@vigolium/piolium 0.0.1

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 (271) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/agents/access-auditor.md +300 -0
  4. package/agents/assumption-breaker.md +154 -0
  5. package/agents/attack-designer.md +116 -0
  6. package/agents/code-scanner.md +139 -0
  7. package/agents/concurrency-auditor.md +238 -0
  8. package/agents/confirm-writer.md +257 -0
  9. package/agents/context-reviewer.md +274 -0
  10. package/agents/cross-verifier.md +165 -0
  11. package/agents/cve-scout.md +381 -0
  12. package/agents/env-builder.md +282 -0
  13. package/agents/env-profiler.md +205 -0
  14. package/agents/evidence-collector.md +140 -0
  15. package/agents/finding-grader.md +142 -0
  16. package/agents/finding-writer.md +148 -0
  17. package/agents/flow-tracer.md +106 -0
  18. package/agents/goal-backtracer.md +146 -0
  19. package/agents/history-miner.md +467 -0
  20. package/agents/independent-verifier.md +118 -0
  21. package/agents/intent-mapper.md +183 -0
  22. package/agents/longshot-collector.md +128 -0
  23. package/agents/longshot-prober.md +126 -0
  24. package/agents/patch-auditor.md +73 -0
  25. package/agents/poc-author.md +124 -0
  26. package/agents/poc-runner.md +194 -0
  27. package/agents/probe-lead.md +269 -0
  28. package/agents/red-challenger.md +101 -0
  29. package/agents/report-composer.md +208 -0
  30. package/agents/review-adjudicator.md +216 -0
  31. package/agents/spec-auditor.md +155 -0
  32. package/agents/taint-tracer.md +265 -0
  33. package/agents/test-locator.md +209 -0
  34. package/agents/threat-modeler.md +132 -0
  35. package/agents/variant-scanner.md +108 -0
  36. package/agents/variant-spotter.md +110 -0
  37. package/bin/piolium.mjs +376 -0
  38. package/extensions/piolium/_vendor/yaml.bundle.d.mts +6 -0
  39. package/extensions/piolium/_vendor/yaml.bundle.mjs +139 -0
  40. package/extensions/piolium/agent-runner.ts +322 -0
  41. package/extensions/piolium/agents.ts +266 -0
  42. package/extensions/piolium/audit-state.ts +522 -0
  43. package/extensions/piolium/bundled-resources.ts +97 -0
  44. package/extensions/piolium/candidate-scan.ts +966 -0
  45. package/extensions/piolium/command-target.ts +177 -0
  46. package/extensions/piolium/console-stream.ts +57 -0
  47. package/extensions/piolium/export-results.ts +380 -0
  48. package/extensions/piolium/findings.ts +448 -0
  49. package/extensions/piolium/heartbeat.ts +182 -0
  50. package/extensions/piolium/help.ts +234 -0
  51. package/extensions/piolium/index.ts +1865 -0
  52. package/extensions/piolium/longshot.ts +530 -0
  53. package/extensions/piolium/matcher-suggestions.ts +196 -0
  54. package/extensions/piolium/matcher-utils.ts +83 -0
  55. package/extensions/piolium/modes/balanced.ts +750 -0
  56. package/extensions/piolium/modes/confirm-bootstrap.ts +186 -0
  57. package/extensions/piolium/modes/confirm.ts +697 -0
  58. package/extensions/piolium/modes/deep.ts +917 -0
  59. package/extensions/piolium/modes/diff.ts +177 -0
  60. package/extensions/piolium/modes/lite.ts +540 -0
  61. package/extensions/piolium/modes/longshot.ts +595 -0
  62. package/extensions/piolium/modes/merge.ts +204 -0
  63. package/extensions/piolium/modes/phase-runner.ts +267 -0
  64. package/extensions/piolium/modes/reinvest.ts +546 -0
  65. package/extensions/piolium/modes/revisit.ts +279 -0
  66. package/extensions/piolium/modes.ts +48 -0
  67. package/extensions/piolium/phase-labels.ts +123 -0
  68. package/extensions/piolium/phase-status-strip.ts +92 -0
  69. package/extensions/piolium/prompt-prefix-editor.ts +39 -0
  70. package/extensions/piolium/providers/anthropic-vertex.ts +836 -0
  71. package/extensions/piolium/recon.ts +409 -0
  72. package/extensions/piolium/result-stats.ts +105 -0
  73. package/extensions/piolium/retry.ts +120 -0
  74. package/extensions/piolium/scheduler.ts +212 -0
  75. package/extensions/piolium/secrets.ts +368 -0
  76. package/extensions/piolium/tools/web-tools.ts +148 -0
  77. package/package.json +77 -0
  78. package/skills/agentic-actions-auditor/SKILL.md +327 -0
  79. package/skills/agentic-actions-auditor/references/action-profiles.md +186 -0
  80. package/skills/agentic-actions-auditor/references/cross-file-resolution.md +209 -0
  81. package/skills/agentic-actions-auditor/references/foundations.md +94 -0
  82. package/skills/agentic-actions-auditor/references/vector-a-env-var-intermediary.md +77 -0
  83. package/skills/agentic-actions-auditor/references/vector-b-direct-expression-injection.md +83 -0
  84. package/skills/agentic-actions-auditor/references/vector-c-cli-data-fetch.md +83 -0
  85. package/skills/agentic-actions-auditor/references/vector-d-pr-target-checkout.md +88 -0
  86. package/skills/agentic-actions-auditor/references/vector-e-error-log-injection.md +88 -0
  87. package/skills/agentic-actions-auditor/references/vector-f-subshell-expansion.md +82 -0
  88. package/skills/agentic-actions-auditor/references/vector-g-eval-of-ai-output.md +91 -0
  89. package/skills/agentic-actions-auditor/references/vector-h-dangerous-sandbox-configs.md +102 -0
  90. package/skills/agentic-actions-auditor/references/vector-i-wildcard-allowlists.md +88 -0
  91. package/skills/audit/SKILL.md +562 -0
  92. package/skills/audit/assets/icon.svg +7 -0
  93. package/skills/audit/hooks/scripts/validate_phase_output.py +550 -0
  94. package/skills/audit/references/adversarial-review.md +148 -0
  95. package/skills/audit/references/architecture-aware-sast.md +306 -0
  96. package/skills/audit/references/audit-workflow.md +737 -0
  97. package/skills/audit/references/chamber-protocol.md +384 -0
  98. package/skills/audit/references/creative-attack-modes.md +221 -0
  99. package/skills/audit/references/deep-analysis.md +273 -0
  100. package/skills/audit/references/domain-attack-playbooks.md +1129 -0
  101. package/skills/audit/references/knowledge-base-template.md +513 -0
  102. package/skills/audit/references/real-env-validation.md +191 -0
  103. package/skills/audit/references/report-templates.md +417 -0
  104. package/skills/audit/references/triage-and-prereqs.md +134 -0
  105. package/skills/audit/scripts/consolidate_drafts.py +554 -0
  106. package/skills/audit/scripts/partition_findings.py +152 -0
  107. package/skills/audit/scripts/rg-hotspots.sh +121 -0
  108. package/skills/audit/scripts/stamp_file_state.py +349 -0
  109. package/skills/code-reviewer/SKILL.md +65 -0
  110. package/skills/codeql/SKILL.md +281 -0
  111. package/skills/codeql/references/build-fixes.md +90 -0
  112. package/skills/codeql/references/diagnostic-query-templates.md +339 -0
  113. package/skills/codeql/references/extension-yaml-format.md +209 -0
  114. package/skills/codeql/references/important-only-suite.md +153 -0
  115. package/skills/codeql/references/language-details.md +207 -0
  116. package/skills/codeql/references/macos-arm64e-workaround.md +179 -0
  117. package/skills/codeql/references/performance-tuning.md +111 -0
  118. package/skills/codeql/references/quality-assessment.md +172 -0
  119. package/skills/codeql/references/ruleset-catalog.md +63 -0
  120. package/skills/codeql/references/run-all-suite.md +92 -0
  121. package/skills/codeql/references/sarif-processing.md +79 -0
  122. package/skills/codeql/references/threat-models.md +51 -0
  123. package/skills/codeql/workflows/build-database.md +280 -0
  124. package/skills/codeql/workflows/create-data-extensions.md +261 -0
  125. package/skills/codeql/workflows/run-analysis.md +301 -0
  126. package/skills/differential-review/SKILL.md +220 -0
  127. package/skills/differential-review/adversarial.md +203 -0
  128. package/skills/differential-review/methodology.md +234 -0
  129. package/skills/differential-review/patterns.md +300 -0
  130. package/skills/differential-review/reporting.md +369 -0
  131. package/skills/fp-check/SKILL.md +125 -0
  132. package/skills/fp-check/references/bug-class-verification.md +114 -0
  133. package/skills/fp-check/references/deep-verification.md +143 -0
  134. package/skills/fp-check/references/evidence-templates.md +91 -0
  135. package/skills/fp-check/references/false-positive-patterns.md +115 -0
  136. package/skills/fp-check/references/gate-reviews.md +27 -0
  137. package/skills/fp-check/references/standard-verification.md +78 -0
  138. package/skills/insecure-defaults/SKILL.md +117 -0
  139. package/skills/insecure-defaults/references/examples.md +409 -0
  140. package/skills/last30days/SKILL.md +444 -0
  141. package/skills/sarif-parsing/SKILL.md +483 -0
  142. package/skills/sarif-parsing/resources/jq-queries.md +162 -0
  143. package/skills/sarif-parsing/resources/sarif_helpers.py +331 -0
  144. package/skills/security-threat-model/LICENSE.txt +201 -0
  145. package/skills/security-threat-model/SKILL.md +81 -0
  146. package/skills/security-threat-model/agents/openai.yaml +4 -0
  147. package/skills/security-threat-model/references/prompt-template.md +255 -0
  148. package/skills/security-threat-model/references/security-controls-and-assets.md +32 -0
  149. package/skills/semgrep/SKILL.md +212 -0
  150. package/skills/semgrep/references/rulesets.md +162 -0
  151. package/skills/semgrep/references/scan-modes.md +110 -0
  152. package/skills/semgrep/references/scanner-task-prompt.md +140 -0
  153. package/skills/semgrep/scripts/merge_sarif.py +203 -0
  154. package/skills/semgrep/workflows/scan-workflow.md +311 -0
  155. package/skills/semgrep-rule-creator/SKILL.md +168 -0
  156. package/skills/semgrep-rule-creator/references/quick-reference.md +202 -0
  157. package/skills/semgrep-rule-creator/references/workflow.md +240 -0
  158. package/skills/semgrep-rule-variant-creator/SKILL.md +205 -0
  159. package/skills/semgrep-rule-variant-creator/references/applicability-analysis.md +250 -0
  160. package/skills/semgrep-rule-variant-creator/references/language-syntax-guide.md +324 -0
  161. package/skills/semgrep-rule-variant-creator/references/workflow.md +518 -0
  162. package/skills/sharp-edges/SKILL.md +292 -0
  163. package/skills/sharp-edges/references/auth-patterns.md +252 -0
  164. package/skills/sharp-edges/references/case-studies.md +274 -0
  165. package/skills/sharp-edges/references/config-patterns.md +333 -0
  166. package/skills/sharp-edges/references/crypto-apis.md +190 -0
  167. package/skills/sharp-edges/references/lang-c.md +205 -0
  168. package/skills/sharp-edges/references/lang-csharp.md +285 -0
  169. package/skills/sharp-edges/references/lang-go.md +270 -0
  170. package/skills/sharp-edges/references/lang-java.md +263 -0
  171. package/skills/sharp-edges/references/lang-javascript.md +269 -0
  172. package/skills/sharp-edges/references/lang-kotlin.md +265 -0
  173. package/skills/sharp-edges/references/lang-php.md +245 -0
  174. package/skills/sharp-edges/references/lang-python.md +274 -0
  175. package/skills/sharp-edges/references/lang-ruby.md +273 -0
  176. package/skills/sharp-edges/references/lang-rust.md +272 -0
  177. package/skills/sharp-edges/references/lang-swift.md +287 -0
  178. package/skills/sharp-edges/references/language-specific.md +588 -0
  179. package/skills/spec-to-code-compliance/SKILL.md +357 -0
  180. package/skills/spec-to-code-compliance/resources/COMPLETENESS_CHECKLIST.md +69 -0
  181. package/skills/spec-to-code-compliance/resources/IR_EXAMPLES.md +417 -0
  182. package/skills/spec-to-code-compliance/resources/OUTPUT_REQUIREMENTS.md +105 -0
  183. package/skills/supply-chain-risk-auditor/SKILL.md +67 -0
  184. package/skills/supply-chain-risk-auditor/resources/results-template.md +41 -0
  185. package/skills/variant-analysis/METHODOLOGY.md +327 -0
  186. package/skills/variant-analysis/SKILL.md +142 -0
  187. package/skills/variant-analysis/resources/codeql/cpp.ql +119 -0
  188. package/skills/variant-analysis/resources/codeql/go.ql +69 -0
  189. package/skills/variant-analysis/resources/codeql/java.ql +71 -0
  190. package/skills/variant-analysis/resources/codeql/javascript.ql +63 -0
  191. package/skills/variant-analysis/resources/codeql/python.ql +80 -0
  192. package/skills/variant-analysis/resources/semgrep/cpp.yaml +98 -0
  193. package/skills/variant-analysis/resources/semgrep/go.yaml +63 -0
  194. package/skills/variant-analysis/resources/semgrep/java.yaml +61 -0
  195. package/skills/variant-analysis/resources/semgrep/javascript.yaml +60 -0
  196. package/skills/variant-analysis/resources/semgrep/python.yaml +72 -0
  197. package/skills/variant-analysis/resources/variant-report-template.md +75 -0
  198. package/skills/vuln-report/SKILL.md +137 -0
  199. package/skills/vuln-report/agents/openai.yaml +4 -0
  200. package/skills/vuln-report/references/report-template.md +135 -0
  201. package/skills/wooyun-legacy/SKILL.md +367 -0
  202. package/skills/wooyun-legacy/references/bank-penetration.md +222 -0
  203. package/skills/wooyun-legacy/references/checklists/command-execution-checklist.md +119 -0
  204. package/skills/wooyun-legacy/references/checklists/csrf-checklist.md +74 -0
  205. package/skills/wooyun-legacy/references/checklists/file-upload-checklist.md +108 -0
  206. package/skills/wooyun-legacy/references/checklists/info-disclosure-checklist.md +114 -0
  207. package/skills/wooyun-legacy/references/checklists/logic-flaws-checklist.md +95 -0
  208. package/skills/wooyun-legacy/references/checklists/misconfig-checklist.md +124 -0
  209. package/skills/wooyun-legacy/references/checklists/path-traversal-checklist.md +87 -0
  210. package/skills/wooyun-legacy/references/checklists/rce-checklist.md +93 -0
  211. package/skills/wooyun-legacy/references/checklists/sql-injection-checklist.md +97 -0
  212. package/skills/wooyun-legacy/references/checklists/ssrf-checklist.md +99 -0
  213. package/skills/wooyun-legacy/references/checklists/unauthorized-access-checklist.md +89 -0
  214. package/skills/wooyun-legacy/references/checklists/weak-password-checklist.md +115 -0
  215. package/skills/wooyun-legacy/references/checklists/xss-checklist.md +103 -0
  216. package/skills/wooyun-legacy/references/checklists/xxe-checklist.md +130 -0
  217. package/skills/wooyun-legacy/references/info-disclosure.md +975 -0
  218. package/skills/wooyun-legacy/references/logic-flaws.md +721 -0
  219. package/skills/wooyun-legacy/references/path-traversal.md +1191 -0
  220. package/skills/wooyun-legacy/references/telecom-penetration.md +156 -0
  221. package/skills/wooyun-legacy/references/unauthorized-access.md +980 -0
  222. package/skills/wooyun-legacy/references/xss.md +746 -0
  223. package/skills/zeroize-audit/SKILL.md +371 -0
  224. package/skills/zeroize-audit/configs/c.yaml +21 -0
  225. package/skills/zeroize-audit/configs/default.yaml +128 -0
  226. package/skills/zeroize-audit/configs/rust.yaml +83 -0
  227. package/skills/zeroize-audit/prompts/report_template.md +238 -0
  228. package/skills/zeroize-audit/prompts/system.md +163 -0
  229. package/skills/zeroize-audit/prompts/task.md +97 -0
  230. package/skills/zeroize-audit/references/compile-commands.md +231 -0
  231. package/skills/zeroize-audit/references/detection-strategy.md +191 -0
  232. package/skills/zeroize-audit/references/ir-analysis.md +252 -0
  233. package/skills/zeroize-audit/references/mcp-analysis.md +221 -0
  234. package/skills/zeroize-audit/references/poc-generation.md +470 -0
  235. package/skills/zeroize-audit/references/rust-zeroization-patterns.md +867 -0
  236. package/skills/zeroize-audit/schemas/input.json +83 -0
  237. package/skills/zeroize-audit/schemas/output.json +140 -0
  238. package/skills/zeroize-audit/tools/analyze_asm.sh +202 -0
  239. package/skills/zeroize-audit/tools/analyze_cfg.py +381 -0
  240. package/skills/zeroize-audit/tools/analyze_heap.sh +211 -0
  241. package/skills/zeroize-audit/tools/analyze_ir_semantic.py +429 -0
  242. package/skills/zeroize-audit/tools/diff_ir.sh +135 -0
  243. package/skills/zeroize-audit/tools/diff_rust_mir.sh +189 -0
  244. package/skills/zeroize-audit/tools/emit_asm.sh +67 -0
  245. package/skills/zeroize-audit/tools/emit_ir.sh +77 -0
  246. package/skills/zeroize-audit/tools/emit_rust_asm.sh +178 -0
  247. package/skills/zeroize-audit/tools/emit_rust_ir.sh +150 -0
  248. package/skills/zeroize-audit/tools/emit_rust_mir.sh +158 -0
  249. package/skills/zeroize-audit/tools/extract_compile_flags.py +284 -0
  250. package/skills/zeroize-audit/tools/generate_poc.py +1329 -0
  251. package/skills/zeroize-audit/tools/mcp/apply_confidence_gates.py +113 -0
  252. package/skills/zeroize-audit/tools/mcp/check_mcp.sh +68 -0
  253. package/skills/zeroize-audit/tools/mcp/normalize_mcp_evidence.py +125 -0
  254. package/skills/zeroize-audit/tools/scripts/check_llvm_patterns.py +481 -0
  255. package/skills/zeroize-audit/tools/scripts/check_mir_patterns.py +554 -0
  256. package/skills/zeroize-audit/tools/scripts/check_rust_asm.py +424 -0
  257. package/skills/zeroize-audit/tools/scripts/check_rust_asm_aarch64.py +300 -0
  258. package/skills/zeroize-audit/tools/scripts/check_rust_asm_x86.py +283 -0
  259. package/skills/zeroize-audit/tools/scripts/find_dangerous_apis.py +375 -0
  260. package/skills/zeroize-audit/tools/scripts/semantic_audit.py +923 -0
  261. package/skills/zeroize-audit/tools/track_dataflow.sh +196 -0
  262. package/skills/zeroize-audit/tools/validate_rust_toolchain.sh +298 -0
  263. package/skills/zeroize-audit/workflows/phase-0-preflight.md +150 -0
  264. package/skills/zeroize-audit/workflows/phase-1-source-analysis.md +144 -0
  265. package/skills/zeroize-audit/workflows/phase-2-compiler-analysis.md +139 -0
  266. package/skills/zeroize-audit/workflows/phase-3-interim-report.md +46 -0
  267. package/skills/zeroize-audit/workflows/phase-4-poc-generation.md +46 -0
  268. package/skills/zeroize-audit/workflows/phase-5-poc-validation.md +136 -0
  269. package/skills/zeroize-audit/workflows/phase-6-final-report.md +44 -0
  270. package/skills/zeroize-audit/workflows/phase-7-test-generation.md +42 -0
  271. package/themes/piolium-srcery.json +94 -0
@@ -0,0 +1,281 @@
1
+ ---
2
+ name: codeql
3
+ description: >-
4
+ Scans a codebase for security vulnerabilities using CodeQL's interprocedural data flow and
5
+ taint tracking analysis. Triggers on "run codeql", "codeql scan", "codeql analysis", "build
6
+ codeql database", or "find vulnerabilities with codeql". Supports "run all" (security-and-quality
7
+ suite) and "important only" (high-precision security findings) scan modes. Also handles
8
+ creating data extension models and processing CodeQL SARIF output.
9
+ allowed-tools:
10
+ - Bash
11
+ - Read
12
+ - Write
13
+ - Edit
14
+ - Glob
15
+ - Grep
16
+ - AskUserQuestion
17
+ - TaskCreate
18
+ - TaskList
19
+ - TaskUpdate
20
+ - TaskGet
21
+ - TodoRead
22
+ - TodoWrite
23
+ ---
24
+
25
+ # CodeQL Analysis
26
+
27
+ Supported languages: Python, JavaScript/TypeScript, Go, Java/Kotlin, C/C++, C#, Ruby, Swift.
28
+
29
+ **Skill resources:** Reference files and templates are located at `{baseDir}/references/` and `{baseDir}/workflows/`.
30
+
31
+ ## Essential Principles
32
+
33
+ 1. **Database quality is non-negotiable.** A database that builds is not automatically good. Always run quality assessment (file counts, baseline LoC, extractor errors) and compare against expected source files. A cached build produces zero useful extraction.
34
+
35
+ 2. **Data extensions catch what CodeQL misses.** Even projects using standard frameworks (Django, Spring, Express) have custom wrappers around database calls, request parsing, or shell execution. Skipping the create-data-extensions workflow means missing vulnerabilities in project-specific code paths.
36
+
37
+ 3. **Explicit suite references prevent silent query dropping.** Never pass pack names directly to `codeql database analyze` — each pack's `defaultSuiteFile` applies hidden filters that can produce zero results. Always generate a custom `.qls` suite file.
38
+
39
+ 4. **Zero findings needs investigation, not celebration.** Zero results can indicate poor database quality, missing models, wrong query packs, or silent suite filtering. Investigate before reporting clean.
40
+
41
+ 5. **macOS Apple Silicon requires workarounds for compiled languages.** Exit code 137 is `arm64e`/`arm64` mismatch, not a build failure. Try Homebrew arm64 tools or Rosetta before falling back to `build-mode=none`.
42
+
43
+ 6. **Follow workflows step by step.** Once a workflow is selected, execute it step by step without skipping phases. Each phase gates the next — skipping quality assessment or data extensions leads to incomplete analysis.
44
+
45
+ ## Output Directory
46
+
47
+ All generated files (database, build logs, diagnostics, extensions, results) are stored in a single output directory.
48
+
49
+ - **If the user specifies an output directory** in their prompt, use it as `OUTPUT_DIR`.
50
+ - **If not specified**, default to `./static_analysis_codeql_1`. If that already exists, increment to `_2`, `_3`, etc.
51
+
52
+ In both cases, **always create the directory** with `mkdir -p` before writing any files.
53
+
54
+ ```bash
55
+ # Resolve output directory
56
+ if [ -n "$USER_SPECIFIED_DIR" ]; then
57
+ OUTPUT_DIR="$USER_SPECIFIED_DIR"
58
+ else
59
+ BASE="static_analysis_codeql"
60
+ N=1
61
+ while [ -e "${BASE}_${N}" ]; do
62
+ N=$((N + 1))
63
+ done
64
+ OUTPUT_DIR="${BASE}_${N}"
65
+ fi
66
+ mkdir -p "$OUTPUT_DIR"
67
+ ```
68
+
69
+ The output directory is resolved **once** at the start before any workflow executes. All workflows receive `$OUTPUT_DIR` and store their artifacts there:
70
+
71
+ ```
72
+ $OUTPUT_DIR/
73
+ ├── rulesets.txt # Selected query packs (logged after Step 3)
74
+ ├── codeql.db/ # CodeQL database (dir containing codeql-database.yml)
75
+ ├── build.log # Build log
76
+ ├── codeql-config.yml # Exclusion config (interpreted languages)
77
+ ├── diagnostics/ # Diagnostic queries and CSVs
78
+ ├── extensions/ # Data extension YAMLs
79
+ ├── raw/ # Unfiltered analysis output
80
+ │ ├── results.sarif
81
+ │ └── <mode>.qls
82
+ └── results/ # Final results (filtered for important-only, copied for run-all)
83
+ └── results.sarif
84
+ ```
85
+
86
+ ### Database Discovery
87
+
88
+ A CodeQL database is identified by the presence of a `codeql-database.yml` marker file inside its directory. When searching for existing databases, **always collect all matches** — there may be multiple databases from previous runs or for different languages.
89
+
90
+ **Discovery command:**
91
+
92
+ ```bash
93
+ # Find ALL CodeQL databases (top-level and one subdirectory deep)
94
+ find . -maxdepth 3 -name "codeql-database.yml" -not -path "*/\.*" 2>/dev/null \
95
+ | while read -r yml; do dirname "$yml"; done
96
+ ```
97
+
98
+ - **Inside `$OUTPUT_DIR`:** `find "$OUTPUT_DIR" -maxdepth 2 -name "codeql-database.yml"`
99
+ - **Project-wide (for auto-detection):** `find . -maxdepth 3 -name "codeql-database.yml"` — covers databases at the project top level (`./db-name/`) and one subdirectory deep (`./subdir/db-name/`). Does not search deeper.
100
+
101
+ Never assume a database is named `codeql.db` — discover it by its marker file.
102
+
103
+ **When multiple databases are found:**
104
+
105
+ For each discovered database, collect metadata to help the user choose:
106
+
107
+ ```bash
108
+ # For each database, extract language and creation time
109
+ for db in $FOUND_DBS; do
110
+ CODEQL_LANG=$(codeql resolve database --format=json -- "$db" 2>/dev/null | jq -r '.languages[0]')
111
+ CREATED=$(grep '^creationMetadata:' -A5 "$db/codeql-database.yml" 2>/dev/null | grep 'creationTime' | awk '{print $2}')
112
+ echo "$db — language: $CODEQL_LANG, created: $CREATED"
113
+ done
114
+ ```
115
+
116
+ Then use `AskUserQuestion` to let the user select which database to use, or to build a new one. **Skip `AskUserQuestion` if the user explicitly stated which database to use or to build a new one in their prompt.**
117
+
118
+ ## Quick Start
119
+
120
+ For the common case ("scan this codebase for vulnerabilities"):
121
+
122
+ ```bash
123
+ # 1. Verify CodeQL is installed
124
+ if ! command -v codeql >/dev/null 2>&1; then
125
+ echo "NOT INSTALLED: codeql binary not found on PATH"
126
+ else
127
+ codeql --version || echo "ERROR: codeql found but --version failed (check installation)"
128
+ fi
129
+
130
+ # 2. Resolve output directory
131
+ BASE="static_analysis_codeql"; N=1
132
+ while [ -e "${BASE}_${N}" ]; do N=$((N + 1)); done
133
+ OUTPUT_DIR="${BASE}_${N}"; mkdir -p "$OUTPUT_DIR"
134
+ ```
135
+
136
+ Then execute the full pipeline: **build database → create data extensions → run analysis** using the workflows below.
137
+
138
+ ## When to Use
139
+
140
+ - Scanning a codebase for security vulnerabilities with deep data flow analysis
141
+ - Building a CodeQL database from source code (with build capability for compiled languages)
142
+ - Finding complex vulnerabilities that require interprocedural taint tracking or AST/CFG analysis
143
+ - Performing comprehensive security audits with multiple query packs
144
+
145
+ ## When NOT to Use
146
+
147
+ - **Writing custom queries** - Use a dedicated query development skill
148
+ - **CI/CD integration** - Use GitHub Actions documentation directly
149
+ - **Quick pattern searches** - Use Semgrep or grep for speed
150
+ - **No build capability** for compiled languages - Consider Semgrep instead
151
+ - **Single-file or lightweight analysis** - Semgrep is faster for simple pattern matching
152
+
153
+ ## Rationalizations to Reject
154
+
155
+ These shortcuts lead to missed findings. Do not accept them:
156
+
157
+ - **"security-extended is enough"** - It is the baseline. Always check if Trail of Bits packs and Community Packs are available for the language. They catch categories `security-extended` misses entirely.
158
+ - **"The database built, so it's good"** - A database that builds does not mean it extracted well. Always run quality assessment and check file counts against expected source files.
159
+ - **"Data extensions aren't needed for standard frameworks"** - Even Django/Spring apps have custom wrappers that CodeQL does not model. Skipping extensions means missing vulnerabilities.
160
+ - **"build-mode=none is fine for compiled languages"** - It produces severely incomplete analysis. Only use as an absolute last resort. On macOS, try the arm64 toolchain workaround or Rosetta first.
161
+ - **"The build fails on macOS, just use build-mode=none"** - Exit code 137 is caused by `arm64e`/`arm64` mismatch, not a fundamental build failure. See [macos-arm64e-workaround.md](references/macos-arm64e-workaround.md).
162
+ - **"No findings means the code is secure"** - Zero findings can indicate poor database quality, missing models, or wrong query packs. Investigate before reporting clean results.
163
+ - **"I'll just run the default suite"** / **"I'll just pass the pack names directly"** - Each pack's `defaultSuiteFile` applies hidden filters and can produce zero results. Always use an explicit suite reference.
164
+ - **"I'll put files in the current directory"** - All generated files must go in `$OUTPUT_DIR`. Scattering files in the working directory makes cleanup impossible and risks overwriting previous runs.
165
+ - **"Just use the first database I find"** - Multiple databases may exist for different languages or from previous runs. When more than one is found, present all options to the user. Only skip the prompt when the user already specified which database to use.
166
+ - **"The user said 'scan', that means they want me to pick a database"** - "Scan" is not database selection. If multiple databases exist and the user didn't name one, ask.
167
+
168
+ ---
169
+
170
+ ## Workflow Selection
171
+
172
+ This skill has three workflows. **Once a workflow is selected, execute it step by step without skipping phases.**
173
+
174
+ | Workflow | Purpose |
175
+ |----------|---------|
176
+ | [build-database](workflows/build-database.md) | Create CodeQL database using build methods in sequence |
177
+ | [create-data-extensions](workflows/create-data-extensions.md) | Detect or generate data extension models for project APIs |
178
+ | [run-analysis](workflows/run-analysis.md) | Select rulesets, execute queries, process results |
179
+
180
+ ### Auto-Detection Logic
181
+
182
+ **If user explicitly specifies** what to do (e.g., "build a database", "run analysis on ./my-db"), execute that workflow directly. **Do NOT call `AskUserQuestion` for database selection if the user's prompt already makes their intent clear** — e.g., "build a new database", "analyze the codeql database in static_analysis_codeql_2", "run a full scan from scratch".
183
+
184
+ **Default pipeline for "test", "scan", "analyze", or similar:** Discover existing databases first, then decide.
185
+
186
+ ```bash
187
+ # Find ALL CodeQL databases by looking for codeql-database.yml marker file
188
+ # Search top-level dirs and one subdirectory deep
189
+ FOUND_DBS=()
190
+ while IFS= read -r yml; do
191
+ db_dir=$(dirname "$yml")
192
+ codeql resolve database -- "$db_dir" >/dev/null 2>&1 && FOUND_DBS+=("$db_dir")
193
+ done < <(find . -maxdepth 3 -name "codeql-database.yml" -not -path "*/\.*" 2>/dev/null)
194
+
195
+ echo "Found ${#FOUND_DBS[@]} existing database(s)"
196
+ ```
197
+
198
+ | Condition | Action |
199
+ |-----------|--------|
200
+ | No databases found | Resolve new `$OUTPUT_DIR`, execute build → extensions → analysis (full pipeline) |
201
+ | One database found | Use `AskUserQuestion`: reuse it or build new? |
202
+ | Multiple databases found | Use `AskUserQuestion`: list all with metadata, let user pick one or build new |
203
+ | User explicitly stated intent | Skip `AskUserQuestion`, act on their instructions directly |
204
+
205
+ ### Database Selection Prompt
206
+
207
+ When existing databases are found **and the user did not explicitly specify which to use**, present via `AskUserQuestion`:
208
+
209
+ ```
210
+ header: "Existing CodeQL Databases"
211
+ question: "I found existing CodeQL database(s). What would you like to do?"
212
+ options:
213
+ - label: "<db_path_1> (language: python, created: 2026-02-24)"
214
+ description: "Reuse this database"
215
+ - label: "<db_path_2> (language: cpp, created: 2026-02-23)"
216
+ description: "Reuse this database"
217
+ - label: "Build a new database"
218
+ description: "Create a fresh database in a new output directory"
219
+ ```
220
+
221
+ After selection:
222
+ - **If user picks an existing database:** Set `$OUTPUT_DIR` to its parent directory (or the directory containing it), set `$DB_NAME` to the selected path, then proceed to extensions → analysis.
223
+ - **If user picks "Build new":** Resolve a new `$OUTPUT_DIR`, execute build → extensions → analysis.
224
+
225
+ ### General Decision Prompt
226
+
227
+ If the user's intent is ambiguous (neither database selection nor workflow is clear), ask:
228
+
229
+ ```
230
+ I can help with CodeQL analysis. What would you like to do?
231
+
232
+ 1. **Full scan (Recommended)** - Build database, create extensions, then run analysis
233
+ 2. **Build database** - Create a new CodeQL database from this codebase
234
+ 3. **Create data extensions** - Generate custom source/sink models for project APIs
235
+ 4. **Run analysis** - Run security queries on existing database
236
+
237
+ [If databases found: "I found N existing database(s): <list paths with language>"]
238
+ [Show output directory: "Output will be stored in <OUTPUT_DIR>"]
239
+ ```
240
+
241
+ ---
242
+
243
+ ## Reference Index
244
+
245
+ | File | Content |
246
+ |------|---------|
247
+ | **Workflows** | |
248
+ | [workflows/build-database.md](workflows/build-database.md) | Database creation with build method sequence |
249
+ | [workflows/create-data-extensions.md](workflows/create-data-extensions.md) | Data extension generation pipeline |
250
+ | [workflows/run-analysis.md](workflows/run-analysis.md) | Query execution and result processing |
251
+ | **References** | |
252
+ | [references/macos-arm64e-workaround.md](references/macos-arm64e-workaround.md) | Apple Silicon build tracing workarounds |
253
+ | [references/build-fixes.md](references/build-fixes.md) | Build failure fix catalog |
254
+ | [references/quality-assessment.md](references/quality-assessment.md) | Database quality metrics and improvements |
255
+ | [references/extension-yaml-format.md](references/extension-yaml-format.md) | Data extension YAML column definitions and examples |
256
+ | [references/sarif-processing.md](references/sarif-processing.md) | jq commands for SARIF output processing |
257
+ | [references/diagnostic-query-templates.md](references/diagnostic-query-templates.md) | QL queries for source/sink enumeration |
258
+ | [references/important-only-suite.md](references/important-only-suite.md) | Important-only suite template and generation |
259
+ | [references/run-all-suite.md](references/run-all-suite.md) | Run-all suite template |
260
+ | [references/ruleset-catalog.md](references/ruleset-catalog.md) | Available query packs by language |
261
+ | [references/threat-models.md](references/threat-models.md) | Threat model configuration |
262
+ | [references/language-details.md](references/language-details.md) | Language-specific build and extraction details |
263
+ | [references/performance-tuning.md](references/performance-tuning.md) | Memory, threading, and timeout configuration |
264
+
265
+ ---
266
+
267
+ ## Success Criteria
268
+
269
+ A complete CodeQL analysis run should satisfy:
270
+
271
+ - [ ] Output directory resolved (user-specified or auto-incremented default)
272
+ - [ ] All generated files stored inside `$OUTPUT_DIR`
273
+ - [ ] Database built (discovered via `codeql-database.yml` marker) with quality assessment passed (baseline LoC > 0, errors < 5%)
274
+ - [ ] Data extensions evaluated — either created in `$OUTPUT_DIR/extensions/` or explicitly skipped with justification
275
+ - [ ] Analysis run with explicit suite reference (not default pack suite)
276
+ - [ ] All installed query packs (official + Trail of Bits + Community) used or explicitly excluded
277
+ - [ ] Selected query packs logged to `$OUTPUT_DIR/rulesets.txt`
278
+ - [ ] Unfiltered results preserved in `$OUTPUT_DIR/raw/results.sarif`
279
+ - [ ] Final results in `$OUTPUT_DIR/results/results.sarif` (filtered for important-only, copied for run-all)
280
+ - [ ] Zero-finding results investigated (database quality, model coverage, suite selection)
281
+ - [ ] Build log preserved at `$OUTPUT_DIR/build.log` with all commands, fixes, and quality assessments
@@ -0,0 +1,90 @@
1
+ # Build Fixes
2
+
3
+ Fixes to apply when a CodeQL database build method fails. Try these in order, then retry the current build method. **Log each fix attempt.**
4
+
5
+ ## 1. Clean existing state
6
+
7
+ ```bash
8
+ log_step "Applying fix: clean existing state"
9
+ rm -rf "$DB_NAME"
10
+ log_result "Removed $DB_NAME"
11
+ ```
12
+
13
+ ## 2. Clean build cache
14
+
15
+ ```bash
16
+ log_step "Applying fix: clean build cache"
17
+ CLEANED=""
18
+ make clean 2>/dev/null && CLEANED="$CLEANED make"
19
+ rm -rf build CMakeCache.txt CMakeFiles 2>/dev/null && CLEANED="$CLEANED cmake-artifacts"
20
+ ./gradlew clean 2>/dev/null && CLEANED="$CLEANED gradle"
21
+ mvn clean 2>/dev/null && CLEANED="$CLEANED maven"
22
+ cargo clean 2>/dev/null && CLEANED="$CLEANED cargo"
23
+ log_result "Cleaned: $CLEANED"
24
+ ```
25
+
26
+ ## 3. Install missing dependencies
27
+
28
+ > **Note:** The commands below install the *target project's* dependencies so CodeQL can trace the build. Use whatever package manager the target project expects (`pip`, `npm`, `go mod`, etc.) — these are not the skill's own tooling preferences.
29
+
30
+ ```bash
31
+ log_step "Applying fix: install dependencies"
32
+
33
+ # Python — use target project's package manager (pip/uv/poetry)
34
+ if [ -f requirements.txt ]; then
35
+ log_cmd "pip install -r requirements.txt"
36
+ pip install -r requirements.txt 2>&1 | tee -a "$LOG_FILE"
37
+ fi
38
+ if [ -f setup.py ] || [ -f pyproject.toml ]; then
39
+ log_cmd "pip install -e ."
40
+ pip install -e . 2>&1 | tee -a "$LOG_FILE"
41
+ fi
42
+
43
+ # Node - log installed packages
44
+ if [ -f package.json ]; then
45
+ log_cmd "npm install"
46
+ npm install 2>&1 | tee -a "$LOG_FILE"
47
+ fi
48
+
49
+ # Go
50
+ if [ -f go.mod ]; then
51
+ log_cmd "go mod download"
52
+ go mod download 2>&1 | tee -a "$LOG_FILE"
53
+ fi
54
+
55
+ # Java - log downloaded dependencies
56
+ if [ -f build.gradle ] || [ -f build.gradle.kts ]; then
57
+ log_cmd "./gradlew dependencies --refresh-dependencies"
58
+ ./gradlew dependencies --refresh-dependencies 2>&1 | tee -a "$LOG_FILE"
59
+ fi
60
+ if [ -f pom.xml ]; then
61
+ log_cmd "mvn dependency:resolve"
62
+ mvn dependency:resolve 2>&1 | tee -a "$LOG_FILE"
63
+ fi
64
+
65
+ # Rust
66
+ if [ -f Cargo.toml ]; then
67
+ log_cmd "cargo fetch"
68
+ cargo fetch 2>&1 | tee -a "$LOG_FILE"
69
+ fi
70
+
71
+ log_result "Dependencies installed - see above for details"
72
+ ```
73
+
74
+ ## 4. Handle private registries
75
+
76
+ If dependencies require authentication, ask user:
77
+ ```
78
+ AskUserQuestion: "Build requires private registry access. Options:"
79
+ 1. "I'll configure auth and retry"
80
+ 2. "Skip these dependencies"
81
+ 3. "Show me what's needed"
82
+ ```
83
+
84
+ ```bash
85
+ # Log authentication setup if performed
86
+ log_step "Private registry authentication configured"
87
+ log_result "Registry: <REGISTRY_URL>, Method: <AUTH_METHOD>"
88
+ ```
89
+
90
+ **After fixes:** Retry current build method. If still fails, move to next method.