@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.
- package/LICENSE +21 -0
- package/README.md +117 -0
- package/agents/access-auditor.md +300 -0
- package/agents/assumption-breaker.md +154 -0
- package/agents/attack-designer.md +116 -0
- package/agents/code-scanner.md +139 -0
- package/agents/concurrency-auditor.md +238 -0
- package/agents/confirm-writer.md +257 -0
- package/agents/context-reviewer.md +274 -0
- package/agents/cross-verifier.md +165 -0
- package/agents/cve-scout.md +381 -0
- package/agents/env-builder.md +282 -0
- package/agents/env-profiler.md +205 -0
- package/agents/evidence-collector.md +140 -0
- package/agents/finding-grader.md +142 -0
- package/agents/finding-writer.md +148 -0
- package/agents/flow-tracer.md +106 -0
- package/agents/goal-backtracer.md +146 -0
- package/agents/history-miner.md +467 -0
- package/agents/independent-verifier.md +118 -0
- package/agents/intent-mapper.md +183 -0
- package/agents/longshot-collector.md +128 -0
- package/agents/longshot-prober.md +126 -0
- package/agents/patch-auditor.md +73 -0
- package/agents/poc-author.md +124 -0
- package/agents/poc-runner.md +194 -0
- package/agents/probe-lead.md +269 -0
- package/agents/red-challenger.md +101 -0
- package/agents/report-composer.md +208 -0
- package/agents/review-adjudicator.md +216 -0
- package/agents/spec-auditor.md +155 -0
- package/agents/taint-tracer.md +265 -0
- package/agents/test-locator.md +209 -0
- package/agents/threat-modeler.md +132 -0
- package/agents/variant-scanner.md +108 -0
- package/agents/variant-spotter.md +110 -0
- package/bin/piolium.mjs +376 -0
- package/extensions/piolium/_vendor/yaml.bundle.d.mts +6 -0
- package/extensions/piolium/_vendor/yaml.bundle.mjs +139 -0
- package/extensions/piolium/agent-runner.ts +322 -0
- package/extensions/piolium/agents.ts +266 -0
- package/extensions/piolium/audit-state.ts +522 -0
- package/extensions/piolium/bundled-resources.ts +97 -0
- package/extensions/piolium/candidate-scan.ts +966 -0
- package/extensions/piolium/command-target.ts +177 -0
- package/extensions/piolium/console-stream.ts +57 -0
- package/extensions/piolium/export-results.ts +380 -0
- package/extensions/piolium/findings.ts +448 -0
- package/extensions/piolium/heartbeat.ts +182 -0
- package/extensions/piolium/help.ts +234 -0
- package/extensions/piolium/index.ts +1865 -0
- package/extensions/piolium/longshot.ts +530 -0
- package/extensions/piolium/matcher-suggestions.ts +196 -0
- package/extensions/piolium/matcher-utils.ts +83 -0
- package/extensions/piolium/modes/balanced.ts +750 -0
- package/extensions/piolium/modes/confirm-bootstrap.ts +186 -0
- package/extensions/piolium/modes/confirm.ts +697 -0
- package/extensions/piolium/modes/deep.ts +917 -0
- package/extensions/piolium/modes/diff.ts +177 -0
- package/extensions/piolium/modes/lite.ts +540 -0
- package/extensions/piolium/modes/longshot.ts +595 -0
- package/extensions/piolium/modes/merge.ts +204 -0
- package/extensions/piolium/modes/phase-runner.ts +267 -0
- package/extensions/piolium/modes/reinvest.ts +546 -0
- package/extensions/piolium/modes/revisit.ts +279 -0
- package/extensions/piolium/modes.ts +48 -0
- package/extensions/piolium/phase-labels.ts +123 -0
- package/extensions/piolium/phase-status-strip.ts +92 -0
- package/extensions/piolium/prompt-prefix-editor.ts +39 -0
- package/extensions/piolium/providers/anthropic-vertex.ts +836 -0
- package/extensions/piolium/recon.ts +409 -0
- package/extensions/piolium/result-stats.ts +105 -0
- package/extensions/piolium/retry.ts +120 -0
- package/extensions/piolium/scheduler.ts +212 -0
- package/extensions/piolium/secrets.ts +368 -0
- package/extensions/piolium/tools/web-tools.ts +148 -0
- package/package.json +77 -0
- package/skills/agentic-actions-auditor/SKILL.md +327 -0
- package/skills/agentic-actions-auditor/references/action-profiles.md +186 -0
- package/skills/agentic-actions-auditor/references/cross-file-resolution.md +209 -0
- package/skills/agentic-actions-auditor/references/foundations.md +94 -0
- package/skills/agentic-actions-auditor/references/vector-a-env-var-intermediary.md +77 -0
- package/skills/agentic-actions-auditor/references/vector-b-direct-expression-injection.md +83 -0
- package/skills/agentic-actions-auditor/references/vector-c-cli-data-fetch.md +83 -0
- package/skills/agentic-actions-auditor/references/vector-d-pr-target-checkout.md +88 -0
- package/skills/agentic-actions-auditor/references/vector-e-error-log-injection.md +88 -0
- package/skills/agentic-actions-auditor/references/vector-f-subshell-expansion.md +82 -0
- package/skills/agentic-actions-auditor/references/vector-g-eval-of-ai-output.md +91 -0
- package/skills/agentic-actions-auditor/references/vector-h-dangerous-sandbox-configs.md +102 -0
- package/skills/agentic-actions-auditor/references/vector-i-wildcard-allowlists.md +88 -0
- package/skills/audit/SKILL.md +562 -0
- package/skills/audit/assets/icon.svg +7 -0
- package/skills/audit/hooks/scripts/validate_phase_output.py +550 -0
- package/skills/audit/references/adversarial-review.md +148 -0
- package/skills/audit/references/architecture-aware-sast.md +306 -0
- package/skills/audit/references/audit-workflow.md +737 -0
- package/skills/audit/references/chamber-protocol.md +384 -0
- package/skills/audit/references/creative-attack-modes.md +221 -0
- package/skills/audit/references/deep-analysis.md +273 -0
- package/skills/audit/references/domain-attack-playbooks.md +1129 -0
- package/skills/audit/references/knowledge-base-template.md +513 -0
- package/skills/audit/references/real-env-validation.md +191 -0
- package/skills/audit/references/report-templates.md +417 -0
- package/skills/audit/references/triage-and-prereqs.md +134 -0
- package/skills/audit/scripts/consolidate_drafts.py +554 -0
- package/skills/audit/scripts/partition_findings.py +152 -0
- package/skills/audit/scripts/rg-hotspots.sh +121 -0
- package/skills/audit/scripts/stamp_file_state.py +349 -0
- package/skills/code-reviewer/SKILL.md +65 -0
- package/skills/codeql/SKILL.md +281 -0
- package/skills/codeql/references/build-fixes.md +90 -0
- package/skills/codeql/references/diagnostic-query-templates.md +339 -0
- package/skills/codeql/references/extension-yaml-format.md +209 -0
- package/skills/codeql/references/important-only-suite.md +153 -0
- package/skills/codeql/references/language-details.md +207 -0
- package/skills/codeql/references/macos-arm64e-workaround.md +179 -0
- package/skills/codeql/references/performance-tuning.md +111 -0
- package/skills/codeql/references/quality-assessment.md +172 -0
- package/skills/codeql/references/ruleset-catalog.md +63 -0
- package/skills/codeql/references/run-all-suite.md +92 -0
- package/skills/codeql/references/sarif-processing.md +79 -0
- package/skills/codeql/references/threat-models.md +51 -0
- package/skills/codeql/workflows/build-database.md +280 -0
- package/skills/codeql/workflows/create-data-extensions.md +261 -0
- package/skills/codeql/workflows/run-analysis.md +301 -0
- package/skills/differential-review/SKILL.md +220 -0
- package/skills/differential-review/adversarial.md +203 -0
- package/skills/differential-review/methodology.md +234 -0
- package/skills/differential-review/patterns.md +300 -0
- package/skills/differential-review/reporting.md +369 -0
- package/skills/fp-check/SKILL.md +125 -0
- package/skills/fp-check/references/bug-class-verification.md +114 -0
- package/skills/fp-check/references/deep-verification.md +143 -0
- package/skills/fp-check/references/evidence-templates.md +91 -0
- package/skills/fp-check/references/false-positive-patterns.md +115 -0
- package/skills/fp-check/references/gate-reviews.md +27 -0
- package/skills/fp-check/references/standard-verification.md +78 -0
- package/skills/insecure-defaults/SKILL.md +117 -0
- package/skills/insecure-defaults/references/examples.md +409 -0
- package/skills/last30days/SKILL.md +444 -0
- package/skills/sarif-parsing/SKILL.md +483 -0
- package/skills/sarif-parsing/resources/jq-queries.md +162 -0
- package/skills/sarif-parsing/resources/sarif_helpers.py +331 -0
- package/skills/security-threat-model/LICENSE.txt +201 -0
- package/skills/security-threat-model/SKILL.md +81 -0
- package/skills/security-threat-model/agents/openai.yaml +4 -0
- package/skills/security-threat-model/references/prompt-template.md +255 -0
- package/skills/security-threat-model/references/security-controls-and-assets.md +32 -0
- package/skills/semgrep/SKILL.md +212 -0
- package/skills/semgrep/references/rulesets.md +162 -0
- package/skills/semgrep/references/scan-modes.md +110 -0
- package/skills/semgrep/references/scanner-task-prompt.md +140 -0
- package/skills/semgrep/scripts/merge_sarif.py +203 -0
- package/skills/semgrep/workflows/scan-workflow.md +311 -0
- package/skills/semgrep-rule-creator/SKILL.md +168 -0
- package/skills/semgrep-rule-creator/references/quick-reference.md +202 -0
- package/skills/semgrep-rule-creator/references/workflow.md +240 -0
- package/skills/semgrep-rule-variant-creator/SKILL.md +205 -0
- package/skills/semgrep-rule-variant-creator/references/applicability-analysis.md +250 -0
- package/skills/semgrep-rule-variant-creator/references/language-syntax-guide.md +324 -0
- package/skills/semgrep-rule-variant-creator/references/workflow.md +518 -0
- package/skills/sharp-edges/SKILL.md +292 -0
- package/skills/sharp-edges/references/auth-patterns.md +252 -0
- package/skills/sharp-edges/references/case-studies.md +274 -0
- package/skills/sharp-edges/references/config-patterns.md +333 -0
- package/skills/sharp-edges/references/crypto-apis.md +190 -0
- package/skills/sharp-edges/references/lang-c.md +205 -0
- package/skills/sharp-edges/references/lang-csharp.md +285 -0
- package/skills/sharp-edges/references/lang-go.md +270 -0
- package/skills/sharp-edges/references/lang-java.md +263 -0
- package/skills/sharp-edges/references/lang-javascript.md +269 -0
- package/skills/sharp-edges/references/lang-kotlin.md +265 -0
- package/skills/sharp-edges/references/lang-php.md +245 -0
- package/skills/sharp-edges/references/lang-python.md +274 -0
- package/skills/sharp-edges/references/lang-ruby.md +273 -0
- package/skills/sharp-edges/references/lang-rust.md +272 -0
- package/skills/sharp-edges/references/lang-swift.md +287 -0
- package/skills/sharp-edges/references/language-specific.md +588 -0
- package/skills/spec-to-code-compliance/SKILL.md +357 -0
- package/skills/spec-to-code-compliance/resources/COMPLETENESS_CHECKLIST.md +69 -0
- package/skills/spec-to-code-compliance/resources/IR_EXAMPLES.md +417 -0
- package/skills/spec-to-code-compliance/resources/OUTPUT_REQUIREMENTS.md +105 -0
- package/skills/supply-chain-risk-auditor/SKILL.md +67 -0
- package/skills/supply-chain-risk-auditor/resources/results-template.md +41 -0
- package/skills/variant-analysis/METHODOLOGY.md +327 -0
- package/skills/variant-analysis/SKILL.md +142 -0
- package/skills/variant-analysis/resources/codeql/cpp.ql +119 -0
- package/skills/variant-analysis/resources/codeql/go.ql +69 -0
- package/skills/variant-analysis/resources/codeql/java.ql +71 -0
- package/skills/variant-analysis/resources/codeql/javascript.ql +63 -0
- package/skills/variant-analysis/resources/codeql/python.ql +80 -0
- package/skills/variant-analysis/resources/semgrep/cpp.yaml +98 -0
- package/skills/variant-analysis/resources/semgrep/go.yaml +63 -0
- package/skills/variant-analysis/resources/semgrep/java.yaml +61 -0
- package/skills/variant-analysis/resources/semgrep/javascript.yaml +60 -0
- package/skills/variant-analysis/resources/semgrep/python.yaml +72 -0
- package/skills/variant-analysis/resources/variant-report-template.md +75 -0
- package/skills/vuln-report/SKILL.md +137 -0
- package/skills/vuln-report/agents/openai.yaml +4 -0
- package/skills/vuln-report/references/report-template.md +135 -0
- package/skills/wooyun-legacy/SKILL.md +367 -0
- package/skills/wooyun-legacy/references/bank-penetration.md +222 -0
- package/skills/wooyun-legacy/references/checklists/command-execution-checklist.md +119 -0
- package/skills/wooyun-legacy/references/checklists/csrf-checklist.md +74 -0
- package/skills/wooyun-legacy/references/checklists/file-upload-checklist.md +108 -0
- package/skills/wooyun-legacy/references/checklists/info-disclosure-checklist.md +114 -0
- package/skills/wooyun-legacy/references/checklists/logic-flaws-checklist.md +95 -0
- package/skills/wooyun-legacy/references/checklists/misconfig-checklist.md +124 -0
- package/skills/wooyun-legacy/references/checklists/path-traversal-checklist.md +87 -0
- package/skills/wooyun-legacy/references/checklists/rce-checklist.md +93 -0
- package/skills/wooyun-legacy/references/checklists/sql-injection-checklist.md +97 -0
- package/skills/wooyun-legacy/references/checklists/ssrf-checklist.md +99 -0
- package/skills/wooyun-legacy/references/checklists/unauthorized-access-checklist.md +89 -0
- package/skills/wooyun-legacy/references/checklists/weak-password-checklist.md +115 -0
- package/skills/wooyun-legacy/references/checklists/xss-checklist.md +103 -0
- package/skills/wooyun-legacy/references/checklists/xxe-checklist.md +130 -0
- package/skills/wooyun-legacy/references/info-disclosure.md +975 -0
- package/skills/wooyun-legacy/references/logic-flaws.md +721 -0
- package/skills/wooyun-legacy/references/path-traversal.md +1191 -0
- package/skills/wooyun-legacy/references/telecom-penetration.md +156 -0
- package/skills/wooyun-legacy/references/unauthorized-access.md +980 -0
- package/skills/wooyun-legacy/references/xss.md +746 -0
- package/skills/zeroize-audit/SKILL.md +371 -0
- package/skills/zeroize-audit/configs/c.yaml +21 -0
- package/skills/zeroize-audit/configs/default.yaml +128 -0
- package/skills/zeroize-audit/configs/rust.yaml +83 -0
- package/skills/zeroize-audit/prompts/report_template.md +238 -0
- package/skills/zeroize-audit/prompts/system.md +163 -0
- package/skills/zeroize-audit/prompts/task.md +97 -0
- package/skills/zeroize-audit/references/compile-commands.md +231 -0
- package/skills/zeroize-audit/references/detection-strategy.md +191 -0
- package/skills/zeroize-audit/references/ir-analysis.md +252 -0
- package/skills/zeroize-audit/references/mcp-analysis.md +221 -0
- package/skills/zeroize-audit/references/poc-generation.md +470 -0
- package/skills/zeroize-audit/references/rust-zeroization-patterns.md +867 -0
- package/skills/zeroize-audit/schemas/input.json +83 -0
- package/skills/zeroize-audit/schemas/output.json +140 -0
- package/skills/zeroize-audit/tools/analyze_asm.sh +202 -0
- package/skills/zeroize-audit/tools/analyze_cfg.py +381 -0
- package/skills/zeroize-audit/tools/analyze_heap.sh +211 -0
- package/skills/zeroize-audit/tools/analyze_ir_semantic.py +429 -0
- package/skills/zeroize-audit/tools/diff_ir.sh +135 -0
- package/skills/zeroize-audit/tools/diff_rust_mir.sh +189 -0
- package/skills/zeroize-audit/tools/emit_asm.sh +67 -0
- package/skills/zeroize-audit/tools/emit_ir.sh +77 -0
- package/skills/zeroize-audit/tools/emit_rust_asm.sh +178 -0
- package/skills/zeroize-audit/tools/emit_rust_ir.sh +150 -0
- package/skills/zeroize-audit/tools/emit_rust_mir.sh +158 -0
- package/skills/zeroize-audit/tools/extract_compile_flags.py +284 -0
- package/skills/zeroize-audit/tools/generate_poc.py +1329 -0
- package/skills/zeroize-audit/tools/mcp/apply_confidence_gates.py +113 -0
- package/skills/zeroize-audit/tools/mcp/check_mcp.sh +68 -0
- package/skills/zeroize-audit/tools/mcp/normalize_mcp_evidence.py +125 -0
- package/skills/zeroize-audit/tools/scripts/check_llvm_patterns.py +481 -0
- package/skills/zeroize-audit/tools/scripts/check_mir_patterns.py +554 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm.py +424 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm_aarch64.py +300 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm_x86.py +283 -0
- package/skills/zeroize-audit/tools/scripts/find_dangerous_apis.py +375 -0
- package/skills/zeroize-audit/tools/scripts/semantic_audit.py +923 -0
- package/skills/zeroize-audit/tools/track_dataflow.sh +196 -0
- package/skills/zeroize-audit/tools/validate_rust_toolchain.sh +298 -0
- package/skills/zeroize-audit/workflows/phase-0-preflight.md +150 -0
- package/skills/zeroize-audit/workflows/phase-1-source-analysis.md +144 -0
- package/skills/zeroize-audit/workflows/phase-2-compiler-analysis.md +139 -0
- package/skills/zeroize-audit/workflows/phase-3-interim-report.md +46 -0
- package/skills/zeroize-audit/workflows/phase-4-poc-generation.md +46 -0
- package/skills/zeroize-audit/workflows/phase-5-poc-validation.md +136 -0
- package/skills/zeroize-audit/workflows/phase-6-final-report.md +44 -0
- package/skills/zeroize-audit/workflows/phase-7-test-generation.md +42 -0
- package/themes/piolium-srcery.json +94 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Diagnostic Query Templates
|
|
2
|
+
|
|
3
|
+
Language-specific QL queries for enumerating sources and sinks recognized by CodeQL. Used during the data extensions creation process.
|
|
4
|
+
|
|
5
|
+
## Source Enumeration Query
|
|
6
|
+
|
|
7
|
+
All languages use the class `RemoteFlowSource`. The import differs per language.
|
|
8
|
+
|
|
9
|
+
### Import Reference
|
|
10
|
+
|
|
11
|
+
| Language | Imports | Class |
|
|
12
|
+
|----------|---------|-------|
|
|
13
|
+
| Python | `import python` + `import semmle.python.dataflow.new.RemoteFlowSources` | `RemoteFlowSource` |
|
|
14
|
+
| JavaScript | `import javascript` | `RemoteFlowSource` |
|
|
15
|
+
| Java | `import java` + `import semmle.code.java.dataflow.FlowSources` | `RemoteFlowSource` |
|
|
16
|
+
| Go | `import go` | `RemoteFlowSource` |
|
|
17
|
+
| C/C++ | `import cpp` + `import semmle.code.cpp.security.FlowSources` | `RemoteFlowSource` |
|
|
18
|
+
| C# | `import csharp` + `import semmle.code.csharp.security.dataflow.flowsources.Remote` | `RemoteFlowSource` |
|
|
19
|
+
| Ruby | `import ruby` + `import codeql.ruby.dataflow.RemoteFlowSources` | `RemoteFlowSource` |
|
|
20
|
+
|
|
21
|
+
### Template (Python — swap imports per table above)
|
|
22
|
+
|
|
23
|
+
```ql
|
|
24
|
+
/**
|
|
25
|
+
* @name List recognized dataflow sources
|
|
26
|
+
* @description Enumerates all locations CodeQL recognizes as dataflow sources
|
|
27
|
+
* @kind problem
|
|
28
|
+
* @id custom/list-sources
|
|
29
|
+
*/
|
|
30
|
+
import python
|
|
31
|
+
import semmle.python.dataflow.new.RemoteFlowSources
|
|
32
|
+
|
|
33
|
+
from RemoteFlowSource src
|
|
34
|
+
select src,
|
|
35
|
+
src.getSourceType()
|
|
36
|
+
+ " | " + src.getLocation().getFile().getRelativePath()
|
|
37
|
+
+ ":" + src.getLocation().getStartLine().toString()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Note:** `getSourceType()` is available on Python, Java, and C#. For Go, JavaScript, Ruby, and C++ replace the select with:
|
|
41
|
+
```ql
|
|
42
|
+
select src,
|
|
43
|
+
src.getLocation().getFile().getRelativePath()
|
|
44
|
+
+ ":" + src.getLocation().getStartLine().toString()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Sink Enumeration Queries
|
|
50
|
+
|
|
51
|
+
The Concepts API differs significantly across languages. Use the correct template.
|
|
52
|
+
|
|
53
|
+
### Concept Class Reference
|
|
54
|
+
|
|
55
|
+
| Concept | Python | JavaScript | Go | Ruby |
|
|
56
|
+
|---------|--------|------------|-----|------|
|
|
57
|
+
| SQL | `SqlExecution.getSql()` | `DatabaseAccess.getAQueryArgument()` | `SQL::QueryString` (is-a Node) | `SqlExecution.getSql()` |
|
|
58
|
+
| Command exec | `SystemCommandExecution.getCommand()` | `SystemCommandExecution.getACommandArgument()` | `SystemCommandExecution.getCommandName()` | `SystemCommandExecution.getAnArgument()` |
|
|
59
|
+
| File access | `FileSystemAccess.getAPathArgument()` | `FileSystemAccess.getAPathArgument()` | `FileSystemAccess.getAPathArgument()` | `FileSystemAccess.getAPathArgument()` |
|
|
60
|
+
| HTTP client | `Http::Client::Request.getAUrlPart()` | — | — | — |
|
|
61
|
+
| Decoding | `Decoding.getAnInput()` | — | — | — |
|
|
62
|
+
| XML parsing | — | — | — | `XmlParserCall.getAnInput()` |
|
|
63
|
+
|
|
64
|
+
### Python
|
|
65
|
+
|
|
66
|
+
```ql
|
|
67
|
+
/**
|
|
68
|
+
* @name List recognized dataflow sinks
|
|
69
|
+
* @description Enumerates security-relevant sinks CodeQL recognizes
|
|
70
|
+
* @kind problem
|
|
71
|
+
* @id custom/list-sinks
|
|
72
|
+
*/
|
|
73
|
+
import python
|
|
74
|
+
import semmle.python.Concepts
|
|
75
|
+
|
|
76
|
+
from DataFlow::Node sink, string kind
|
|
77
|
+
where
|
|
78
|
+
exists(SqlExecution e | sink = e.getSql() and kind = "sql-execution")
|
|
79
|
+
or
|
|
80
|
+
exists(SystemCommandExecution e |
|
|
81
|
+
sink = e.getCommand() and kind = "command-execution"
|
|
82
|
+
)
|
|
83
|
+
or
|
|
84
|
+
exists(FileSystemAccess e |
|
|
85
|
+
sink = e.getAPathArgument() and kind = "file-access"
|
|
86
|
+
)
|
|
87
|
+
or
|
|
88
|
+
exists(Http::Client::Request r |
|
|
89
|
+
sink = r.getAUrlPart() and kind = "http-request"
|
|
90
|
+
)
|
|
91
|
+
or
|
|
92
|
+
exists(Decoding d | sink = d.getAnInput() and kind = "decoding")
|
|
93
|
+
or
|
|
94
|
+
exists(CodeExecution e | sink = e.getCode() and kind = "code-execution")
|
|
95
|
+
select sink,
|
|
96
|
+
kind
|
|
97
|
+
+ " | " + sink.getLocation().getFile().getRelativePath()
|
|
98
|
+
+ ":" + sink.getLocation().getStartLine().toString()
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### JavaScript / TypeScript
|
|
102
|
+
|
|
103
|
+
```ql
|
|
104
|
+
/**
|
|
105
|
+
* @name List recognized dataflow sinks
|
|
106
|
+
* @description Enumerates security-relevant sinks CodeQL recognizes
|
|
107
|
+
* @kind problem
|
|
108
|
+
* @id custom/list-sinks-js
|
|
109
|
+
*/
|
|
110
|
+
import javascript
|
|
111
|
+
|
|
112
|
+
from DataFlow::Node sink, string kind
|
|
113
|
+
where
|
|
114
|
+
exists(DatabaseAccess e |
|
|
115
|
+
sink = e.getAQueryArgument() and kind = "database-access"
|
|
116
|
+
)
|
|
117
|
+
or
|
|
118
|
+
exists(SystemCommandExecution e |
|
|
119
|
+
sink = e.getACommandArgument() and kind = "command-execution"
|
|
120
|
+
)
|
|
121
|
+
or
|
|
122
|
+
exists(FileSystemAccess e |
|
|
123
|
+
sink = e.getAPathArgument() and kind = "file-access"
|
|
124
|
+
)
|
|
125
|
+
select sink,
|
|
126
|
+
kind
|
|
127
|
+
+ " | " + sink.getLocation().getFile().getRelativePath()
|
|
128
|
+
+ ":" + sink.getLocation().getStartLine().toString()
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Go
|
|
132
|
+
|
|
133
|
+
```ql
|
|
134
|
+
/**
|
|
135
|
+
* @name List recognized dataflow sinks
|
|
136
|
+
* @description Enumerates security-relevant sinks CodeQL recognizes
|
|
137
|
+
* @kind problem
|
|
138
|
+
* @id custom/list-sinks-go
|
|
139
|
+
*/
|
|
140
|
+
import go
|
|
141
|
+
import semmle.go.frameworks.SQL
|
|
142
|
+
|
|
143
|
+
from DataFlow::Node sink, string kind
|
|
144
|
+
where
|
|
145
|
+
sink instanceof SQL::QueryString and kind = "sql-query"
|
|
146
|
+
or
|
|
147
|
+
exists(SystemCommandExecution e |
|
|
148
|
+
sink = e.getCommandName() and kind = "command-execution"
|
|
149
|
+
)
|
|
150
|
+
or
|
|
151
|
+
exists(FileSystemAccess e |
|
|
152
|
+
sink = e.getAPathArgument() and kind = "file-access"
|
|
153
|
+
)
|
|
154
|
+
select sink,
|
|
155
|
+
kind
|
|
156
|
+
+ " | " + sink.getLocation().getFile().getRelativePath()
|
|
157
|
+
+ ":" + sink.getLocation().getStartLine().toString()
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Ruby
|
|
161
|
+
|
|
162
|
+
```ql
|
|
163
|
+
/**
|
|
164
|
+
* @name List recognized dataflow sinks
|
|
165
|
+
* @description Enumerates security-relevant sinks CodeQL recognizes
|
|
166
|
+
* @kind problem
|
|
167
|
+
* @id custom/list-sinks-ruby
|
|
168
|
+
*/
|
|
169
|
+
import ruby
|
|
170
|
+
import codeql.ruby.Concepts
|
|
171
|
+
|
|
172
|
+
from DataFlow::Node sink, string kind
|
|
173
|
+
where
|
|
174
|
+
exists(SqlExecution e | sink = e.getSql() and kind = "sql-execution")
|
|
175
|
+
or
|
|
176
|
+
exists(SystemCommandExecution e |
|
|
177
|
+
sink = e.getAnArgument() and kind = "command-execution"
|
|
178
|
+
)
|
|
179
|
+
or
|
|
180
|
+
exists(FileSystemAccess e |
|
|
181
|
+
sink = e.getAPathArgument() and kind = "file-access"
|
|
182
|
+
)
|
|
183
|
+
or
|
|
184
|
+
exists(CodeExecution e | sink = e.getCode() and kind = "code-execution")
|
|
185
|
+
select sink,
|
|
186
|
+
kind
|
|
187
|
+
+ " | " + sink.getLocation().getFile().getRelativePath()
|
|
188
|
+
+ ":" + sink.getLocation().getStartLine().toString()
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Java
|
|
192
|
+
|
|
193
|
+
Java lacks a unified Concepts module. Use language-specific sink classes. The diagnostics query needs its own `qlpack.yml` with a `codeql/java-all` dependency — create it alongside the `.ql` files:
|
|
194
|
+
|
|
195
|
+
```yaml
|
|
196
|
+
# $DIAG_DIR/qlpack.yml
|
|
197
|
+
name: custom/diagnostics
|
|
198
|
+
version: 0.0.1
|
|
199
|
+
dependencies:
|
|
200
|
+
codeql/java-all: "*"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Then run `codeql pack install` in the diagnostics directory before executing queries.
|
|
204
|
+
|
|
205
|
+
```ql
|
|
206
|
+
/**
|
|
207
|
+
* @name List recognized dataflow sinks
|
|
208
|
+
* @description Enumerates security-relevant sinks CodeQL recognizes
|
|
209
|
+
* @kind problem
|
|
210
|
+
* @id custom/list-sinks
|
|
211
|
+
*/
|
|
212
|
+
import java
|
|
213
|
+
import semmle.code.java.dataflow.DataFlow
|
|
214
|
+
import semmle.code.java.security.QueryInjection
|
|
215
|
+
import semmle.code.java.security.CommandLineQuery
|
|
216
|
+
import semmle.code.java.security.TaintedPathQuery
|
|
217
|
+
import semmle.code.java.security.XSS
|
|
218
|
+
import semmle.code.java.security.RequestForgery
|
|
219
|
+
import semmle.code.java.security.Xxe
|
|
220
|
+
|
|
221
|
+
from DataFlow::Node sink, string kind
|
|
222
|
+
where
|
|
223
|
+
sink instanceof QueryInjectionSink and kind = "sql-injection"
|
|
224
|
+
or
|
|
225
|
+
sink instanceof CommandInjectionSink and kind = "command-injection"
|
|
226
|
+
or
|
|
227
|
+
sink instanceof TaintedPathSink and kind = "path-injection"
|
|
228
|
+
or
|
|
229
|
+
sink instanceof XssSink and kind = "xss"
|
|
230
|
+
or
|
|
231
|
+
sink instanceof RequestForgerySink and kind = "ssrf"
|
|
232
|
+
or
|
|
233
|
+
sink instanceof XxeSink and kind = "xxe"
|
|
234
|
+
select sink,
|
|
235
|
+
kind
|
|
236
|
+
+ " | " + sink.getLocation().getFile().getRelativePath()
|
|
237
|
+
+ ":" + sink.getLocation().getStartLine().toString()
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### C / C++
|
|
241
|
+
|
|
242
|
+
C++ uses a similar per-vulnerability-class pattern. Requires a `qlpack.yml` with `codeql/cpp-all` dependency (same approach as Java):
|
|
243
|
+
|
|
244
|
+
```yaml
|
|
245
|
+
# $DIAG_DIR/qlpack.yml
|
|
246
|
+
name: custom/diagnostics
|
|
247
|
+
version: 0.0.1
|
|
248
|
+
dependencies:
|
|
249
|
+
codeql/cpp-all: "*"
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Then run `codeql pack install` in the diagnostics directory before executing queries.
|
|
253
|
+
|
|
254
|
+
```ql
|
|
255
|
+
/**
|
|
256
|
+
* @name List recognized dataflow sinks
|
|
257
|
+
* @description Enumerates security-relevant sinks CodeQL recognizes
|
|
258
|
+
* @kind problem
|
|
259
|
+
* @id custom/list-sinks-cpp
|
|
260
|
+
*/
|
|
261
|
+
import cpp
|
|
262
|
+
import semmle.code.cpp.dataflow.DataFlow
|
|
263
|
+
import semmle.code.cpp.security.CommandExecution
|
|
264
|
+
import semmle.code.cpp.security.FileAccess
|
|
265
|
+
import semmle.code.cpp.security.BufferWrite
|
|
266
|
+
|
|
267
|
+
from DataFlow::Node sink, string kind
|
|
268
|
+
where
|
|
269
|
+
exists(FunctionCall call |
|
|
270
|
+
sink.asExpr() = call.getAnArgument() and
|
|
271
|
+
call.getTarget().hasGlobalOrStdName("system") and
|
|
272
|
+
kind = "command-injection"
|
|
273
|
+
)
|
|
274
|
+
or
|
|
275
|
+
exists(FunctionCall call |
|
|
276
|
+
sink.asExpr() = call.getAnArgument() and
|
|
277
|
+
call.getTarget().hasGlobalOrStdName(["fopen", "open", "freopen"]) and
|
|
278
|
+
kind = "file-access"
|
|
279
|
+
)
|
|
280
|
+
or
|
|
281
|
+
exists(FunctionCall call |
|
|
282
|
+
sink.asExpr() = call.getAnArgument() and
|
|
283
|
+
call.getTarget().hasGlobalOrStdName(["sprintf", "strcpy", "strcat", "gets"]) and
|
|
284
|
+
kind = "buffer-write"
|
|
285
|
+
)
|
|
286
|
+
or
|
|
287
|
+
exists(FunctionCall call |
|
|
288
|
+
sink.asExpr() = call.getAnArgument() and
|
|
289
|
+
call.getTarget().hasGlobalOrStdName(["execl", "execle", "execlp", "execv", "execvp", "execvpe", "popen"]) and
|
|
290
|
+
kind = "command-execution"
|
|
291
|
+
)
|
|
292
|
+
select sink,
|
|
293
|
+
kind
|
|
294
|
+
+ " | " + sink.getLocation().getFile().getRelativePath()
|
|
295
|
+
+ ":" + sink.getLocation().getStartLine().toString()
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### C\#
|
|
299
|
+
|
|
300
|
+
C# uses per-vulnerability sink classes. Requires a `qlpack.yml` with `codeql/csharp-all` dependency:
|
|
301
|
+
|
|
302
|
+
```yaml
|
|
303
|
+
# $DIAG_DIR/qlpack.yml
|
|
304
|
+
name: custom/diagnostics
|
|
305
|
+
version: 0.0.1
|
|
306
|
+
dependencies:
|
|
307
|
+
codeql/csharp-all: "*"
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Then run `codeql pack install` in the diagnostics directory before executing queries.
|
|
311
|
+
|
|
312
|
+
```ql
|
|
313
|
+
/**
|
|
314
|
+
* @name List recognized dataflow sinks
|
|
315
|
+
* @description Enumerates security-relevant sinks CodeQL recognizes
|
|
316
|
+
* @kind problem
|
|
317
|
+
* @id custom/list-sinks-csharp
|
|
318
|
+
*/
|
|
319
|
+
import csharp
|
|
320
|
+
import semmle.code.csharp.dataflow.DataFlow
|
|
321
|
+
import semmle.code.csharp.security.dataflow.SqlInjectionQuery
|
|
322
|
+
import semmle.code.csharp.security.dataflow.CommandInjectionQuery
|
|
323
|
+
import semmle.code.csharp.security.dataflow.TaintedPathQuery
|
|
324
|
+
import semmle.code.csharp.security.dataflow.XSSQuery
|
|
325
|
+
|
|
326
|
+
from DataFlow::Node sink, string kind
|
|
327
|
+
where
|
|
328
|
+
sink instanceof SqlInjection::Sink and kind = "sql-injection"
|
|
329
|
+
or
|
|
330
|
+
sink instanceof CommandInjection::Sink and kind = "command-injection"
|
|
331
|
+
or
|
|
332
|
+
sink instanceof TaintedPath::Sink and kind = "path-injection"
|
|
333
|
+
or
|
|
334
|
+
sink instanceof XSS::Sink and kind = "xss"
|
|
335
|
+
select sink,
|
|
336
|
+
kind
|
|
337
|
+
+ " | " + sink.getLocation().getFile().getRelativePath()
|
|
338
|
+
+ ":" + sink.getLocation().getStartLine().toString()
|
|
339
|
+
```
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Data Extension YAML Format
|
|
2
|
+
|
|
3
|
+
YAML format for CodeQL data extension files. Used by the create-data-extensions workflow to model project-specific sources, sinks, and flow summaries.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
All extension files follow this structure:
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
extensions:
|
|
11
|
+
- addsTo:
|
|
12
|
+
pack: codeql/<language>-all # Target library pack
|
|
13
|
+
extensible: <model-type> # sourceModel, sinkModel, summaryModel, neutralModel
|
|
14
|
+
data:
|
|
15
|
+
- [<columns>]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Source Models
|
|
19
|
+
|
|
20
|
+
Columns: `[package, type, subtypes, name, signature, ext, output, kind, provenance]`
|
|
21
|
+
|
|
22
|
+
| Column | Description | Example |
|
|
23
|
+
|--------|-------------|---------|
|
|
24
|
+
| package | Module/package path | `myapp.auth` |
|
|
25
|
+
| type | Class or module name | `AuthManager` |
|
|
26
|
+
| subtypes | Include subclasses | `True` (Java: capitalized) / `true` (Python/JS/Go) |
|
|
27
|
+
| name | Method name | `get_token` |
|
|
28
|
+
| signature | Method signature (optional) | `""` (Python/JS), `"(String,int)"` (Java) |
|
|
29
|
+
| ext | Extension (optional) | `""` |
|
|
30
|
+
| output | What is tainted | `ReturnValue`, `Parameter[0]` (Java) / `Argument[0]` (Python/JS/Go) |
|
|
31
|
+
| kind | Source category | `remote`, `local`, `file`, `environment`, `database` |
|
|
32
|
+
| provenance | How model was created | `manual` |
|
|
33
|
+
|
|
34
|
+
**Java-specific format differences:**
|
|
35
|
+
- **subtypes**: Use `True` / `False` (capitalized, Python-style), not `true` / `false`
|
|
36
|
+
- **output for parameters**: Use `Parameter[N]` (not `Argument[N]`) to mark method parameters as sources
|
|
37
|
+
- **signature**: Required for disambiguation — use Java type syntax: `"(String)"`, `"(String,int)"`
|
|
38
|
+
- **Parameter ranges**: Use `Parameter[0..2]` to mark multiple consecutive parameters
|
|
39
|
+
|
|
40
|
+
Example (Python):
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
# $OUTPUT_DIR/extensions/sources.yml
|
|
44
|
+
extensions:
|
|
45
|
+
- addsTo:
|
|
46
|
+
pack: codeql/python-all
|
|
47
|
+
extensible: sourceModel
|
|
48
|
+
data:
|
|
49
|
+
- ["myapp.http", "Request", true, "get_param", "", "", "ReturnValue", "remote", "manual"]
|
|
50
|
+
- ["myapp.http", "Request", true, "get_header", "", "", "ReturnValue", "remote", "manual"]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Example (Java — note `True`, `Parameter[N]`, and signature):
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
# $OUTPUT_DIR/extensions/sources.yml
|
|
57
|
+
extensions:
|
|
58
|
+
- addsTo:
|
|
59
|
+
pack: codeql/java-all
|
|
60
|
+
extensible: sourceModel
|
|
61
|
+
data:
|
|
62
|
+
- ["com.myapp.controller", "ApiController", True, "search", "(String)", "", "Parameter[0]", "remote", "manual"]
|
|
63
|
+
- ["com.myapp.service", "FileService", True, "upload", "(String,String)", "", "Parameter[0..1]", "remote", "manual"]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Sink Models
|
|
67
|
+
|
|
68
|
+
Columns: `[package, type, subtypes, name, signature, ext, input, kind, provenance]`
|
|
69
|
+
|
|
70
|
+
Note: column 7 is `input` (which argument receives tainted data), not `output`.
|
|
71
|
+
|
|
72
|
+
| Kind | Vulnerability |
|
|
73
|
+
|------|---------------|
|
|
74
|
+
| `sql-injection` | SQL injection |
|
|
75
|
+
| `command-injection` | Command injection |
|
|
76
|
+
| `path-injection` | Path traversal |
|
|
77
|
+
| `xss` | Cross-site scripting |
|
|
78
|
+
| `code-injection` | Code injection |
|
|
79
|
+
| `ssrf` | Server-side request forgery |
|
|
80
|
+
| `unsafe-deserialization` | Insecure deserialization |
|
|
81
|
+
|
|
82
|
+
Example (Python):
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
# $OUTPUT_DIR/extensions/sinks.yml
|
|
86
|
+
extensions:
|
|
87
|
+
- addsTo:
|
|
88
|
+
pack: codeql/python-all
|
|
89
|
+
extensible: sinkModel
|
|
90
|
+
data:
|
|
91
|
+
- ["myapp.db", "Connection", true, "raw_query", "", "", "Argument[0]", "sql-injection", "manual"]
|
|
92
|
+
- ["myapp.shell", "Runner", false, "execute", "", "", "Argument[0]", "command-injection", "manual"]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Example (Java — note `True` and `Argument[N]` for sink input):
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
extensions:
|
|
99
|
+
- addsTo:
|
|
100
|
+
pack: codeql/java-all
|
|
101
|
+
extensible: sinkModel
|
|
102
|
+
data:
|
|
103
|
+
- ["com.myapp.db", "QueryRunner", True, "execute", "(String)", "", "Argument[0]", "sql-injection", "manual"]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Summary Models
|
|
107
|
+
|
|
108
|
+
Columns: `[package, type, subtypes, name, signature, ext, input, output, kind, provenance]`
|
|
109
|
+
|
|
110
|
+
| Kind | Description |
|
|
111
|
+
|------|-------------|
|
|
112
|
+
| `taint` | Data flows through, still tainted |
|
|
113
|
+
| `value` | Data flows through, exact value preserved |
|
|
114
|
+
|
|
115
|
+
Example:
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
# $OUTPUT_DIR/extensions/summaries.yml
|
|
119
|
+
extensions:
|
|
120
|
+
# Pass-through: taint propagates
|
|
121
|
+
- addsTo:
|
|
122
|
+
pack: codeql/python-all
|
|
123
|
+
extensible: summaryModel
|
|
124
|
+
data:
|
|
125
|
+
- ["myapp.cache", "Cache", true, "get", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
|
|
126
|
+
- ["myapp.utils", "JSON", false, "parse", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Neutral Models
|
|
131
|
+
|
|
132
|
+
Columns: `[package, type, name, signature, kind, provenance]` (6 columns, NOT the 10-column `summaryModel` format).
|
|
133
|
+
|
|
134
|
+
Use `neutralModel` to explicitly block taint propagation through known-safe functions.
|
|
135
|
+
|
|
136
|
+
Example:
|
|
137
|
+
|
|
138
|
+
```yaml
|
|
139
|
+
- addsTo:
|
|
140
|
+
pack: codeql/python-all
|
|
141
|
+
extensible: neutralModel
|
|
142
|
+
data:
|
|
143
|
+
- ["myapp.security", "Sanitizer", "escape_html", "", "summary", "manual"]
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**`neutralModel` vs no model:** If a function has no model at all, CodeQL may still infer flow through it. Use `neutralModel` to explicitly block taint propagation through known-safe functions.
|
|
147
|
+
|
|
148
|
+
## Language-Specific Notes
|
|
149
|
+
|
|
150
|
+
**Python:** Use dotted module paths for `package` (e.g., `myapp.db`).
|
|
151
|
+
|
|
152
|
+
**JavaScript:** `package` is often `""` for project-local code. Use the import path for npm packages.
|
|
153
|
+
|
|
154
|
+
**Go:** Use full import paths (e.g., `myapp/internal/db`). `type` is often `""` for package-level functions.
|
|
155
|
+
|
|
156
|
+
**Java:** Use fully qualified package names (e.g., `com.myapp.db`).
|
|
157
|
+
|
|
158
|
+
**C/C++:** Use `""` for package, put the namespace in `type`.
|
|
159
|
+
|
|
160
|
+
## Deploying Extensions
|
|
161
|
+
|
|
162
|
+
**Known limitation:** `--additional-packs` and `--model-packs` flags do not work with pre-compiled query packs (bundled CodeQL distributions that cache `java-all` inside `.codeql/libraries/`). Extensions placed in a standalone model pack directory will be resolved by `codeql resolve qlpacks` but silently ignored during `codeql database analyze`.
|
|
163
|
+
|
|
164
|
+
**Workaround — copy extensions into the library pack's `ext/` directory:**
|
|
165
|
+
|
|
166
|
+
> **Warning:** Files copied into the `ext/` directory live inside CodeQL's managed pack cache. They will be **lost** when packs are updated via `codeql pack download` or version upgrades. After any pack update, re-run this deployment step to restore the extensions.
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Find the java-all ext directory used by the query pack
|
|
170
|
+
JAVA_ALL_EXT=$(find "$(codeql resolve qlpacks 2>/dev/null | grep 'java-queries' | awk '{print $NF}' | tr -d '()')" \
|
|
171
|
+
-path '*/.codeql/libraries/codeql/java-all/*/ext' -type d 2>/dev/null | head -1)
|
|
172
|
+
|
|
173
|
+
if [ -n "$JAVA_ALL_EXT" ]; then
|
|
174
|
+
PROJECT_NAME=$(basename "$(pwd)")
|
|
175
|
+
cp "$OUTPUT_DIR/extensions/sources.yml" "$JAVA_ALL_EXT/${PROJECT_NAME}.sources.model.yml"
|
|
176
|
+
[ -f "$OUTPUT_DIR/extensions/sinks.yml" ] && cp "$OUTPUT_DIR/extensions/sinks.yml" "$JAVA_ALL_EXT/${PROJECT_NAME}.sinks.model.yml"
|
|
177
|
+
[ -f "$OUTPUT_DIR/extensions/summaries.yml" ] && cp "$OUTPUT_DIR/extensions/summaries.yml" "$JAVA_ALL_EXT/${PROJECT_NAME}.summaries.model.yml"
|
|
178
|
+
|
|
179
|
+
# Verify deployment — confirm files landed correctly
|
|
180
|
+
DEPLOYED=$(ls "$JAVA_ALL_EXT/${PROJECT_NAME}".*.model.yml 2>/dev/null | wc -l)
|
|
181
|
+
if [ "$DEPLOYED" -gt 0 ]; then
|
|
182
|
+
echo "Extensions deployed to $JAVA_ALL_EXT ($DEPLOYED files):"
|
|
183
|
+
ls -la "$JAVA_ALL_EXT/${PROJECT_NAME}".*.model.yml
|
|
184
|
+
else
|
|
185
|
+
echo "ERROR: Files were copied but verification failed. Check path: $JAVA_ALL_EXT"
|
|
186
|
+
fi
|
|
187
|
+
else
|
|
188
|
+
echo "WARNING: Could not find java-all ext directory. Extensions may not load."
|
|
189
|
+
echo "Attempted path lookup from: codeql resolve qlpacks | grep java-queries"
|
|
190
|
+
echo "Run 'codeql resolve qlpacks' manually to debug."
|
|
191
|
+
fi
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**For Python/JS/Go:** The same limitation may apply. Locate the `<lang>-all` pack's `ext/` directory and copy extensions there.
|
|
195
|
+
|
|
196
|
+
**Alternative (if query packs are NOT pre-compiled):** Use `--additional-packs=./codeql-extensions` with a proper model pack `qlpack.yml`:
|
|
197
|
+
|
|
198
|
+
```yaml
|
|
199
|
+
# $OUTPUT_DIR/extensions/qlpack.yml
|
|
200
|
+
name: custom/<project>-extensions
|
|
201
|
+
version: 0.0.1
|
|
202
|
+
library: true
|
|
203
|
+
extensionTargets:
|
|
204
|
+
codeql/<lang>-all: "*"
|
|
205
|
+
dataExtensions:
|
|
206
|
+
- sources.yml
|
|
207
|
+
- sinks.yml
|
|
208
|
+
- summaries.yml
|
|
209
|
+
```
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Important-Only Query Suite
|
|
2
|
+
|
|
3
|
+
In important-only mode, generate a custom `.qls` query suite file at runtime. This applies the same precision/severity filtering to **all** packs (official + third-party).
|
|
4
|
+
|
|
5
|
+
## Why a Custom Suite
|
|
6
|
+
|
|
7
|
+
The built-in `security-extended` suite only applies to the official `codeql/<lang>-queries` pack. Third-party packs (Trail of Bits, Community Packs) run unfiltered when passed directly to `codeql database analyze`. A custom `.qls` suite loads queries from all packs and applies a single set of `include`/`exclude` filters uniformly.
|
|
8
|
+
|
|
9
|
+
## Metadata Criteria
|
|
10
|
+
|
|
11
|
+
Two-phase filtering: the **suite** selects candidate queries (broad), then a **post-analysis jq filter** removes low-severity medium-precision results from the SARIF output.
|
|
12
|
+
|
|
13
|
+
### Phase 1: Suite selection (which queries run)
|
|
14
|
+
|
|
15
|
+
Queries are included if they match **any** of these blocks (OR logic across blocks, AND logic within):
|
|
16
|
+
|
|
17
|
+
| Block | kind | precision | problem.severity | tags |
|
|
18
|
+
|-------|------|-----------|-----------------|------|
|
|
19
|
+
| 1 | `problem`, `path-problem` | `high`, `very-high` | *(any)* | must contain `security` |
|
|
20
|
+
| 2 | `problem`, `path-problem` | `medium` | *(any)* | must contain `security` |
|
|
21
|
+
|
|
22
|
+
### Phase 2: Post-analysis filter (which results are reported)
|
|
23
|
+
|
|
24
|
+
After `codeql database analyze` completes, filter the SARIF output:
|
|
25
|
+
|
|
26
|
+
| precision | security-severity | Action |
|
|
27
|
+
|-----------|-------------------|--------|
|
|
28
|
+
| high / very-high | *(any)* | **Keep** |
|
|
29
|
+
| medium | >= 6.0 | **Keep** |
|
|
30
|
+
| medium | < 6.0 or missing | **Drop** |
|
|
31
|
+
|
|
32
|
+
This ensures medium-precision queries with meaningful security impact (e.g., `cpp/path-injection` at 7.5, `cpp/world-writable-file-creation` at 7.8) are included, while noisy low-severity medium-precision findings are filtered out.
|
|
33
|
+
|
|
34
|
+
Excluded: deprecated queries, model editor/generator queries. Experimental queries are **included**.
|
|
35
|
+
|
|
36
|
+
**Key difference from `security-extended`:** The `security-extended` suite includes medium-precision queries at any severity. Important-only mode adds a security-severity threshold to reduce noise from medium-precision queries that flag low-impact issues.
|
|
37
|
+
|
|
38
|
+
## Suite Template
|
|
39
|
+
|
|
40
|
+
Generate this file as `important-only.qls` in the results directory before running analysis:
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
- description: Important-only — security vulnerabilities, medium-high confidence
|
|
44
|
+
# Official queries
|
|
45
|
+
- queries: .
|
|
46
|
+
from: codeql/<CODEQL_LANG>-queries
|
|
47
|
+
# Third-party packs (include only if installed, one entry per pack)
|
|
48
|
+
# - queries: .
|
|
49
|
+
# from: trailofbits/<CODEQL_LANG>-queries
|
|
50
|
+
# - queries: .
|
|
51
|
+
# from: GitHubSecurityLab/CodeQL-Community-Packs-<CODEQL_LANG>
|
|
52
|
+
# Filtering: security only, high/very-high precision (any severity),
|
|
53
|
+
# medium precision (any severity — low-severity filtered post-analysis by security-severity score).
|
|
54
|
+
# Experimental queries included.
|
|
55
|
+
- include:
|
|
56
|
+
kind:
|
|
57
|
+
- problem
|
|
58
|
+
- path-problem
|
|
59
|
+
precision:
|
|
60
|
+
- high
|
|
61
|
+
- very-high
|
|
62
|
+
tags contain:
|
|
63
|
+
- security
|
|
64
|
+
- include:
|
|
65
|
+
kind:
|
|
66
|
+
- problem
|
|
67
|
+
- path-problem
|
|
68
|
+
precision:
|
|
69
|
+
- medium
|
|
70
|
+
tags contain:
|
|
71
|
+
- security
|
|
72
|
+
- exclude:
|
|
73
|
+
deprecated: //
|
|
74
|
+
- exclude:
|
|
75
|
+
tags contain:
|
|
76
|
+
- modeleditor
|
|
77
|
+
- modelgenerator
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
> **Post-analysis step required:** After running the analysis, apply the post-analysis jq filter (defined in the run-analysis workflow Step 5) to remove medium-precision results with `security-severity` < 6.0.
|
|
81
|
+
|
|
82
|
+
## Generation Script
|
|
83
|
+
|
|
84
|
+
The agent should generate the suite file dynamically based on installed packs:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
RAW_DIR="$OUTPUT_DIR/raw"
|
|
88
|
+
SUITE_FILE="$RAW_DIR/important-only.qls"
|
|
89
|
+
|
|
90
|
+
# NOTE: CODEQL_LANG must be set before running this script (e.g., CODEQL_LANG=cpp)
|
|
91
|
+
# NOTE: INSTALLED_THIRD_PARTY_PACKS must be a space-separated list of pack names
|
|
92
|
+
|
|
93
|
+
# Use a heredoc WITHOUT quotes so ${CODEQL_LANG} expands
|
|
94
|
+
cat > "$SUITE_FILE" << HEADER
|
|
95
|
+
- description: Important-only — security vulnerabilities, medium-high confidence
|
|
96
|
+
- queries: .
|
|
97
|
+
from: codeql/${CODEQL_LANG}-queries
|
|
98
|
+
HEADER
|
|
99
|
+
|
|
100
|
+
# Add each installed third-party pack
|
|
101
|
+
for PACK in $INSTALLED_THIRD_PARTY_PACKS; do
|
|
102
|
+
cat >> "$SUITE_FILE" << PACK_ENTRY
|
|
103
|
+
- queries: .
|
|
104
|
+
from: ${PACK}
|
|
105
|
+
PACK_ENTRY
|
|
106
|
+
done
|
|
107
|
+
|
|
108
|
+
# Append the filtering rules (quoted heredoc — no variable expansion needed)
|
|
109
|
+
cat >> "$SUITE_FILE" << 'FILTERS'
|
|
110
|
+
- include:
|
|
111
|
+
kind:
|
|
112
|
+
- problem
|
|
113
|
+
- path-problem
|
|
114
|
+
precision:
|
|
115
|
+
- high
|
|
116
|
+
- very-high
|
|
117
|
+
tags contain:
|
|
118
|
+
- security
|
|
119
|
+
- include:
|
|
120
|
+
kind:
|
|
121
|
+
- problem
|
|
122
|
+
- path-problem
|
|
123
|
+
precision:
|
|
124
|
+
- medium
|
|
125
|
+
tags contain:
|
|
126
|
+
- security
|
|
127
|
+
- exclude:
|
|
128
|
+
deprecated: //
|
|
129
|
+
- exclude:
|
|
130
|
+
tags contain:
|
|
131
|
+
- modeleditor
|
|
132
|
+
- modelgenerator
|
|
133
|
+
FILTERS
|
|
134
|
+
|
|
135
|
+
# Verify the suite resolves correctly
|
|
136
|
+
: "${CODEQL_LANG:?ERROR: CODEQL_LANG must be set before generating suite}"
|
|
137
|
+
: "${SUITE_FILE:?ERROR: SUITE_FILE must be set}"
|
|
138
|
+
|
|
139
|
+
if ! codeql resolve queries "$SUITE_FILE" | head -20; then
|
|
140
|
+
echo "ERROR: Suite file failed to resolve. Check CODEQL_LANG=$CODEQL_LANG and installed packs."
|
|
141
|
+
fi
|
|
142
|
+
echo "Suite generated: $SUITE_FILE"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## How Filtering Works on Third-Party Queries
|
|
146
|
+
|
|
147
|
+
CodeQL query suite filters match on query metadata (`@precision`, `@problem.severity`, `@tags`). Third-party queries that:
|
|
148
|
+
|
|
149
|
+
- **Have proper metadata**: Filtered normally (kept if they match the include criteria)
|
|
150
|
+
- **Lack `@precision`**: Excluded by `include` blocks (they require precision to match). This is correct — if a query doesn't declare its precision, we cannot assess its confidence.
|
|
151
|
+
- **Lack `@tags security`**: Excluded. Non-security queries are not relevant to important-only mode.
|
|
152
|
+
|
|
153
|
+
This is a stricter-than-necessary filter for third-party packs, but it ensures only well-annotated security queries run in important-only mode. The post-analysis jq filter then further narrows medium-precision results to those with `security-severity` >= 6.0.
|