Skip to content

Commit dd87de6

Browse files
committed
experimental rules in run all mode; more explicit gates/ask-user
1 parent 5c15f4f commit dd87de6

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

plugins/static-analysis/skills/codeql/SKILL.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ description: >-
44
Scans a codebase for security vulnerabilities using CodeQL's interprocedural data flow and
55
taint tracking analysis. Triggers on "run codeql", "codeql scan", "codeql analysis", "build
66
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.
7+
+ security-experimental suites) and "important only" (high-precision security findings) scan
8+
modes. Also handles creating data extension models and processing CodeQL SARIF output.
99
allowed-tools:
1010
- Bash
1111
- Read
@@ -155,6 +155,7 @@ Then execute the full pipeline: **build database → create data extensions →
155155
These shortcuts lead to missed findings. Do not accept them:
156156

157157
- **"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+
- **"security-and-quality is the broadest suite"** - `security-and-quality` excludes all `experimental/` query paths. For run-all mode, import both `security-and-quality` and `security-experimental`. The delta is 1–52 queries depending on the language.
158159
- **"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.
159160
- **"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.
160161
- **"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.

plugins/static-analysis/skills/codeql/references/ruleset-catalog.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
| Suite | False Positives | Use Case |
66
|-------|-----------------|----------|
77
| `security-extended` | Low | **Default** - Security audits |
8-
| `security-and-quality` | Medium | Comprehensive review |
9-
| `security-experimental` | Higher | Research, vulnerability hunting |
8+
| `security-and-quality` | Medium | Comprehensive review (stable security + code quality) |
9+
| `security-experimental` | Higher | Research, vulnerability hunting (stable security + experimental security) |
10+
11+
> **Suite hierarchy:** `security-and-quality` and `security-experimental` are complementary. `security-and-quality` excludes `experimental/` query paths. `security-experimental` includes them but excludes code quality queries. For maximum coverage (run-all mode), import both.
1012
1113
**Usage:** `codeql/<lang>-queries:codeql-suites/<lang>-security-extended.qls`
1214

plugins/static-analysis/skills/codeql/references/run-all-suite.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,23 @@ In run-all mode, generate a custom `.qls` query suite file at runtime. This ensu
66

77
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.
88

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.
9+
The run-all suite explicitly imports both `security-and-quality` and `security-experimental` from official packs, plus third-party packs with minimal filtering.
10+
11+
> **Why both suites?** `security-and-quality` = stable security + code quality (excludes `experimental/` paths). `security-experimental` = stable security + experimental security (re-includes `experimental/` paths tagged `security`). They are complementary — importing both is safe since CodeQL deduplicates shared queries automatically.
1012
1113
## Suite Template
1214

1315
Generate this file as `run-all.qls` in the results directory before running analysis:
1416

1517
```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+
- description: Run-all — all security, experimental, and quality queries from all installed packs
19+
# Official queries: import BOTH suites (they are complementary, not hierarchical)
20+
# security-and-quality = stable security + code quality (excludes experimental/ paths)
21+
# security-experimental = stable security + experimental security (re-includes experimental/ with security tag)
1822
- import: codeql-suites/<CODEQL_LANG>-security-and-quality.qls
1923
from: codeql/<CODEQL_LANG>-queries
24+
- import: codeql-suites/<CODEQL_LANG>-security-experimental.qls
25+
from: codeql/<CODEQL_LANG>-queries
2026
# Third-party packs (include only if installed, one entry per pack)
2127
# - queries: .
2228
# from: trailofbits/<CODEQL_LANG>-queries
@@ -45,9 +51,11 @@ SUITE_FILE="$RAW_DIR/run-all.qls"
4551
# NOTE: INSTALLED_THIRD_PARTY_PACKS must be a space-separated list of pack names
4652

4753
cat > "$SUITE_FILE" << HEADER
48-
- description: Run-all — all security and quality queries from all installed packs
54+
- description: Run-all — all security, experimental, and quality queries from all installed packs
4955
- import: codeql-suites/${CODEQL_LANG}-security-and-quality.qls
5056
from: codeql/${CODEQL_LANG}-queries
57+
- import: codeql-suites/${CODEQL_LANG}-security-experimental.qls
58+
from: codeql/${CODEQL_LANG}-queries
5159
HEADER
5260

5361
# Add each installed third-party pack
@@ -86,7 +94,7 @@ echo "Suite generated: $SUITE_FILE"
8694
8795
| Aspect | Run all | Important only |
8896
|--------|---------|----------------|
89-
| Official pack suite | `security-and-quality` (all security + code quality) | All queries loaded, filtered by precision |
97+
| Official pack suites | `security-and-quality` + `security-experimental` (stable security + code quality + experimental security) | All queries loaded, filtered by precision |
9098
| Third-party packs | All `problem`/`path-problem` queries | Only `security`-tagged queries with precision metadata |
9199
| Precision filter | None | high/very-high always; medium only if security-severity >= 6.0 |
92100
| Post-analysis filter | None | Drops medium-precision results with security-severity < 6.0 |

plugins/static-analysis/skills/codeql/workflows/run-analysis.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Two modes control analysis scope. Both use all installed packs — the differenc
88

99
| Mode | Description | Suite Reference |
1010
|------|-------------|-----------------|
11-
| **Run all** | All queries from all installed packs via `security-and-quality` suite | [run-all-suite.md](../references/run-all-suite.md) |
11+
| **Run all** | All queries from all installed packs via `security-and-quality` + `security-experimental` suites | [run-all-suite.md](../references/run-all-suite.md) |
1212
| **Important only** | Security queries filtered by precision and security-severity threshold | [important-only-suite.md](../references/important-only-suite.md) |
1313

1414
> **WARNING:** Do NOT pass pack names directly to `codeql database analyze` (e.g., `-- codeql/cpp-queries`). Each pack's `defaultSuiteFile` silently applies strict filters and can produce zero results. Always use an explicit suite reference.
@@ -31,10 +31,11 @@ TaskCreate: "Process and report results" (Step 5) - blockedBy: Step 4
3131

3232
| Task | Gate Type | Cannot Proceed Until |
3333
|------|-----------|---------------------|
34-
| Step 2 | **SOFT GATE** | User selects mode; confirms installed/ignored for each missing pack |
35-
| Step 3 | **SOFT GATE** | User approves query packs, model packs, and threat model selection |
34+
| Step 2a | **SOFT GATE** | User selects scan mode. Skip only if user said "run all" or "important only" verbatim. |
35+
| Step 3a | **HARD GATE** | User confirms query pack selection. Always ask — no auto-skip. |
36+
| Step 3c | **HARD GATE** | User selects threat model. Always ask — no auto-skip. |
3637

37-
**Auto-skip rule:** If the user already specified a choice in the invocation, skip the corresponding `AskUserQuestion` and use the provided value directly.
38+
**Auto-skip rules are per-gate.** Each gate documents its own skip condition. Choosing "full scan" or "run all" satisfies the scan mode gate (2a) but does not satisfy pack confirmation (3a) or threat model selection (3c).
3839

3940
---
4041

@@ -94,7 +95,7 @@ If multi-language database, ask which language to analyze.
9495

9596
#### 2a: Select Scan Mode
9697

97-
**Skip if user already specified.** Otherwise use `AskUserQuestion`:
98+
**Skip only if user said "run all" or "important only" in their prompt.** "Full scan", "scan", or "analyze" do NOT count — ask.
9899

99100
```
100101
header: "Scan Mode"
@@ -139,13 +140,13 @@ Record all detected packs for Step 3.
139140
**Exit:** User confirmed query packs, model packs, and threat model selection; all flags built (`THREAT_MODEL_FLAG`, `MODEL_PACK_FLAGS`, `ADDITIONAL_PACK_FLAGS`)
140141

141142
> **CHECKPOINT** — Present available packs to user for confirmation.
142-
> **Skip if user already specified pack preferences.**
143+
> **Always ask. Do not auto-skip.**
143144
144145
#### 3a: Confirm Query Packs
145146

146147
**Important-only mode:** Inform user all installed packs included with filtering. Proceed to 3b.
147148

148-
**Run-all mode:** Use `AskUserQuestion` to confirm "Use all" or "Select individually".
149+
**Run-all mode:** Use `AskUserQuestion` to confirm "Use all" or "Select individually". Always ask — the user needs to see which packs will run.
149150

150151
#### 3b: Select Model Packs (if any detected)
151152

@@ -162,7 +163,7 @@ Use `AskUserQuestion`: "Use all (Recommended)" / "Select individually" / "Skip".
162163

163164
Threat models control which input sources CodeQL treats as tainted. See [threat-models.md](../references/threat-models.md).
164165

165-
Use `AskUserQuestion`:
166+
**Always ask.** Do not default to "remote only" without user confirmation. Use `AskUserQuestion`:
166167

167168
```
168169
header: "Threat Models"

0 commit comments

Comments
 (0)