semgrep-rule-creator
यह क्या करती है
यह टूल Semgrep के लिए कस्टम rules बनाने में मदद करता है। Semgrep एक प्रोग्राम है जो आपके code में security की खामियों या coding patterns को जांचता है। यह सुनिश्चित करता है कि आपके rules अच्छी तरह test किए गए हों और सही तरह काम करें।
कब इस्तेमाल करें
- ✓जब आपको अपने code में किसी खास तरह की security समस्या को ढूंढना हो।
- ✓जब आपको ऐसे rules बनाने हों जिससे आपका code किसी खास pattern का पालन करे।
- ✓यह जांचने के लिए कि बाहरी data (जैसे user से आया data) code के किसी संवेदनशील हिस्से में इस्तेमाल होने पर security समस्या तो नहीं पैदा करता।
Skill का लिंक
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/semgrep-rule-creator/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“Python में जहां user input के साथ `eval()` इस्तेमाल होता है, वहां ढूंढने के लिए एक Semgrep rule बनाओ।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
आप समस्या और उन cases का वर्णन करते हैं जो मिलने चाहिए या नहीं मिलने चाहिए। टूल पहले tests लिखने में मदद करता है, फिर rule, ताकि पक्का हो कि वह सभी test किए गए cases के लिए सही काम करता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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-analysisskill)
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
todookandtodoruleidtest annotations:todoruleid: <rule-id>andtodook: <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 -->
…
अक्सर पूछे जाने वाले सवाल
Semgrep क्या है?
Semgrep एक टूल है जो आपके code का विश्लेषण करके उसमें bugs या security vulnerabilities जैसी समस्याएं ढूंढता है। यह rules का इस्तेमाल करता है जिन्हें आप या दूसरे लोग बनाते हैं।
Semgrep के 'rules' क्या होते हैं?
ये recipes की तरह होते हैं जो Semgrep को बताते हैं कि code में क्या ढूंढना है। ये सरल हो सकते हैं, जैसे 'इस function की सभी calls ढूंढो', या जटिल, जैसे 'वह जगह ढूंढो जहां भरोसे के लायक न होने वाला data किसी खतरनाक बिंदु तक पहुंचता है'।
rules की testing क्यों ज़रूरी है?
Testing से पक्का होता है कि rule वही समस्याएं ढूंढे जो उसे ढूंढनी चाहिए (कुछ छूटे नहीं) और वहां अलर्ट न दे जहां नहीं देना चाहिए (झूठे अलार्म से बचाव)। बिना test किए rules बेकार या नुकसानदायक भी हो सकते हैं।
जानकारी
लेखक का मूल विवरण
Creates custom Semgrep rules for detecting security vulnerabilities, bug patterns, and code patterns. Use when writing Semgrep rules or building custom static analysis detections.
लोकप्रियता
- GitHub स्टार
- 48k
- रैंकिंग में स्थान
- #5713
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
00-andruia-consultant
48kआपके एजेंट को AI प्रोजेक्ट शुरू करने या उन्हें बेहतर बनाने में मदद करता है। यह code का विश्लेषण करता है, tools सुझाता है और स्पेनिश भाषा में action plan बनाता है।
007
48kआपका एजेंट security audit और threat modeling करता है। यह प्रोजेक्ट को हमलों और कमजोरियों से बचाने में काम आता है।
10-andruia-skill-smith
48kआपके एजेंट को AI tools बनाने या उन्हें बेहतर करने में मदद करता है। यह तय करता है कि tools कैसे काम करेंगे, documentation लिखता है और structure की जांच करता है।
20-andruia-niche-intelligence
48kआपका एजेंट किसी खास industry का summary बनाता है। भरोसेमंद स्रोतों की मदद से यह प्रोजेक्ट का संदर्भ, नियम, इस्तेमाल के तरीके और जोखिम समझने में मदद करता है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।