semgrep-rule-variant-creator
Skill này làm gì
Tool này giúp điều chỉnh các quy tắc bảo mật code (gọi là 'Semgrep rules') cho các ngôn ngữ lập trình khác nhau. Nếu bạn có một quy tắc hoạt động trên một ngôn ngữ, tool có thể giúp tạo phiên bản của quy tắc đó cho các ngôn ngữ khác.
Khi nào nên dùng
- ✓Khi bạn điều chỉnh một quy tắc bảo mật có sẵn cho một ngôn ngữ mới.
- ✓Khi bạn tạo các phiên bản của cùng một kiểm tra bảo mật cho nhiều ngôn ngữ trong một dự án.
- ✓Khi bạn mở rộng phạm vi bảo mật của code sang các ngôn ngữ chưa từng bao phủ trước đây.
Liên kết skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/semgrep-rule-variant-creator/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Điều chỉnh quy tắc 'sql-injection' cho Go và Java.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Tool phân tích xem quy tắc gốc có hợp lý trong ngôn ngữ mới không, tạo các ví dụ code để kiểm thử quy tắc, rồi sinh ra quy tắc mới và bài kiểm thử của nó. Nó đảm bảo mỗi quy tắc mới được kiểm thử độc lập.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Semgrep Rule Variant Creator
Port existing Semgrep rules to new target languages with proper applicability analysis and test-driven validation.
When to Use
Ideal scenarios:
- Porting an existing Semgrep rule to one or more target languages
- Creating language-specific variants of a universal vulnerability pattern
- Expanding rule coverage across a polyglot codebase
- Translating rules between languages with equivalent constructs
When NOT to Use
Do NOT use this skill for:
- Creating a new Semgrep rule from scratch (use
semgrep-rule-creatorinstead) - Running existing rules against code
- Languages where the vulnerability pattern fundamentally doesn't apply
- Minor syntax variations within the same language
Input Specification
This skill requires:
- Existing Semgrep rule - YAML file path or YAML rule content
- Target languages - One or more languages to port to (e.g., "Golang and Java")
Output Specification
For each applicable target language, produces:
<original-rule-id>-<language>/
├── <original-rule-id>-<language>.yaml # Ported Semgrep rule
└── <original-rule-id>-<language>.<ext> # Test file with annotations
Example output for porting sql-injection to Go and Java:
sql-injection-golang/
├── sql-injection-golang.yaml
└── sql-injection-golang.go
sql-injection-java/
├── sql-injection-java.yaml
└── sql-injection-java.java
Rationalizations to Reject
When porting Semgrep rules, reject these common shortcuts:
| Rationalization | Why It Fails | Correct Approach |
|---|---|---|
| "Pattern structure is identical" | Different ASTs across languages | Always dump AST for target language |
| "Same vulnerability, same detection" | Data flow differs between languages | Analyze target language idioms |
| "Rule doesn't need tests since original worked" | Language edge cases differ | Write NEW test cases for target |
| "Skip applicability - it obviously applies" | Some patterns are language-specific | Complete applicability analysis first |
| "I'll create all variants then test" | Errors compound, hard to debug | Complete full cycle per language |
| "Library equivalent is close enough" | Surface similarity hides differences | Verify API semantics match |
| "Just translate the syntax 1:1" | Languages have different idioms | Research target language patterns |
Strictness Level
This workflow is strict - do not skip steps:
- Applicability analysis is mandatory: Don't assume patterns translate
- Each language is independent: Complete full cycle before moving to next
- Test-first for each variant: Never write a rule without test cases
- 100% test pass required: "Most tests pass" is not acceptable
Overview
This skill guides the creation of language-specific variants of existing Semgrep rules. Each target language goes through an independent 4-phase cycle:
FOR EACH target language:
Phase 1: Applicability Analysis → Verdict
Phase 2: Test Creation (Test-First)
Phase 3: Rule Creation
Phase 4: Validation
(Complete full cycle before moving to next language)
Foundational Knowledge
The semgrep-rule-creator skill is the authoritative reference for Semgrep rule creation fundamentals. While this skill focuses on porting existing rules to new languages, the core principles of writing quality rules remain the same.
Consult semgrep-rule-creator for guidance on:
- When to use taint mode vs pattern matching - Choosing the right approach for the vulnerability type
- Test-first methodology - Why tests come before rules and how to write effective test cases
- Anti-patterns to avoid - Common mistakes like overly broad or overly specific patterns
- Iterating until tests pass - The validation loop and debugging techniques
- Rule optimization - Removing redundant patterns after tests pass
When porting a rule, you're applying these same principles in a new language context. If uncertain about rule structure or approach, refer to semgrep-rule-creator first.
Four-Phase Workflow
Phase 1: Applicability Analysis
Before porting, determine if the pattern applies to the target language.
Analysis criteria:
- Does the vulnerability class exist in the target language?
- Does an equivalent construct exist (function, pattern, library)?
- Are the semantics similar enough for meaningful detection?
Verdict options:
APPLICABLE→ Proceed with variant creation
…
Câu hỏi thường gặp
“Semgrep rules” là gì?
Đó giống như các công thức dạy chương trình tìm các mẫu code cụ thể, thường để xác định lỗ hổng bảo mật hoặc lỗi.
Vì sao không thể chỉ sao chép quy tắc sang ngôn ngữ khác?
Mỗi ngôn ngữ có những đặc điểm và cách làm việc riêng. Một quy tắc hoạt động hoàn hảo ở ngôn ngữ này có thể không hoạt động, hoặc phát hiện sai, ở ngôn ngữ khác, dù trông có vẻ tương tự.
Tôi có cần biết lập trình để dùng không?
Bạn không cần là lập trình viên giàu kinh nghiệm. Tool tự động hóa quá trình điều chỉnh, nhưng hiểu cơ bản quy tắc gốc làm gì sẽ giúp bạn chọn đúng ngôn ngữ.
Chi tiết
Mô tả gốc của tác giả
Creates language variants of existing Semgrep rules. Use when porting a Semgrep rule to specified target languages. Takes an existing rule and target languages as input, produces independent rule+test directories for each language.
Độ phổ biến
- Sao GitHub
- 48k
- Vị trí xếp hạng
- #5714
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
00-andruia-consultant
48kGiúp agent của bạn bắt đầu hoặc cải thiện các dự án AI. Phân tích mã, gợi ý công cụ và lập kế hoạch hành động bằng tiếng Tây Ban Nha.
007
48kCho phép agent của bạn thực hiện kiểm toán bảo mật và mô hình hóa mối đe dọa. Hữu ích để bảo vệ dự án khỏi các cuộc tấn công và lỗ hổng.
10-andruia-skill-smith
48kGiúp agent của bạn tạo hoặc cải thiện các công cụ AI. Xác định cách công cụ hoạt động, viết tài liệu và kiểm tra cấu trúc.
20-andruia-niche-intelligence
48kGiúp agent của bạn tạo bản tóm tắt về một ngành cụ thể. Hữu ích để hiểu bối cảnh, quy tắc, cách người dùng tương tác và rủi ro của dự án.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.