@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,63 @@
1
+ # Ruleset Catalog
2
+
3
+ ## Official CodeQL Suites
4
+
5
+ | Suite | False Positives | Use Case |
6
+ |-------|-----------------|----------|
7
+ | `security-extended` | Low | **Default** - Security audits |
8
+ | `security-and-quality` | Medium | Comprehensive review |
9
+ | `security-experimental` | Higher | Research, vulnerability hunting |
10
+
11
+ **Usage:** `codeql/<lang>-queries:codeql-suites/<lang>-security-extended.qls`
12
+
13
+ **Languages:** `cpp`, `csharp`, `go`, `java`, `javascript`, `python`, `ruby`, `swift`
14
+
15
+ ---
16
+
17
+ ## Trail of Bits Packs
18
+
19
+ | Pack | Language | Focus |
20
+ |------|----------|-------|
21
+ | `trailofbits/cpp-queries` | C/C++ | Memory safety, integer overflows |
22
+ | `trailofbits/go-queries` | Go | Concurrency, error handling |
23
+ | `trailofbits/java-queries` | Java | Security, code quality |
24
+
25
+ **Install:**
26
+ ```bash
27
+ codeql pack download trailofbits/cpp-queries
28
+ codeql pack download trailofbits/go-queries
29
+ codeql pack download trailofbits/java-queries
30
+ ```
31
+
32
+ ---
33
+
34
+ ## CodeQL Community Packs
35
+
36
+ | Pack | Language |
37
+ |------|----------|
38
+ | `GitHubSecurityLab/CodeQL-Community-Packs-JavaScript` | JavaScript/TypeScript |
39
+ | `GitHubSecurityLab/CodeQL-Community-Packs-Python` | Python |
40
+ | `GitHubSecurityLab/CodeQL-Community-Packs-Go` | Go |
41
+ | `GitHubSecurityLab/CodeQL-Community-Packs-Java` | Java |
42
+ | `GitHubSecurityLab/CodeQL-Community-Packs-CPP` | C/C++ |
43
+ | `GitHubSecurityLab/CodeQL-Community-Packs-CSharp` | C# |
44
+ | `GitHubSecurityLab/CodeQL-Community-Packs-Ruby` | Ruby |
45
+
46
+ **Install:**
47
+ ```bash
48
+ codeql pack download GitHubSecurityLab/CodeQL-Community-Packs-<Lang>
49
+ ```
50
+
51
+ **Source:** [github.com/GitHubSecurityLab/CodeQL-Community-Packs](https://github.com/GitHubSecurityLab/CodeQL-Community-Packs)
52
+
53
+ ---
54
+
55
+ ## Verify Installation
56
+
57
+ ```bash
58
+ # List all installed packs
59
+ codeql resolve qlpacks
60
+
61
+ # Check specific packs
62
+ codeql resolve qlpacks | grep -E "(trailofbits|GitHubSecurityLab)"
63
+ ```
@@ -0,0 +1,92 @@
1
+ # Run-All Query Suite
2
+
3
+ In run-all mode, generate a custom `.qls` query suite file at runtime. This ensures all queries from all installed packs actually execute, avoiding the silent filtering caused by each pack's `defaultSuiteFile`.
4
+
5
+ ## Why a Custom Suite
6
+
7
+ When you pass a pack name directly to `codeql database analyze` (e.g., `-- codeql/cpp-queries`), CodeQL uses the pack's `defaultSuiteFile` field from `qlpack.yml`. For official packs, this is typically `codeql-suites/<lang>-code-scanning.qls`, which applies strict precision and severity filters. This silently drops many queries and can produce zero results for small codebases.
8
+
9
+ The run-all suite explicitly references the broadest built-in suite (`security-and-quality`) for official packs and loads third-party packs with minimal filtering.
10
+
11
+ ## Suite Template
12
+
13
+ Generate this file as `run-all.qls` in the results directory before running analysis:
14
+
15
+ ```yaml
16
+ - description: Run-all — all security and quality queries from all installed packs
17
+ # Official queries: use security-and-quality suite (broadest built-in suite)
18
+ - import: codeql-suites/<CODEQL_LANG>-security-and-quality.qls
19
+ from: codeql/<CODEQL_LANG>-queries
20
+ # Third-party packs (include only if installed, one entry per pack)
21
+ # - queries: .
22
+ # from: trailofbits/<CODEQL_LANG>-queries
23
+ # - queries: .
24
+ # from: GitHubSecurityLab/CodeQL-Community-Packs-<CODEQL_LANG>
25
+ # Minimal filtering — only select alert-type queries
26
+ - include:
27
+ kind:
28
+ - problem
29
+ - path-problem
30
+ - exclude:
31
+ deprecated: //
32
+ - exclude:
33
+ tags contain:
34
+ - modeleditor
35
+ - modelgenerator
36
+ ```
37
+
38
+ ## Generation Script
39
+
40
+ ```bash
41
+ RAW_DIR="$OUTPUT_DIR/raw"
42
+ SUITE_FILE="$RAW_DIR/run-all.qls"
43
+
44
+ # NOTE: CODEQL_LANG must be set before running this script (e.g., CODEQL_LANG=cpp)
45
+ # NOTE: INSTALLED_THIRD_PARTY_PACKS must be a space-separated list of pack names
46
+
47
+ cat > "$SUITE_FILE" << HEADER
48
+ - description: Run-all — all security and quality queries from all installed packs
49
+ - import: codeql-suites/${CODEQL_LANG}-security-and-quality.qls
50
+ from: codeql/${CODEQL_LANG}-queries
51
+ HEADER
52
+
53
+ # Add each installed third-party pack
54
+ for PACK in $INSTALLED_THIRD_PARTY_PACKS; do
55
+ cat >> "$SUITE_FILE" << PACK_ENTRY
56
+ - queries: .
57
+ from: ${PACK}
58
+ PACK_ENTRY
59
+ done
60
+
61
+ # Append minimal filtering rules (quoted heredoc — no expansion needed)
62
+ cat >> "$SUITE_FILE" << 'FILTERS'
63
+ - include:
64
+ kind:
65
+ - problem
66
+ - path-problem
67
+ - exclude:
68
+ deprecated: //
69
+ - exclude:
70
+ tags contain:
71
+ - modeleditor
72
+ - modelgenerator
73
+ FILTERS
74
+
75
+ # Verify the suite resolves correctly
76
+ : "${CODEQL_LANG:?ERROR: CODEQL_LANG must be set before generating suite}"
77
+ : "${SUITE_FILE:?ERROR: SUITE_FILE must be set}"
78
+
79
+ if ! codeql resolve queries "$SUITE_FILE" | wc -l; then
80
+ echo "ERROR: Suite file failed to resolve. Check CODEQL_LANG=$CODEQL_LANG and installed packs."
81
+ fi
82
+ echo "Suite generated: $SUITE_FILE"
83
+ ```
84
+
85
+ ## How This Differs From Important-Only
86
+
87
+ | Aspect | Run all | Important only |
88
+ |--------|---------|----------------|
89
+ | Official pack suite | `security-and-quality` (all security + code quality) | All queries loaded, filtered by precision |
90
+ | Third-party packs | All `problem`/`path-problem` queries | Only `security`-tagged queries with precision metadata |
91
+ | Precision filter | None | high/very-high always; medium only if security-severity >= 6.0 |
92
+ | Post-analysis filter | None | Drops medium-precision results with security-severity < 6.0 |
@@ -0,0 +1,79 @@
1
+ # SARIF Processing
2
+
3
+ jq commands for processing CodeQL SARIF output. Used in the run-analysis workflow Step 5.
4
+
5
+ > **SARIF structure note:** `security-severity` and `level` are stored on rule definitions (`.runs[].tool.driver.rules[]`), NOT on individual result objects. Results reference rules by `ruleIndex`. The jq commands below join results with their rule metadata.
6
+ >
7
+ > **Portability note:** These jq patterns assume CodeQL SARIF output where `ruleIndex` is populated. For SARIF from other tools (e.g., Semgrep), use `ruleId`-based lookups instead.
8
+
9
+ > **Directory convention:** Unfiltered output lives in `$RAW_DIR` (`$OUTPUT_DIR/raw`). Final results live in `$RESULTS_DIR` (`$OUTPUT_DIR/results`). The summary commands below operate on `$RESULTS_DIR/results.sarif` (the final output).
10
+
11
+ ## Count Findings
12
+
13
+ ```bash
14
+ jq '.runs[].results | length' "$RESULTS_DIR/results.sarif"
15
+ ```
16
+
17
+ ## Summary by SARIF Level
18
+
19
+ ```bash
20
+ jq -r '
21
+ .runs[] |
22
+ . as $run |
23
+ .results[] |
24
+ ($run.tool.driver.rules[.ruleIndex].defaultConfiguration.level // "unknown")
25
+ ' "$RESULTS_DIR/results.sarif" \
26
+ | sort | uniq -c | sort -rn
27
+ ```
28
+
29
+ ## Summary by Security Severity (most useful for triage)
30
+
31
+ ```bash
32
+ jq -r '
33
+ .runs[] |
34
+ . as $run |
35
+ .results[] |
36
+ ($run.tool.driver.rules[.ruleIndex].properties["security-severity"] // "none") + " | " +
37
+ .ruleId + " | " +
38
+ (.locations[0].physicalLocation.artifactLocation.uri // "?") + ":" +
39
+ ((.locations[0].physicalLocation.region.startLine // 0) | tostring) + " | " +
40
+ (.message.text // "no message" | .[0:80])
41
+ ' "$RESULTS_DIR/results.sarif" | sort -rn | head -20
42
+ ```
43
+
44
+ ## Summary by Rule
45
+
46
+ ```bash
47
+ jq -r '.runs[].results[] | .ruleId' "$RESULTS_DIR/results.sarif" \
48
+ | sort | uniq -c | sort -rn
49
+ ```
50
+
51
+ ## Important-Only Post-Filter
52
+
53
+ If scan mode is "important only", filter out medium-precision results with `security-severity` < 6.0 from the report. The suite includes all medium-precision security queries to let CodeQL evaluate them, but low-severity medium-precision findings are noise.
54
+
55
+ The filter reads from `$RAW_DIR/results.sarif` (unfiltered) and writes to `$RESULTS_DIR/results.sarif` (final). The raw file is preserved unmodified.
56
+
57
+ ```bash
58
+ # Filter important-only results: drop medium-precision findings with security-severity < 6.0
59
+ # Medium-precision queries without a security-severity score default to 0.0 (excluded).
60
+ # Non-medium queries are always kept regardless of security-severity.
61
+ # Reads from raw/, writes to results/ — preserving the unfiltered original.
62
+ RAW_DIR="$OUTPUT_DIR/raw"
63
+ RESULTS_DIR="$OUTPUT_DIR/results"
64
+ jq '
65
+ .runs[] |= (
66
+ . as $run |
67
+ .results = [
68
+ .results[] |
69
+ ($run.tool.driver.rules[.ruleIndex].properties.precision // "unknown") as $prec |
70
+ ($run.tool.driver.rules[.ruleIndex].properties["security-severity"] // null) as $raw_sev |
71
+ (if $prec == "medium" then ($raw_sev // "0" | tonumber) else 10 end) as $sev |
72
+ select(
73
+ ($prec == "high") or ($prec == "very-high") or ($prec == "unknown") or
74
+ ($prec == "medium" and $sev >= 6.0)
75
+ )
76
+ ]
77
+ )
78
+ ' "$RAW_DIR/results.sarif" > "$RESULTS_DIR/results.sarif"
79
+ ```
@@ -0,0 +1,51 @@
1
+ # Threat Models Reference
2
+
3
+ Control which source categories are active during CodeQL analysis. By default, only `remote` sources are tracked.
4
+
5
+ ## Available Models
6
+
7
+ | Model | Sources Included | When to Enable | False Positive Impact |
8
+ |-------|------------------|----------------|----------------------|
9
+ | `remote` | HTTP requests, network input | Always (default). Covers web services, APIs, network-facing code. | Low — these are the most common attack vectors. |
10
+ | `local` | Command line args, local files | CLI tools, batch processors, desktop apps where local users are untrusted. | Medium — generates noise for web-only services where CLI args are developer-controlled. |
11
+ | `environment` | Environment variables | Apps that read config from env vars at runtime (12-factor apps, containers). Skip for apps that only read env at startup into validated config objects. | Medium — many env reads are startup-only config, not runtime-tainted data. |
12
+ | `database` | Database query results | Second-order injection scenarios: stored XSS, data from shared databases where other writers are untrusted. | High — most apps trust their own database. Only enable when auditing for stored/second-order attacks. |
13
+ | `file` | File contents | File upload processors, log parsers, config file readers that accept user-provided files. | Medium — triggers on all file reads including trusted config files. |
14
+
15
+ ## Default Behavior
16
+
17
+ With no `--threat-model` flag, CodeQL uses `remote` only (the `default` group). This is correct for most web applications and APIs. Expanding beyond `remote` is useful when the application's trust boundary extends to local inputs.
18
+
19
+ ## Usage
20
+
21
+ Enable additional threat models with the `--threat-model` flag (singular, NOT `--threat-models`):
22
+
23
+ ```bash
24
+ # Web service (default — remote only, no flag needed)
25
+ codeql database analyze codeql.db \
26
+ -- results/suite.qls
27
+
28
+ # CLI tool — local users can provide malicious input
29
+ codeql database analyze codeql.db \
30
+ --threat-model local \
31
+ -- results/suite.qls
32
+
33
+ # Container app reading env vars from untrusted orchestrator
34
+ codeql database analyze codeql.db \
35
+ --threat-model local --threat-model environment \
36
+ -- results/suite.qls
37
+
38
+ # Full coverage — audit mode for all input vectors
39
+ codeql database analyze codeql.db \
40
+ --threat-model all \
41
+ -- results/suite.qls
42
+
43
+ # Enable all except database (to reduce noise)
44
+ codeql database analyze codeql.db \
45
+ --threat-model all --threat-model '!database' \
46
+ -- results/suite.qls
47
+ ```
48
+
49
+ The `--threat-model` flag can be repeated. Each invocation adds (or removes with `!` prefix) a threat model group. The `remote` group is always enabled by default — use `--threat-model '!default'` to disable it (rare). The `all` group enables everything, and `!<name>` disables a specific model.
50
+
51
+ Multiple models can be combined. Each additional model expands the set of sources CodeQL considers tainted, increasing coverage but potentially increasing false positives. Start with the narrowest set that matches the application's actual threat model, then expand if needed.
@@ -0,0 +1,280 @@
1
+ # Build Database Workflow
2
+
3
+ Create high-quality CodeQL databases by trying build methods in sequence until one produces good results.
4
+
5
+ ## Task System
6
+
7
+ Create these tasks on workflow start:
8
+
9
+ ```
10
+ TaskCreate: "Detect language and configure" (Step 1)
11
+ TaskCreate: "Build database" (Step 2) - blockedBy: Step 1
12
+ TaskCreate: "Apply fixes if needed" (Step 3) - blockedBy: Step 2
13
+ TaskCreate: "Assess quality" (Step 4) - blockedBy: Step 3
14
+ TaskCreate: "Improve quality if needed" (Step 5) - blockedBy: Step 4
15
+ TaskCreate: "Generate final report" (Step 6) - blockedBy: Step 5
16
+ ```
17
+
18
+ ---
19
+
20
+ ## Overview
21
+
22
+ Database creation differs by language type:
23
+
24
+ ### Interpreted Languages (Python, JavaScript, Go, Ruby)
25
+ - **No build required** — CodeQL extracts source directly
26
+ - **Exclusion config supported** — Use `--codescanning-config` to skip irrelevant files
27
+
28
+ ### Compiled Languages (C/C++, Java, C#, Rust, Swift)
29
+ - **Build required** — CodeQL must trace the compilation
30
+ - **Exclusion config NOT supported** — All compiled code must be traced
31
+ - Try build methods in order until one succeeds:
32
+ 1. **Autobuild** — CodeQL auto-detects and runs the build
33
+ 2. **Custom Command** — Explicit build command for the detected build system
34
+ 2m. **macOS arm64 Toolchain** — Homebrew compiler + multi-step tracing (Apple Silicon workaround)
35
+ 3. **Multi-step** — Fine-grained control with init → trace-command → finalize
36
+ 4. **No-build fallback** — `--build-mode=none` (partial analysis, last resort)
37
+
38
+ > **macOS Apple Silicon:** On arm64 Macs, system tools (`/usr/bin/make`, `/usr/bin/clang`, `/usr/bin/ar`) are `arm64e` but CodeQL's `libtrace.dylib` only has `arm64`. macOS kills `arm64e` processes with a non-`arm64e` injected dylib (SIGKILL, exit 137). Step 2a detects this and routes to Method 2m.
39
+
40
+ ---
41
+
42
+ ## Output Directory
43
+
44
+ This workflow receives `$OUTPUT_DIR` from the parent skill (resolved once at invocation). All files go inside it.
45
+
46
+ ```bash
47
+ DB_NAME="$OUTPUT_DIR/codeql.db"
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Build Log
53
+
54
+ Maintain a log file throughout. Initialize at start:
55
+
56
+ ```bash
57
+ LOG_FILE="$OUTPUT_DIR/build.log"
58
+ echo "=== CodeQL Database Build Log ===" > "$LOG_FILE"
59
+ echo "Started: $(date -Iseconds)" >> "$LOG_FILE"
60
+ echo "Output dir: $OUTPUT_DIR" >> "$LOG_FILE"
61
+ echo "Database: $DB_NAME" >> "$LOG_FILE"
62
+ ```
63
+
64
+ Log helper:
65
+ ```bash
66
+ log_step() { echo "[$(date -Iseconds)] $1" >> "$LOG_FILE"; }
67
+ log_cmd() { echo "[$(date -Iseconds)] COMMAND: $1" >> "$LOG_FILE"; }
68
+ log_result() { echo "[$(date -Iseconds)] RESULT: $1" >> "$LOG_FILE"; echo "" >> "$LOG_FILE"; }
69
+ ```
70
+
71
+ **What to log:** Detected language/build system, each build attempt with exact command, fix attempts and outcomes, quality assessment results, final successful command.
72
+
73
+ ---
74
+
75
+ ## Step 1: Detect Language and Configure
76
+
77
+ **Entry:** CodeQL CLI installed and on PATH (`codeql --version` succeeds)
78
+ **Exit:** `CODEQL_LANG` variable set to a valid CodeQL language identifier; exclusion config created (interpreted) or skipped (compiled)
79
+
80
+ ### 1a. Detect Language
81
+
82
+ ```bash
83
+ fd -t f -e py -e js -e ts -e go -e rb -e java -e c -e cpp -e h -e hpp -e rs -e cs | \
84
+ sed 's/.*\.//' | sort | uniq -c | sort -rn | head -5
85
+ ls -la Makefile CMakeLists.txt build.gradle pom.xml Cargo.toml *.sln 2>/dev/null || true
86
+ ```
87
+
88
+ | Language | `--language=` | Type |
89
+ |----------|---------------|------|
90
+ | Python | `python` | Interpreted |
91
+ | JavaScript/TypeScript | `javascript` | Interpreted |
92
+ | Go | `go` | Interpreted |
93
+ | Ruby | `ruby` | Interpreted |
94
+ | Java/Kotlin | `java` | Compiled |
95
+ | C/C++ | `cpp` | Compiled |
96
+ | C# | `csharp` | Compiled |
97
+ | Rust | `rust` | Compiled |
98
+ | Swift | `swift` | Compiled (macOS) |
99
+
100
+ ### 1b. Create Exclusion Config (Interpreted Languages Only)
101
+
102
+ > **Skip for compiled languages** — exclusion config is not supported when build tracing is required.
103
+
104
+ Scan for irrelevant directories and create `$OUTPUT_DIR/codeql-config.yml` with `paths-ignore` entries for `node_modules`, `vendor`, `venv`, third-party code, and generated/minified files.
105
+
106
+ ---
107
+
108
+ ## Step 2: Build Database
109
+
110
+ **Entry:** Step 1 complete (`CODEQL_LANG` set, `DB_NAME` assigned, log file initialized)
111
+ **Exit:** `codeql resolve database -- "$DB_NAME"` succeeds (database exists and is valid)
112
+
113
+ ### For Interpreted Languages
114
+
115
+ ```bash
116
+ log_step "Building database for interpreted language: <LANG>"
117
+ CMD="codeql database create $DB_NAME --language=$CODEQL_LANG --source-root=. --codescanning-config=$OUTPUT_DIR/codeql-config.yml --overwrite"
118
+ log_cmd "$CMD"
119
+ $CMD 2>&1 | tee -a "$LOG_FILE"
120
+ ```
121
+
122
+ **Skip to Step 4 after success.**
123
+
124
+ ---
125
+
126
+ ### For Compiled Languages
127
+
128
+ #### Step 2a: macOS arm64e Detection (C/C++ primarily)
129
+
130
+ ```bash
131
+ IS_MACOS_ARM64E=false
132
+ if [[ "$(uname -s)" == "Darwin" ]] && [[ "$(uname -m)" == "arm64" ]]; then
133
+ LIBTRACE=$(find "$(dirname "$(command -v codeql)")" -name libtrace.dylib 2>/dev/null | head -1)
134
+ if [ -n "$LIBTRACE" ]; then
135
+ LIBTRACE_ARCHS=$(lipo -archs "$LIBTRACE" 2>/dev/null)
136
+ if [[ "$LIBTRACE_ARCHS" != *"arm64e"* ]]; then
137
+ MAKE_ARCHS=$(lipo -archs /usr/bin/make 2>/dev/null)
138
+ [[ "$MAKE_ARCHS" == *"arm64e"* ]] && IS_MACOS_ARM64E=true
139
+ fi
140
+ fi
141
+ fi
142
+ ```
143
+
144
+ **If `IS_MACOS_ARM64E=true`:** Skip Methods 1 and 2 — go directly to Method 2m.
145
+
146
+ ---
147
+
148
+ Try build methods in sequence until one succeeds:
149
+
150
+ #### Method 1: Autobuild
151
+
152
+ > **Skip if `IS_MACOS_ARM64E=true`.**
153
+
154
+ ```bash
155
+ log_step "METHOD 1: Autobuild"
156
+ CMD="codeql database create $DB_NAME --language=$CODEQL_LANG --source-root=. --overwrite"
157
+ log_cmd "$CMD"
158
+ $CMD 2>&1 | tee -a "$LOG_FILE"
159
+ ```
160
+
161
+ #### Method 2: Custom Command
162
+
163
+ > **Skip if `IS_MACOS_ARM64E=true`.**
164
+
165
+ Detect build system and use explicit command:
166
+
167
+ | Build System | Detection | Command |
168
+ |--------------|-----------|---------|
169
+ | Make | `Makefile` | `make clean && make -j$(nproc)` |
170
+ | CMake | `CMakeLists.txt` | `cmake -B build && cmake --build build` |
171
+ | Gradle | `build.gradle` | `./gradlew clean build -x test` |
172
+ | Maven | `pom.xml` | `mvn clean compile -DskipTests` |
173
+ | Cargo | `Cargo.toml` | `cargo clean && cargo build` |
174
+ | .NET | `*.sln` | `dotnet clean && dotnet build` |
175
+
176
+ Also check for project-specific build scripts (`build.sh`, `compile.sh`) and README instructions.
177
+
178
+ ```bash
179
+ log_step "METHOD 2: Custom command"
180
+ CMD="codeql database create $DB_NAME --language=$CODEQL_LANG --source-root=. --command='$BUILD_CMD' --overwrite"
181
+ log_cmd "$CMD"
182
+ $CMD 2>&1 | tee -a "$LOG_FILE"
183
+ ```
184
+
185
+ #### Method 2m: macOS arm64 Toolchain (Apple Silicon workaround)
186
+
187
+ > **Use when `IS_MACOS_ARM64E=true`.** Replaces Methods 1 and 2 on affected systems.
188
+
189
+ See [macos-arm64e-workaround.md](../references/macos-arm64e-workaround.md) for the full sub-method sequence (2m-a through 2m-d): Homebrew compiler with multi-step tracing → Rosetta x86_64 → system compiler verification → ask user.
190
+
191
+ #### Method 3: Multi-step Build
192
+
193
+ For complex builds needing fine-grained control:
194
+
195
+ > **On macOS with `IS_MACOS_ARM64E=true`:** Only trace arm64 Homebrew binaries. Do NOT trace system tools.
196
+
197
+ ```bash
198
+ log_step "METHOD 3: Multi-step build"
199
+ codeql database init $DB_NAME --language=$CODEQL_LANG --source-root=. --overwrite
200
+ codeql database trace-command $DB_NAME -- <build step 1>
201
+ codeql database trace-command $DB_NAME -- <build step 2>
202
+ codeql database finalize $DB_NAME
203
+ ```
204
+
205
+ #### Method 4: No-Build Fallback (Last Resort)
206
+
207
+ > **WARNING:** Creates a database without build tracing. Only source-level patterns detected.
208
+
209
+ ```bash
210
+ log_step "METHOD 4: No-build fallback (partial analysis)"
211
+ CMD="codeql database create $DB_NAME --language=$CODEQL_LANG --source-root=. --build-mode=none --overwrite"
212
+ log_cmd "$CMD"
213
+ $CMD 2>&1 | tee -a "$LOG_FILE"
214
+ ```
215
+
216
+ ---
217
+
218
+ ## Step 3: Apply Fixes (if build failed)
219
+
220
+ **Entry:** Step 2 build method failed (non-zero exit or `codeql resolve database` fails)
221
+ **Exit:** Fix applied and current build method retried; either succeeds (go to Step 4) or all fixes exhausted (try next build method in Step 2)
222
+
223
+ Try fixes in order, then retry current build method. See [build-fixes.md](../references/build-fixes.md) for the full fix catalog: clean state, clean build cache, install dependencies, handle private registries.
224
+
225
+ ---
226
+
227
+ ## Steps 4-5: Assess and Improve Quality
228
+
229
+ **Entry:** Database exists and `codeql resolve database` succeeds
230
+ **Exit (Step 4):** Quality metrics collected (baseline LoC, file counts, extractor errors, finalization status)
231
+ **Exit (Step 5):** Quality is GOOD (baseline LoC > 0, errors < 5%, project files present) OR user accepts current state
232
+
233
+ Run quality checks and compare against expected source files. See [quality-assessment.md](../references/quality-assessment.md) for metric collection, quality criteria table, and improvement steps.
234
+
235
+ ---
236
+
237
+ ## Exit Conditions
238
+
239
+ **Success:** Quality assessment shows GOOD or user accepts current state.
240
+
241
+ **Failure (all methods exhausted):**
242
+ ```
243
+ AskUserQuestion: "All build methods failed. Options:"
244
+ 1. "Accept current state" (if any database exists)
245
+ 2. "I'll fix the build manually and retry"
246
+ 3. "Abort"
247
+ ```
248
+
249
+ ---
250
+
251
+ ## Final Report
252
+
253
+ ```bash
254
+ echo "=== Build Complete ===" >> "$LOG_FILE"
255
+ echo "Finished: $(date -Iseconds)" >> "$LOG_FILE"
256
+ echo "Final database: $DB_NAME" >> "$LOG_FILE"
257
+ echo "Successful method: <METHOD>" >> "$LOG_FILE"
258
+ codeql resolve database -- "$DB_NAME" >> "$LOG_FILE" 2>&1
259
+ ```
260
+
261
+ Report to user:
262
+ ```
263
+ ## Database Build Complete
264
+
265
+ **Output directory:** $OUTPUT_DIR
266
+ **Database:** $DB_NAME
267
+ **Language:** <LANG>
268
+ **Build method:** autobuild | custom | multi-step
269
+ **Files extracted:** <COUNT>
270
+
271
+ ### Quality:
272
+ - Errors: <N>
273
+ - Coverage: <good/partial/poor>
274
+
275
+ ### Build Log:
276
+ See `$OUTPUT_DIR/build.log` for complete details.
277
+
278
+ **Final command used:** <EXACT_COMMAND>
279
+ **Ready for analysis.**
280
+ ```