Saltar al contenido
Skillpedia
Programación general48 mil · #5713

semgrep-rule-creator

Qué hace

Esta herramienta te ayuda a crear reglas personalizadas para Semgrep, un programa que revisa tu código en busca de fallos de seguridad o patrones de programación. Se asegura de que tus reglas estén bien probadas y funcionen correctamente.

Cuándo usarla

  • ✓Cuando necesitas encontrar un tipo concreto de problema de seguridad en tu código.
  • ✓Cuando quieres crear reglas que aseguren que tu código sigue un patrón determinado.
  • ✓Para comprobar si datos externos (como los que escribe un usuario) pueden causar problemas de seguridad al usarse en partes sensibles del código.

Link de la skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/semgrep-rule-creator/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/semgrep-rule-creator/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Crea una regla de Semgrep para encontrar dónde se usa `eval()` con datos del usuario en Python.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

Tú describes el problema y los casos que deberían encontrarse o no. La herramienta te ayuda a escribir primero las pruebas, luego la regla, asegurándose de que funcione en todos los casos probados.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

Semgrep Rule Creator

Create production-quality Semgrep rules with proper testing and validation.

When to Use

Ideal scenarios:

  • Writing Semgrep rules for specific bug patterns
  • Writing rules to detect security vulnerabilities in your codebase
  • Writing taint mode rules for data flow vulnerabilities
  • Writing rules to enforce coding standards

When NOT to Use

Do NOT use this skill for:

  • Running existing Semgrep rulesets
  • General static analysis without custom rules (use static-analysis skill)

Rationalizations to Reject

When writing Semgrep rules, reject these common shortcuts:

  • "The pattern looks complete" → Still run semgrep --test --config <rule-id>.yaml <rule-id>.<ext> to verify. Untested rules have hidden false positives/negatives.
  • "It matches the vulnerable case" → Matching vulnerabilities is half the job. Verify safe cases don't match (false positives break trust).
  • "Taint mode is overkill for this" → If data flows from user input to a dangerous sink, taint mode gives better precision than pattern matching.
  • "One test is enough" → Include edge cases: different coding styles, sanitized inputs, safe alternatives, and boundary conditions.
  • "I'll optimize the patterns first" → Write correct patterns first, optimize after all tests pass. Premature optimization causes regressions.
  • "The AST dump is too complex" → The AST reveals exactly how Semgrep sees code. Skipping it leads to patterns that miss syntactic variations.

Anti-Patterns

Too broad - matches everything, useless for detection:

# BAD: Matches any function call
pattern: $FUNC(...)

# GOOD: Specific dangerous function
pattern: eval(...) # security-allowlist: Semgrep sink pattern

Missing safe cases in tests - leads to undetected false positives:

# BAD: Only tests vulnerable case
# ruleid: my-rule
dangerous(user_input)

# GOOD: Include safe cases to verify no false positives
# ruleid: my-rule
dangerous(user_input)

# ok: my-rule
dangerous(sanitize(user_input))

# ok: my-rule
dangerous("hardcoded_safe_value")

Overly specific patterns - misses variations:

# BAD: Only matches exact format
pattern: os.system("rm " + $VAR)

# GOOD: Matches all os.system calls with taint tracking
mode: taint
pattern-sinks:
  - pattern: os.system(...)

Strictness Level

This workflow is strict - do not skip steps:

  • Read documentation first: See Documentation before writing Semgrep rules
  • Test-first is mandatory: Never write a rule without tests
  • 100% test pass is required: "Most tests pass" is not acceptable
  • Optimization comes last: Only simplify patterns after all tests pass
  • Avoid generic patterns: Rules must be specific, not match broad patterns
  • Prioritize taint mode: For data flow vulnerabilities
  • One YAML file - one Semgrep rule: Each YAML file must contain only one Semgrep rule; don't combine multiple rules in a single file
  • No generic rules: When targeting a specific language for Semgrep rules - avoid generic pattern matching (languages: generic)
  • Forbidden todook and todoruleid test annotations: todoruleid: <rule-id> and todook: <rule-id> annotations in tests files for future rule improvements are forbidden

Overview

This skill guides creation of Semgrep rules that detect security vulnerabilities and code patterns. Rules are created iteratively: analyze the problem, write tests first, analyze AST structure, write the rule, iterate until all tests pass, optimize the rule.

Approach selection:

  • Taint mode (prioritize): Data flow issues where untrusted input reaches dangerous sinks
  • Pattern matching: Simple syntactic patterns without data flow requirements

Why prioritize taint mode? Pattern matching finds syntax but misses context. A pattern eval($X) matches both eval(user_input) (vulnerable) and eval("safe_literal") (safe). Taint mode tracks data flow, so it only alerts when untrusted data actually reaches the sink—dramatically reducing false positives for injection vulnerabilities. <!-- security-allowlist: Semgrep taint-mode explanation -->

…

Preguntas frecuentes

¿Qué es Semgrep?

Semgrep es una herramienta que analiza tu código para encontrar problemas, como errores o fallos de seguridad, usando reglas que tú u otras personas creáis.

¿Qué son las 'reglas' de Semgrep?

Son como recetas que le indican a Semgrep qué buscar en tu código. Pueden ser simples, como 'encuentra todas las llamadas a esta función', o más complejas, como 'encuentra dónde llegan datos no confiables a un punto peligroso'.

¿Por qué es importante probar las reglas?

Probar la regla garantiza que encuentre los problemas que debe encontrar (sin dejar ninguno) y que no marque problemas donde no los hay (evitando falsas alarmas). Las reglas sin probar pueden ser inútiles o incluso perjudiciales.

Detalles

Descripción original del autor

Creates custom Semgrep rules for detecting security vulnerabilities, bug patterns, and code patterns. Use when writing Semgrep rules or building custom static analysis detections.

repo: sickn33/agentic-awesome-skills

Popularidad

Estrellas en GitHub
48 mil
Posición en el ranking
#5713
Licencia
MIT
Actualizada
15/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas