@bgicli/bgicli 2.2.8 → 2.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/data/skills/anthropic-algorithmic-art/SKILL.md +405 -0
  2. package/data/skills/anthropic-canvas-design/SKILL.md +130 -0
  3. package/data/skills/anthropic-claude-api/SKILL.md +243 -0
  4. package/data/skills/anthropic-doc-coauthoring/SKILL.md +375 -0
  5. package/data/skills/anthropic-docx/SKILL.md +590 -0
  6. package/data/skills/anthropic-frontend-design/SKILL.md +42 -0
  7. package/data/skills/anthropic-internal-comms/SKILL.md +32 -0
  8. package/data/skills/anthropic-mcp-builder/SKILL.md +236 -0
  9. package/data/skills/anthropic-pdf/SKILL.md +314 -0
  10. package/data/skills/anthropic-pptx/SKILL.md +232 -0
  11. package/data/skills/anthropic-skill-creator/SKILL.md +485 -0
  12. package/data/skills/anthropic-webapp-testing/SKILL.md +96 -0
  13. package/data/skills/anthropic-xlsx/SKILL.md +292 -0
  14. package/data/skills/arxiv-database/SKILL.md +362 -0
  15. package/data/skills/astropy/SKILL.md +329 -0
  16. package/data/skills/ctx-advanced-evaluation/SKILL.md +402 -0
  17. package/data/skills/ctx-bdi-mental-states/SKILL.md +311 -0
  18. package/data/skills/ctx-context-compression/SKILL.md +272 -0
  19. package/data/skills/ctx-context-degradation/SKILL.md +206 -0
  20. package/data/skills/ctx-context-fundamentals/SKILL.md +201 -0
  21. package/data/skills/ctx-context-optimization/SKILL.md +195 -0
  22. package/data/skills/ctx-evaluation/SKILL.md +251 -0
  23. package/data/skills/ctx-filesystem-context/SKILL.md +287 -0
  24. package/data/skills/ctx-hosted-agents/SKILL.md +260 -0
  25. package/data/skills/ctx-memory-systems/SKILL.md +225 -0
  26. package/data/skills/ctx-multi-agent-patterns/SKILL.md +257 -0
  27. package/data/skills/ctx-project-development/SKILL.md +291 -0
  28. package/data/skills/ctx-tool-design/SKILL.md +271 -0
  29. package/data/skills/dhdna-profiler/SKILL.md +162 -0
  30. package/data/skills/generate-image/SKILL.md +183 -0
  31. package/data/skills/geomaster/SKILL.md +365 -0
  32. package/data/skills/get-available-resources/SKILL.md +275 -0
  33. package/data/skills/hamelsmu-build-review-interface/SKILL.md +96 -0
  34. package/data/skills/hamelsmu-error-analysis/SKILL.md +164 -0
  35. package/data/skills/hamelsmu-eval-audit/SKILL.md +183 -0
  36. package/data/skills/hamelsmu-evaluate-rag/SKILL.md +177 -0
  37. package/data/skills/hamelsmu-generate-synthetic-data/SKILL.md +131 -0
  38. package/data/skills/hamelsmu-validate-evaluator/SKILL.md +212 -0
  39. package/data/skills/hamelsmu-write-judge-prompt/SKILL.md +144 -0
  40. package/data/skills/hf-cli/SKILL.md +174 -0
  41. package/data/skills/hf-mcp/SKILL.md +178 -0
  42. package/data/skills/hugging-face-dataset-viewer/SKILL.md +121 -0
  43. package/data/skills/hugging-face-datasets/SKILL.md +542 -0
  44. package/data/skills/hugging-face-evaluation/SKILL.md +651 -0
  45. package/data/skills/hugging-face-jobs/SKILL.md +1042 -0
  46. package/data/skills/hugging-face-model-trainer/SKILL.md +717 -0
  47. package/data/skills/hugging-face-paper-pages/SKILL.md +239 -0
  48. package/data/skills/hugging-face-paper-publisher/SKILL.md +624 -0
  49. package/data/skills/hugging-face-tool-builder/SKILL.md +110 -0
  50. package/data/skills/hugging-face-trackio/SKILL.md +115 -0
  51. package/data/skills/hugging-face-vision-trainer/SKILL.md +593 -0
  52. package/data/skills/huggingface-gradio/SKILL.md +245 -0
  53. package/data/skills/matlab/SKILL.md +376 -0
  54. package/data/skills/modal/SKILL.md +381 -0
  55. package/data/skills/openai-cloudflare-deploy/SKILL.md +224 -0
  56. package/data/skills/openai-develop-web-game/SKILL.md +149 -0
  57. package/data/skills/openai-doc/SKILL.md +80 -0
  58. package/data/skills/openai-figma/SKILL.md +42 -0
  59. package/data/skills/openai-figma-implement-design/SKILL.md +264 -0
  60. package/data/skills/openai-gh-address-comments/SKILL.md +25 -0
  61. package/data/skills/openai-gh-fix-ci/SKILL.md +69 -0
  62. package/data/skills/openai-imagegen/SKILL.md +174 -0
  63. package/data/skills/openai-jupyter-notebook/SKILL.md +107 -0
  64. package/data/skills/openai-linear/SKILL.md +87 -0
  65. package/data/skills/openai-netlify-deploy/SKILL.md +247 -0
  66. package/data/skills/openai-notion-knowledge-capture/SKILL.md +56 -0
  67. package/data/skills/openai-notion-meeting-intelligence/SKILL.md +60 -0
  68. package/data/skills/openai-notion-research-documentation/SKILL.md +59 -0
  69. package/data/skills/openai-notion-spec-to-implementation/SKILL.md +58 -0
  70. package/data/skills/openai-openai-docs/SKILL.md +69 -0
  71. package/data/skills/openai-pdf/SKILL.md +67 -0
  72. package/data/skills/openai-playwright/SKILL.md +147 -0
  73. package/data/skills/openai-render-deploy/SKILL.md +479 -0
  74. package/data/skills/openai-screenshot/SKILL.md +267 -0
  75. package/data/skills/openai-security-best-practices/SKILL.md +86 -0
  76. package/data/skills/openai-security-ownership-map/SKILL.md +206 -0
  77. package/data/skills/openai-security-threat-model/SKILL.md +81 -0
  78. package/data/skills/openai-sentry/SKILL.md +123 -0
  79. package/data/skills/openai-sora/SKILL.md +178 -0
  80. package/data/skills/openai-speech/SKILL.md +144 -0
  81. package/data/skills/openai-spreadsheet/SKILL.md +145 -0
  82. package/data/skills/openai-transcribe/SKILL.md +81 -0
  83. package/data/skills/openai-vercel-deploy/SKILL.md +77 -0
  84. package/data/skills/openai-yeet/SKILL.md +28 -0
  85. package/data/skills/pennylane/SKILL.md +224 -0
  86. package/data/skills/polars-bio/SKILL.md +374 -0
  87. package/data/skills/primekg/SKILL.md +97 -0
  88. package/data/skills/pymatgen/SKILL.md +689 -0
  89. package/data/skills/qiskit/SKILL.md +273 -0
  90. package/data/skills/qutip/SKILL.md +316 -0
  91. package/data/skills/recursive-decomposition/SKILL.md +185 -0
  92. package/data/skills/rowan/SKILL.md +427 -0
  93. package/data/skills/scholar-evaluation/SKILL.md +298 -0
  94. package/data/skills/sentry-create-alert/SKILL.md +210 -0
  95. package/data/skills/sentry-fix-issues/SKILL.md +126 -0
  96. package/data/skills/sentry-pr-code-review/SKILL.md +105 -0
  97. package/data/skills/sentry-python-sdk/SKILL.md +317 -0
  98. package/data/skills/sentry-setup-ai-monitoring/SKILL.md +217 -0
  99. package/data/skills/stable-baselines3/SKILL.md +297 -0
  100. package/data/skills/sympy/SKILL.md +498 -0
  101. package/data/skills/trailofbits-ask-questions-if-underspecified/SKILL.md +85 -0
  102. package/data/skills/trailofbits-audit-context-building/SKILL.md +302 -0
  103. package/data/skills/trailofbits-differential-review/SKILL.md +220 -0
  104. package/data/skills/trailofbits-insecure-defaults/SKILL.md +117 -0
  105. package/data/skills/trailofbits-modern-python/SKILL.md +333 -0
  106. package/data/skills/trailofbits-property-based-testing/SKILL.md +123 -0
  107. package/data/skills/trailofbits-semgrep-rule-creator/SKILL.md +172 -0
  108. package/data/skills/trailofbits-sharp-edges/SKILL.md +292 -0
  109. package/data/skills/trailofbits-variant-analysis/SKILL.md +142 -0
  110. package/data/skills/transformers.js/SKILL.md +637 -0
  111. package/data/skills/writing/SKILL.md +419 -0
  112. package/dist/bgi.js +66 -2
  113. package/package.json +1 -1
@@ -0,0 +1,292 @@
1
+ ---
2
+ name: sharp-edges
3
+ description: "Identifies error-prone APIs, dangerous configurations, and footgun designs that enable security mistakes. Use when reviewing API designs, configuration schemas, cryptographic library ergonomics, or evaluating whether code follows 'secure by default' and 'pit of success' principles. Triggers: footgun, misuse-resistant, secure defaults, API usability, dangerous configuration."
4
+ allowed-tools:
5
+ - Read
6
+ - Grep
7
+ - Glob
8
+ ---
9
+
10
+ # Sharp Edges Analysis
11
+
12
+ Evaluates whether APIs, configurations, and interfaces are resistant to developer misuse. Identifies designs where the "easy path" leads to insecurity.
13
+
14
+ ## When to Use
15
+
16
+ - Reviewing API or library design decisions
17
+ - Auditing configuration schemas for dangerous options
18
+ - Evaluating cryptographic API ergonomics
19
+ - Assessing authentication/authorization interfaces
20
+ - Reviewing any code that exposes security-relevant choices to developers
21
+
22
+ ## When NOT to Use
23
+
24
+ - Implementation bugs (use standard code review)
25
+ - Business logic flaws (use domain-specific analysis)
26
+ - Performance optimization (different concern)
27
+
28
+ ## Core Principle
29
+
30
+ **The pit of success**: Secure usage should be the path of least resistance. If developers must understand cryptography, read documentation carefully, or remember special rules to avoid vulnerabilities, the API has failed.
31
+
32
+ ## Rationalizations to Reject
33
+
34
+ | Rationalization | Why It's Wrong | Required Action |
35
+ |-----------------|----------------|-----------------|
36
+ | "It's documented" | Developers don't read docs under deadline pressure | Make the secure choice the default or only option |
37
+ | "Advanced users need flexibility" | Flexibility creates footguns; most "advanced" usage is copy-paste | Provide safe high-level APIs; hide primitives |
38
+ | "It's the developer's responsibility" | Blame-shifting; you designed the footgun | Remove the footgun or make it impossible to misuse |
39
+ | "Nobody would actually do that" | Developers do everything imaginable under pressure | Assume maximum developer confusion |
40
+ | "It's just a configuration option" | Config is code; wrong configs ship to production | Validate configs; reject dangerous combinations |
41
+ | "We need backwards compatibility" | Insecure defaults can't be grandfather-claused | Deprecate loudly; force migration |
42
+
43
+ ## Sharp Edge Categories
44
+
45
+ ### 1. Algorithm/Mode Selection Footguns
46
+
47
+ APIs that let developers choose algorithms invite choosing wrong ones.
48
+
49
+ **The JWT Pattern** (canonical example):
50
+ - Header specifies algorithm: attacker can set `"alg": "none"` to bypass signatures
51
+ - Algorithm confusion: RSA public key used as HMAC secret when switching RS256→HS256
52
+ - Root cause: Letting untrusted input control security-critical decisions
53
+
54
+ **Detection patterns:**
55
+ - Function parameters like `algorithm`, `mode`, `cipher`, `hash_type`
56
+ - Enums/strings selecting cryptographic primitives
57
+ - Configuration options for security mechanisms
58
+
59
+ **Example - PHP password_hash allowing weak algorithms:**
60
+ ```php
61
+ // DANGEROUS: allows crc32, md5, sha1
62
+ password_hash($password, PASSWORD_DEFAULT); // Good - no choice
63
+ hash($algorithm, $password); // BAD: accepts "crc32"
64
+ ```
65
+
66
+ ### 2. Dangerous Defaults
67
+
68
+ Defaults that are insecure, or zero/empty values that disable security.
69
+
70
+ **The OTP Lifetime Pattern:**
71
+ ```python
72
+ # What happens when lifetime=0?
73
+ def verify_otp(code, lifetime=300): # 300 seconds default
74
+ if lifetime == 0:
75
+ return True # OOPS: 0 means "accept all"?
76
+ # Or does it mean "expired immediately"?
77
+ ```
78
+
79
+ **Detection patterns:**
80
+ - Timeouts/lifetimes that accept 0 (infinite? immediate expiry?)
81
+ - Empty strings that bypass checks
82
+ - Null values that skip validation
83
+ - Boolean defaults that disable security features
84
+ - Negative values with undefined semantics
85
+
86
+ **Questions to ask:**
87
+ - What happens with `timeout=0`? `max_attempts=0`? `key=""`?
88
+ - Is the default the most secure option?
89
+ - Can any default value disable security entirely?
90
+
91
+ ### 3. Primitive vs. Semantic APIs
92
+
93
+ APIs that expose raw bytes instead of meaningful types invite type confusion.
94
+
95
+ **The Libsodium vs. Halite Pattern:**
96
+
97
+ ```php
98
+ // Libsodium (primitives): bytes are bytes
99
+ sodium_crypto_box($message, $nonce, $keypair);
100
+ // Easy to: swap nonce/keypair, reuse nonces, use wrong key type
101
+
102
+ // Halite (semantic): types enforce correct usage
103
+ Crypto::seal($message, new EncryptionPublicKey($key));
104
+ // Wrong key type = type error, not silent failure
105
+ ```
106
+
107
+ **Detection patterns:**
108
+ - Functions taking `bytes`, `string`, `[]byte` for distinct security concepts
109
+ - Parameters that could be swapped without type errors
110
+ - Same type used for keys, nonces, ciphertexts, signatures
111
+
112
+ **The comparison footgun:**
113
+ ```go
114
+ // Timing-safe comparison looks identical to unsafe
115
+ if hmac == expected { } // BAD: timing attack
116
+ if hmac.Equal(mac, expected) { } // Good: constant-time
117
+ // Same types, different security properties
118
+ ```
119
+
120
+ ### 4. Configuration Cliffs
121
+
122
+ One wrong setting creates catastrophic failure, with no warning.
123
+
124
+ **Detection patterns:**
125
+ - Boolean flags that disable security entirely
126
+ - String configs that aren't validated
127
+ - Combinations of settings that interact dangerously
128
+ - Environment variables that override security settings
129
+ - Constructor parameters with sensible defaults but no validation (callers can override with insecure values)
130
+
131
+ **Examples:**
132
+ ```yaml
133
+ # One typo = disaster
134
+ verify_ssl: fasle # Typo silently accepted as truthy?
135
+
136
+ # Magic values
137
+ session_timeout: -1 # Does this mean "never expire"?
138
+
139
+ # Dangerous combinations accepted silently
140
+ auth_required: true
141
+ bypass_auth_for_health_checks: true
142
+ health_check_path: "/" # Oops
143
+ ```
144
+
145
+ ```php
146
+ // Sensible default doesn't protect against bad callers
147
+ public function __construct(
148
+ public string $hashAlgo = 'sha256', // Good default...
149
+ public int $otpLifetime = 120, // ...but accepts md5, 0, etc.
150
+ ) {}
151
+ ```
152
+
153
+ See [config-patterns.md](references/config-patterns.md#unvalidated-constructor-parameters) for detailed patterns.
154
+
155
+ ### 5. Silent Failures
156
+
157
+ Errors that don't surface, or success that masks failure.
158
+
159
+ **Detection patterns:**
160
+ - Functions returning booleans instead of throwing on security failures
161
+ - Empty catch blocks around security operations
162
+ - Default values substituted on parse errors
163
+ - Verification functions that "succeed" on malformed input
164
+
165
+ **Examples:**
166
+ ```python
167
+ # Silent bypass
168
+ def verify_signature(sig, data, key):
169
+ if not key:
170
+ return True # No key = skip verification?!
171
+
172
+ # Return value ignored
173
+ signature.verify(data, sig) # Throws on failure
174
+ crypto.verify(data, sig) # Returns False on failure
175
+ # Developer forgets to check return value
176
+ ```
177
+
178
+ ### 6. Stringly-Typed Security
179
+
180
+ Security-critical values as plain strings enable injection and confusion.
181
+
182
+ **Detection patterns:**
183
+ - SQL/commands built from string concatenation
184
+ - Permissions as comma-separated strings
185
+ - Roles/scopes as arbitrary strings instead of enums
186
+ - URLs constructed by joining strings
187
+
188
+ **The permission accumulation footgun:**
189
+ ```python
190
+ permissions = "read,write"
191
+ permissions += ",admin" # Too easy to escalate
192
+
193
+ # vs. type-safe
194
+ permissions = {Permission.READ, Permission.WRITE}
195
+ permissions.add(Permission.ADMIN) # At least it's explicit
196
+ ```
197
+
198
+ ## Analysis Workflow
199
+
200
+ ### Phase 1: Surface Identification
201
+
202
+ 1. **Map security-relevant APIs**: authentication, authorization, cryptography, session management, input validation
203
+ 2. **Identify developer choice points**: Where can developers select algorithms, configure timeouts, choose modes?
204
+ 3. **Find configuration schemas**: Environment variables, config files, constructor parameters
205
+
206
+ ### Phase 2: Edge Case Probing
207
+
208
+ For each choice point, ask:
209
+ - **Zero/empty/null**: What happens with `0`, `""`, `null`, `[]`?
210
+ - **Negative values**: What does `-1` mean? Infinite? Error?
211
+ - **Type confusion**: Can different security concepts be swapped?
212
+ - **Default values**: Is the default secure? Is it documented?
213
+ - **Error paths**: What happens on invalid input? Silent acceptance?
214
+
215
+ ### Phase 3: Threat Modeling
216
+
217
+ Consider three adversaries:
218
+
219
+ 1. **The Scoundrel**: Actively malicious developer or attacker controlling config
220
+ - Can they disable security via configuration?
221
+ - Can they downgrade algorithms?
222
+ - Can they inject malicious values?
223
+
224
+ 2. **The Lazy Developer**: Copy-pastes examples, skips documentation
225
+ - Will the first example they find be secure?
226
+ - Is the path of least resistance secure?
227
+ - Do error messages guide toward secure usage?
228
+
229
+ 3. **The Confused Developer**: Misunderstands the API
230
+ - Can they swap parameters without type errors?
231
+ - Can they use the wrong key/algorithm/mode by accident?
232
+ - Are failure modes obvious or silent?
233
+
234
+ ### Phase 4: Validate Findings
235
+
236
+ For each identified sharp edge:
237
+
238
+ 1. **Reproduce the misuse**: Write minimal code demonstrating the footgun
239
+ 2. **Verify exploitability**: Does the misuse create a real vulnerability?
240
+ 3. **Check documentation**: Is the danger documented? (Documentation doesn't excuse bad design, but affects severity)
241
+ 4. **Test mitigations**: Can the API be used safely with reasonable effort?
242
+
243
+ If a finding seems questionable, return to Phase 2 and probe more edge cases.
244
+
245
+ ## Severity Classification
246
+
247
+ | Severity | Criteria | Examples |
248
+ |----------|----------|----------|
249
+ | Critical | Default or obvious usage is insecure | `verify: false` default; empty password allowed |
250
+ | High | Easy misconfiguration breaks security | Algorithm parameter accepts "none" |
251
+ | Medium | Unusual but possible misconfiguration | Negative timeout has unexpected meaning |
252
+ | Low | Requires deliberate misuse | Obscure parameter combination |
253
+
254
+ ## References
255
+
256
+ **By category:**
257
+
258
+ - **Cryptographic APIs**: See [references/crypto-apis.md](references/crypto-apis.md)
259
+ - **Configuration Patterns**: See [references/config-patterns.md](references/config-patterns.md)
260
+ - **Authentication/Session**: See [references/auth-patterns.md](references/auth-patterns.md)
261
+ - **Real-World Case Studies**: See [references/case-studies.md](references/case-studies.md) (OpenSSL, GMP, etc.)
262
+
263
+ **By language** (general footguns, not crypto-specific):
264
+
265
+ | Language | Guide |
266
+ |----------|-------|
267
+ | C/C++ | [references/lang-c.md](references/lang-c.md) |
268
+ | Go | [references/lang-go.md](references/lang-go.md) |
269
+ | Rust | [references/lang-rust.md](references/lang-rust.md) |
270
+ | Swift | [references/lang-swift.md](references/lang-swift.md) |
271
+ | Java | [references/lang-java.md](references/lang-java.md) |
272
+ | Kotlin | [references/lang-kotlin.md](references/lang-kotlin.md) |
273
+ | C# | [references/lang-csharp.md](references/lang-csharp.md) |
274
+ | PHP | [references/lang-php.md](references/lang-php.md) |
275
+ | JavaScript/TypeScript | [references/lang-javascript.md](references/lang-javascript.md) |
276
+ | Python | [references/lang-python.md](references/lang-python.md) |
277
+ | Ruby | [references/lang-ruby.md](references/lang-ruby.md) |
278
+
279
+ See also [references/language-specific.md](references/language-specific.md) for a combined quick reference.
280
+
281
+ ## Quality Checklist
282
+
283
+ Before concluding analysis:
284
+
285
+ - [ ] Probed all zero/empty/null edge cases
286
+ - [ ] Verified defaults are secure
287
+ - [ ] Checked for algorithm/mode selection footguns
288
+ - [ ] Tested type confusion between security concepts
289
+ - [ ] Considered all three adversary types
290
+ - [ ] Verified error paths don't bypass security
291
+ - [ ] Checked configuration validation
292
+ - [ ] Constructor params validated (not just defaulted) - see [config-patterns.md](references/config-patterns.md#unvalidated-constructor-parameters)
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: variant-analysis
3
+ description: Find similar vulnerabilities and bugs across codebases using pattern-based analysis. Use when hunting bug variants, building CodeQL/Semgrep queries, analyzing security vulnerabilities, or performing systematic code audits after finding an initial issue.
4
+ ---
5
+
6
+ # Variant Analysis
7
+
8
+ You are a variant analysis expert. Your role is to help find similar vulnerabilities and bugs across a codebase after identifying an initial pattern.
9
+
10
+ ## When to Use
11
+
12
+ Use this skill when:
13
+ - A vulnerability has been found and you need to search for similar instances
14
+ - Building or refining CodeQL/Semgrep queries for security patterns
15
+ - Performing systematic code audits after an initial issue discovery
16
+ - Hunting for bug variants across a codebase
17
+ - Analyzing how a single root cause manifests in different code paths
18
+
19
+ ## When NOT to Use
20
+
21
+ Do NOT use this skill for:
22
+ - Initial vulnerability discovery (use audit-context-building or domain-specific audits instead)
23
+ - General code review without a known pattern to search for
24
+ - Writing fix recommendations (use issue-writer instead)
25
+ - Understanding unfamiliar code (use audit-context-building for deep comprehension first)
26
+
27
+ ## The Five-Step Process
28
+
29
+ ### Step 1: Understand the Original Issue
30
+
31
+ Before searching, deeply understand the known bug:
32
+ - **What is the root cause?** Not the symptom, but WHY it's vulnerable
33
+ - **What conditions are required?** Control flow, data flow, state
34
+ - **What makes it exploitable?** User control, missing validation, etc.
35
+
36
+ ### Step 2: Create an Exact Match
37
+
38
+ Start with a pattern that matches ONLY the known instance:
39
+ ```bash
40
+ rg -n "exact_vulnerable_code_here"
41
+ ```
42
+ Verify: Does it match exactly ONE location (the original)?
43
+
44
+ ### Step 3: Identify Abstraction Points
45
+
46
+ | Element | Keep Specific | Can Abstract |
47
+ |---------|---------------|--------------|
48
+ | Function name | If unique to bug | If pattern applies to family |
49
+ | Variable names | Never | Always use metavariables |
50
+ | Literal values | If value matters | If any value triggers bug |
51
+ | Arguments | If position matters | Use `...` wildcards |
52
+
53
+ ### Step 4: Iteratively Generalize
54
+
55
+ **Change ONE element at a time:**
56
+ 1. Run the pattern
57
+ 2. Review ALL new matches
58
+ 3. Classify: true positive or false positive?
59
+ 4. If FP rate acceptable, generalize next element
60
+ 5. If FP rate too high, revert and try different abstraction
61
+
62
+ **Stop when false positive rate exceeds ~50%**
63
+
64
+ ### Step 5: Analyze and Triage Results
65
+
66
+ For each match, document:
67
+ - **Location**: File, line, function
68
+ - **Confidence**: High/Medium/Low
69
+ - **Exploitability**: Reachable? Controllable inputs?
70
+ - **Priority**: Based on impact and exploitability
71
+
72
+ For deeper strategic guidance, see [METHODOLOGY.md](METHODOLOGY.md).
73
+
74
+ ## Tool Selection
75
+
76
+ | Scenario | Tool | Why |
77
+ |----------|------|-----|
78
+ | Quick surface search | ripgrep | Fast, zero setup |
79
+ | Simple pattern matching | Semgrep | Easy syntax, no build needed |
80
+ | Data flow tracking | Semgrep taint / CodeQL | Follows values across functions |
81
+ | Cross-function analysis | CodeQL | Best interprocedural analysis |
82
+ | Non-building code | Semgrep | Works on incomplete code |
83
+
84
+ ## Key Principles
85
+
86
+ 1. **Root cause first**: Understand WHY before searching for WHERE
87
+ 2. **Start specific**: First pattern should match exactly the known bug
88
+ 3. **One change at a time**: Generalize incrementally, verify after each change
89
+ 4. **Know when to stop**: 50%+ FP rate means you've gone too generic
90
+ 5. **Search everywhere**: Always search the ENTIRE codebase, not just the module where the bug was found
91
+ 6. **Expand vulnerability classes**: One root cause often has multiple manifestations
92
+
93
+ ## Critical Pitfalls to Avoid
94
+
95
+ These common mistakes cause analysts to miss real vulnerabilities:
96
+
97
+ ### 1. Narrow Search Scope
98
+
99
+ Searching only the module where the original bug was found misses variants in other locations.
100
+
101
+ **Example:** Bug found in `api/handlers/` → only searching that directory → missing variant in `utils/auth.py`
102
+
103
+ **Mitigation:** Always run searches against the entire codebase root directory.
104
+
105
+ ### 2. Pattern Too Specific
106
+
107
+ Using only the exact attribute/function from the original bug misses variants using related constructs.
108
+
109
+ **Example:** Bug uses `isAuthenticated` check → only searching for that exact term → missing bugs using related properties like `isActive`, `isAdmin`, `isVerified`
110
+
111
+ **Mitigation:** Enumerate ALL semantically related attributes/functions for the bug class.
112
+
113
+ ### 3. Single Vulnerability Class
114
+
115
+ Focusing on only one manifestation of the root cause misses other ways the same logic error appears.
116
+
117
+ **Example:** Original bug is "return allow when condition is false" → only searching that pattern → missing:
118
+ - Null equality bypasses (`null == null` evaluates to true)
119
+ - Documentation/code mismatches (function does opposite of what docs claim)
120
+ - Inverted conditional logic (wrong branch taken)
121
+
122
+ **Mitigation:** List all possible manifestations of the root cause before searching.
123
+
124
+ ### 4. Missing Edge Cases
125
+
126
+ Testing patterns only with "normal" scenarios misses vulnerabilities triggered by edge cases.
127
+
128
+ **Example:** Testing auth checks only with valid users → missing bypass when `userId = null` matches `resourceOwnerId = null`
129
+
130
+ **Mitigation:** Test with: unauthenticated users, null/undefined values, empty collections, and boundary conditions.
131
+
132
+ ## Resources
133
+
134
+ Ready-to-use templates in `resources/`:
135
+
136
+ **CodeQL** (`resources/codeql/`):
137
+ - `python.ql`, `javascript.ql`, `java.ql`, `go.ql`, `cpp.ql`
138
+
139
+ **Semgrep** (`resources/semgrep/`):
140
+ - `python.yaml`, `javascript.yaml`, `java.yaml`, `go.yaml`, `cpp.yaml`
141
+
142
+ **Report**: `resources/variant-report-template.md`