diff --git a/README.md b/README.md index 9fd33d4..2749030 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Compliance Scanner is an autonomous agent that continuously monitors git reposit | Area | Capabilities | |------|-------------| -| **SAST Scanning** | Semgrep-based static analysis with auto-config rules | +| **SAST Scanning** | Semgrep engine with our own CRA rules (no registry rules), cppcheck for C/C++ | | **SBOM Generation** | Syft + cargo-audit for complete dependency inventory | | **CVE Monitoring** | OSV.dev batch queries, NVD CVSS enrichment, SearXNG context | | **GDPR Patterns** | Detect PII logging, missing consent, hardcoded retention, missing deletion | diff --git a/compliance-agent/rules/cra_semgrep.js b/compliance-agent/rules/cra_semgrep.js new file mode 100644 index 0000000..d961be5 --- /dev/null +++ b/compliance-agent/rules/cra_semgrep.js @@ -0,0 +1,21 @@ +const { exec } = require("child_process"); +const express = require("express"); +const app = express(); + +app.get("/orders/export", (req, res) => { + // ruleid: cra-ai-20-node-shell-command + exec("/usr/local/bin/export-orders --customer " + req.query.customer, (err, stdout) => { + // ruleid: cra-ai-20-node-reflected-input + res.send("

Exported for " + req.query.customer + "

" + stdout); + }); + // ok: cra-ai-20-node-shell-command + exec("uptime", () => {}); + // ok: cra-ai-20-node-reflected-input + res.send("

" + encodeURIComponent(req.query.customer) + "

"); + // ok: cra-ai-20-node-shell-command + /a(b)/.exec(req.query.customer); + // ruleid: cra-ai-15-node-cleartext-http + fetch("http://api.example.com/orders"); + // ok: cra-ai-15-node-cleartext-http + fetch("https://api.example.com/orders"); +}); diff --git a/compliance-agent/rules/cra_semgrep.py b/compliance-agent/rules/cra_semgrep.py new file mode 100644 index 0000000..6ea5b5e --- /dev/null +++ b/compliance-agent/rules/cra_semgrep.py @@ -0,0 +1,57 @@ +import os +import subprocess +import requests + +# ruleid: cra-ai-20-python-shell-command +os.system("ping -c 1 " + host) +# ok: cra-ai-20-python-shell-command +os.system("uptime") +# ruleid: cra-ai-20-python-shell-command +subprocess.call("rotate-key --id " + key_id, shell=True) +# ok: cra-ai-20-python-shell-command +subprocess.call("rotate-key --all", shell=True) +# ok: cra-ai-20-python-shell-command +subprocess.call(["rotate-key", "--id", key_id]) + +# ruleid: cra-ai-20-python-sql-string +cur.execute("SELECT * FROM users WHERE id = " + user_id) +# ruleid: cra-ai-20-python-sql-string +cur.execute(f"SELECT * FROM users WHERE id = {user_id}") +# ruleid: cra-ai-20-python-sql-string +cur.execute("SELECT * FROM users WHERE id = %s" % user_id) +# ok: cra-ai-20-python-sql-string +cur.execute("SELECT * FROM users WHERE id = %s", (user_id,)) +# ok: cra-ai-20-python-sql-string +cur.execute("SELECT 1") + +# ruleid: cra-ai-8-python-hardcoded-credential +ADMIN_PASSWORD = "admin123" +# ruleid: cra-ai-8-python-hardcoded-credential +API_KEY = "sk_live_51HxYzABCDEFghijklmnopqrstuvwxyz0123456789" +# ok: cra-ai-8-python-hardcoded-credential +ADMIN_PASSWORD = os.environ["ADMIN_PASSWORD"] +# ok: cra-ai-8-python-hardcoded-credential +PASSWORD_FIELD = "password" +# ok: cra-ai-8-python-hardcoded-credential +password = "" +# ok: cra-ai-8-python-hardcoded-credential +password = "changeme" + +# ruleid: cra-ai-15-python-cleartext-http +requests.get("http://api.internal.example/" + path) +# ok: cra-ai-15-python-cleartext-http +requests.get("https://api.internal.example/" + path) +# ok: cra-ai-15-python-cleartext-http +requests.get("http://localhost:8080/health") + +import pickle +import yaml + +# ruleid: cra-ai-20-python-unsafe-deserialization +config = yaml.load(request.data) +# ok: cra-ai-20-python-unsafe-deserialization +config = yaml.load(request.data, Loader=yaml.SafeLoader) +# ok: cra-ai-20-python-unsafe-deserialization +config = yaml.safe_load(request.data) +# ruleid: cra-ai-20-python-unsafe-deserialization +session = pickle.loads(request.cookies["session"]) diff --git a/compliance-agent/rules/cra_semgrep.yaml b/compliance-agent/rules/cra_semgrep.yaml index bc40c2d..ebf9e4c 100644 --- a/compliance-agent/rules/cra_semgrep.yaml +++ b/compliance-agent/rules/cra_semgrep.yaml @@ -1,4 +1,5 @@ -# Custom semgrep rules for CRA controls that no off-the-shelf ruleset digs out. +# Prüfwerk's own semgrep rules, the only ones it runs: the Semgrep registry rules +# are licensed for internal use only, not for a service offered to others. # Each rule id is `cra-ai--` and is keyed back to its control via the # `control-map` LUT (by rule-id suffix, so semgrep's path prefix on check_id does # not matter). Detection here is deterministic; the grounded LLM judge downstream @@ -116,6 +117,166 @@ rules: - pattern: 'crypto.createCipheriv("des", ...)' - pattern: 'crypto.createCipher(...)' + # --- Python and JavaScript/TypeScript: injection, credentials, transport ------- + # A constant string never matches; the reflected-input rule follows Express + # request input (`req.query`, `req.params`, `req.body`) into the response. + # Annotated cases: cra_semgrep.py / cra_semgrep.js, run with + # `semgrep --test compliance-agent/rules`. + - id: cra-ai-20-python-shell-command + languages: [python] + severity: ERROR + message: A shell command is built from a variable, so whoever controls it can run any command (CWE-78). Pass an argument list without shell=True, or validate the value against an allowlist. + metadata: + cwe: ["CWE-78: Improper Neutralization of Special Elements used in an OS Command"] + control: cra-ai-20 + patterns: + - pattern-either: + - pattern: os.system($CMD) + - pattern: os.popen($CMD, ...) + - pattern: subprocess.$F($CMD, ..., shell=True, ...) + - metavariable-pattern: + metavariable: $CMD + patterns: + - pattern-not: '"..."' + + - id: cra-ai-20-python-sql-string + languages: [python] + severity: ERROR + message: An SQL statement is assembled from a variable, so its value can change the query (SQL injection, CWE-89). Pass values as query parameters (cursor.execute(sql, params)). + metadata: + cwe: ["CWE-89: Improper Neutralization of Special Elements used in an SQL Command"] + control: cra-ai-20 + patterns: + - pattern-either: + - pattern: $CUR.execute("..." + $X, ...) + - pattern: $CUR.execute("..." % $X, ...) + - pattern: $CUR.execute(f"...", ...) + - pattern: $CUR.execute("...".format(...), ...) + - pattern: $CUR.executemany("..." + $X, ...) + - pattern-not: $CUR.execute(f"{$C}", ...) + + - id: cra-ai-20-python-unsafe-deserialization + languages: [python] + severity: ERROR + message: Data is deserialised with a loader that can build arbitrary objects, so crafted input runs code (CWE-502). Use yaml.safe_load, or JSON for data from outside. + metadata: + cwe: ["CWE-502: Deserialization of Untrusted Data"] + control: cra-ai-20 + pattern-either: + - pattern: pickle.loads(...) + - pattern: pickle.load(...) + - pattern: cPickle.loads(...) + - pattern: marshal.loads(...) + - patterns: + - pattern: yaml.load(...) + - pattern-not: yaml.load(..., Loader=yaml.SafeLoader, ...) + - pattern-not: yaml.load(..., Loader=yaml.CSafeLoader, ...) + - pattern-not: yaml.load(..., Loader=SafeLoader, ...) + - pattern: yaml.unsafe_load(...) + + - id: cra-ai-20-node-shell-command + languages: [javascript, typescript] + severity: ERROR + message: A shell command is built from a variable, so whoever controls it can run any command (CWE-78). Use execFile/spawn with an argument list, or validate the value against an allowlist. + metadata: + cwe: ["CWE-78: Improper Neutralization of Special Elements used in an OS Command"] + control: cra-ai-20 + patterns: + - pattern-either: + - pattern: exec($CMD, ...) + - pattern: execSync($CMD, ...) + - pattern: $CP.exec($CMD, ...) + - pattern: $CP.execSync($CMD, ...) + - pattern-not: exec("...", ...) + - pattern-not: execSync("...", ...) + - pattern-not: $CP.exec("...", ...) + - pattern-not: $CP.execSync("...", ...) + - pattern-not: $CP.exec(`...`, ...) + - pattern-inside: | + $REQ = require("child_process") + ... + - pattern-not: $RE.exec($X) + + - id: cra-ai-20-node-reflected-input + languages: [javascript, typescript] + severity: WARNING + message: Request input is written into the response without encoding, so a crafted link runs script in the user's browser (reflected XSS, CWE-79). Encode it, or use a template engine that escapes by default. + metadata: + cwe: ["CWE-79: Improper Neutralization of Input During Web Page Generation"] + control: cra-ai-20 + mode: taint + pattern-sources: + - pattern-either: + - pattern: $REQ.query + - pattern: $REQ.params + - pattern: $REQ.body + pattern-sinks: + - pattern-either: + - pattern: $RES.send(...) + - pattern: $RES.write(...) + pattern-sanitizers: + - pattern-either: + - pattern: encodeURIComponent(...) + - pattern: escape(...) + - pattern: escapeHtml(...) + - pattern: parseInt(...) + - pattern: Number(...) + + - id: cra-ai-8-python-hardcoded-credential + languages: [python] + severity: ERROR + message: $NAME holds a credential written into the code, so every installation ships the same secret (CWE-798). Read it from the environment or a secret store. + metadata: + cwe: ["CWE-798: Use of Hard-coded Credentials"] + control: cra-ai-8 + patterns: + - pattern-either: + - pattern: $NAME = "$VALUE" + - pattern: $OBJ.$NAME = "$VALUE" + - metavariable-regex: + metavariable: $NAME + regex: (?i)^[a-z_]*(password|passwd|pwd|secret|api_?key|access_?key|token|credential)s?$ + - metavariable-regex: + metavariable: $VALUE + regex: ^(?!(?i:changeme|change-me|xxx+|\*+|todo|example|placeholder|dummy|test)$).{4,}$ + + - id: cra-ai-15-python-cleartext-http + languages: [python] + severity: WARNING + message: A request goes over plain http://, so it can be read and altered in transit (CWE-319). Use https:// with certificate checking. + metadata: + cwe: ["CWE-319: Cleartext Transmission of Sensitive Information"] + control: cra-ai-15 + patterns: + - pattern-either: + - pattern: requests.$M("$URL", ...) + - pattern: requests.$M("$URL" + $X, ...) + - pattern: urllib.request.urlopen("$URL", ...) + - pattern: httpx.$M("$URL", ...) + - pattern: httpx.$M("$URL" + $X, ...) + - metavariable-regex: + metavariable: $URL + regex: ^http://(?!(localhost|127\.|0\.0\.0\.0|\[::1\])) + + - id: cra-ai-15-node-cleartext-http + languages: [javascript, typescript] + severity: WARNING + message: A request goes over plain http://, so it can be read and altered in transit (CWE-319). Use https:// with certificate checking. + metadata: + cwe: ["CWE-319: Cleartext Transmission of Sensitive Information"] + control: cra-ai-15 + patterns: + - pattern-either: + - pattern: fetch("$URL", ...) + - pattern: fetch("$URL" + $X, ...) + - pattern: axios.$M("$URL", ...) + - pattern: axios.$M("$URL" + $X, ...) + - pattern: http.get("$URL", ...) + - pattern: http.request("$URL", ...) + - metavariable-regex: + metavariable: $URL + regex: ^http://(?!(localhost|127\.|0\.0\.0\.0|\[::1\])) + # --- C/C++ firmware ------------------------------------------------------------ # C and C++ sources alike (`languages: [c, cpp]`), with the `std::` spellings. # Microcontroller code: unbounded string handling, non-literal format strings, diff --git a/compliance-agent/src/pipeline/semgrep.rs b/compliance-agent/src/pipeline/semgrep.rs index 0a75b3e..f69943e 100644 --- a/compliance-agent/src/pipeline/semgrep.rs +++ b/compliance-agent/src/pipeline/semgrep.rs @@ -10,28 +10,34 @@ use crate::pipeline::source_text::{read_lines, relative_path}; /// What open-source semgrep writes in place of the matched code. const REDACTED_LINES: &str = "requires login"; -/// Custom CRA-control detectors bundled into the binary and staged to a temp file -/// at scan time so semgrep can `--config` them alongside the auto ruleset. These -/// cover controls no off-the-shelf rule digs out (secure defaults, weak password -/// hashing, insecure session cookies, weak data-at-rest ciphers); each rule id is -/// keyed back to its control by the `control-map` LUT. +/// Our own CRA-control rules, bundled into the binary and staged to a temp +/// file at scan time. They are the only rules semgrep runs: the Semgrep +/// registry rules (`--config=auto`, `p/...`) are licensed for internal use +/// only, not for a service offered to others, and `auto` cannot run without +/// sending metrics to Semgrep. Each rule id is keyed back to its control by the +/// `control-map` LUT. const CRA_RULES: &str = include_str!("../../rules/cra_semgrep.yaml"); /// Write the bundled CRA rules to a stable temp path (atomic: unique tmp + -/// rename). Returns `None` on failure — the scan then runs with auto rules only. -async fn stage_cra_rules() -> Option { +/// rename). +/// +/// # Errors +/// +/// Returns `CoreError::Scanner` when the file cannot be written: without it +/// semgrep has no rules to run, and the stage must read as failed, not clean. +async fn stage_cra_rules() -> Result { let dir = std::env::temp_dir(); let path = dir.join("compliance-cra-semgrep.yaml"); let tmp = dir.join(format!("compliance-cra-semgrep.{}.tmp", std::process::id())); - if let Err(e) = tokio::fs::write(&tmp, CRA_RULES).await { - tracing::warn!(error = %e, "failed to stage custom CRA semgrep rules; using auto rules only"); - return None; - } - if let Err(e) = tokio::fs::rename(&tmp, &path).await { - tracing::warn!(error = %e, "failed to stage custom CRA semgrep rules; using auto rules only"); - return None; - } - Some(path) + let staged = async { + tokio::fs::write(&tmp, CRA_RULES).await?; + tokio::fs::rename(&tmp, &path).await + }; + staged.await.map_err(|e| CoreError::Scanner { + scanner: "semgrep".to_string(), + source: format!("could not stage the CRA rules: {e}").into(), + })?; + Ok(path) } /// semgrep over a tree, skipping vendor directories. @@ -59,15 +65,23 @@ impl Scanner for SemgrepScanner { #[tracing::instrument(skip_all)] async fn scan(&self, repo_path: &Path, repo_id: &str) -> Result { - let cra_rules = stage_cra_rules().await; + let cra_rules = stage_cra_rules().await?; // Empty environment + kill-on-drop: semgrep only needs to find itself - // and write temp files, and a timed-out run must actually die. - let mut command = crate::pipeline::tool_cmd::tool("semgrep", &["SEMGREP_RULES"]); - command.arg("--config=auto"); - if let Some(path) = &cra_rules { - command.arg(format!("--config={}", path.display())); - } - command.args(["--json", "--quiet", "--max-memory", "500", "--jobs", "2"]); + // and write temp files, and a timed-out run must actually die. No + // metrics and no version check: nothing about a customer's code leaves + // the scan. + let mut command = crate::pipeline::tool_cmd::tool("semgrep", &[]); + command.arg(format!("--config={}", cra_rules.display())); + command.args([ + "--metrics=off", + "--disable-version-check", + "--json", + "--quiet", + "--max-memory", + "500", + "--jobs", + "2", + ]); // Anchored at the tree root: a bare `Drivers` would also skip a // customer's own `app/Drivers/`. for dir in &self.excluded { diff --git a/compliance-agent/src/pipeline/tool_cmd.rs b/compliance-agent/src/pipeline/tool_cmd.rs index c2b6c27..5fa7e08 100644 --- a/compliance-agent/src/pipeline/tool_cmd.rs +++ b/compliance-agent/src/pipeline/tool_cmd.rs @@ -110,7 +110,7 @@ mod tests { // `Command`'s environment is not readable back, so assert on what we can // see: the program, and that building one does not panic with a cleared // environment plus extras. - let cmd = tool("semgrep", &["SEMGREP_RULES"]); + let cmd = tool("semgrep", &[]); assert_eq!(cmd.as_std().get_program(), "semgrep"); assert!(cmd.as_std().get_envs().count() > 0, "allowlist applied"); } diff --git a/compliance-agent/tests/nightly.rs b/compliance-agent/tests/nightly.rs index f1ed4b3..d567e46 100644 --- a/compliance-agent/tests/nightly.rs +++ b/compliance-agent/tests/nightly.rs @@ -17,9 +17,8 @@ //! - a blessed snapshot in `fixtures/nightly/baselines/.json`: //! - **exact**: scan status, skipped stages, SBOM components, and findings //! from deterministic scanners (PLC rules, secrets, patterns, lint, our own -//! `cra-ai-*` semgrep rules); -//! - **at least**: CVE and advisory ids, and semgrep registry rules, whose -//! sources change daily; +//! `cra-ai-*` semgrep rules, the only ones semgrep runs); +//! - **at least**: CVE and advisory ids, whose sources change daily; //! - **ignored**: LLM code review and triage. Control refs, which the LLM //! control judge stamps, are reported under "advisory" but do not gate. //! @@ -336,8 +335,6 @@ struct Snapshot { findings: BTreeSet, /// CVE and advisory ids; the run must contain at least these. cves: BTreeSet, - /// Semgrep registry rules; the run must contain at least these. - registry_rules: BTreeSet, } impl Snapshot { @@ -380,11 +377,6 @@ impl Snapshot { out.extend(exact("SBOM component", &self.sbom, &baseline.sbom)); out.extend(exact("finding", &self.findings, &baseline.findings)); out.extend(at_least("CVE", &self.cves, &baseline.cves)); - out.extend(at_least( - "registry rule", - &self.registry_rules, - &baseline.registry_rules, - )); out } } @@ -465,8 +457,6 @@ async fn collect(agent: &Agent, target_id: &str, run: &Value) -> Collected { snapshot.cves.insert(rule); } else if scan_type == "codereview" { // LLM output: runs, never gates. - } else if scanner == "semgrep" && !rule.starts_with("cra-ai-") { - snapshot.registry_rules.insert(rule); } else { let file = Path::new(&text(f, "file_path")) .file_name() @@ -734,26 +724,25 @@ mod unit { skipped_stages: set(&["dast"]), sbom: set(&["cargo:itoa@1.0.15"]), findings: set(&["gitleaks:aws-key a.py:3"]), - cves: set(&["CVE-2020-1"]), - registry_rules: set(&["python.lang.x"]), + cves: set(&["CVE-2020-1", "GHSA-xxxx-yyyy-zzzz"]), }; let mut run = blessed.clone(); assert!(run.diff(&blessed).is_empty()); run.sbom = set(&["cargo:itoa@1.0.16"]); - run.cves = set(&["CVE-2020-1", "CVE-2026-9"]); // a new CVE is fine - run.registry_rules = set(&[]); + // A new CVE is fine, a lost one is not. + run.cves = set(&["CVE-2020-1", "CVE-2026-9"]); run.scan_status = "failed".into(); let diff = run.diff(&blessed); for needle in [ "scan status failed, blessed completed", "missing SBOM component: cargo:itoa@1.0.15", "unexpected SBOM component: cargo:itoa@1.0.16", - "missing registry rule: python.lang.x", + "missing CVE: GHSA-xxxx-yyyy-zzzz", ] { assert!(diff.iter().any(|d| d == needle), "{needle} not in {diff:?}"); } - assert!(!diff.iter().any(|d| d.contains("CVE")), "{diff:?}"); + assert!(!diff.iter().any(|d| d.contains("CVE-2026-9")), "{diff:?}"); } #[test] diff --git a/control-map/data/cra_control_map.json b/control-map/data/cra_control_map.json index 4add688..cc0fc64 100644 --- a/control-map/data/cra_control_map.json +++ b/control-map/data/cra_control_map.json @@ -119,14 +119,6 @@ "scan_type": "sast", "languages": [ "python", - "javascript", - "typescript", - "java", - "go", - "ruby", - "php", - "csharp", - "kotlin", "c", "cpp" ], @@ -135,6 +127,7 @@ "CWE-259" ], "rules": [ + "cra-ai-8-python-hardcoded-credential", "cra-ai-8-c-hardcoded-credential" ], "check": "No credential (password, key, token) may be written into the product's source, as a variable or a #define: every device would ship the same secret. A placeholder or an empty value does not violate it." @@ -154,27 +147,6 @@ "cwe": [], "rules": [], "check": "Credentials must not be kept in plain text in the source or configuration; a real secret committed to the repository violates it." - }, - { - "tool": "semgrep", - "scan_type": "sast", - "languages": [ - "python", - "javascript", - "typescript", - "java", - "go", - "ruby", - "php", - "csharp", - "kotlin" - ], - "cwe": [ - "CWE-798", - "CWE-522" - ], - "rules": [], - "check": "Credentials must not be kept or compared in plain text; a hard-coded or plain-text stored secret violates it." } ], "note": null, @@ -267,15 +239,6 @@ "tool": "semgrep", "scan_type": "sast", "languages": [ - "python", - "javascript", - "typescript", - "java", - "go", - "ruby", - "php", - "csharp", - "kotlin", "c", "cpp" ], @@ -325,19 +288,13 @@ "languages": [ "python", "javascript", - "typescript", - "java", - "go", - "ruby", - "php", - "csharp", - "kotlin" + "typescript" ], - "cwe": [ - "CWE-319", - "CWE-311" + "cwe": [], + "rules": [ + "cra-ai-15-python-cleartext-http", + "cra-ai-15-node-cleartext-http" ], - "rules": [], "check": "Network traffic must use TLS 1.2 or newer with certificate checking; plain HTTP for sensitive data, disabled verification or old protocol versions violate it." } ], @@ -360,15 +317,6 @@ "tool": "semgrep", "scan_type": "sast", "languages": [ - "python", - "javascript", - "typescript", - "java", - "go", - "ruby", - "php", - "csharp", - "kotlin", "c", "cpp" ], @@ -417,12 +365,6 @@ "python", "javascript", "typescript", - "java", - "go", - "ruby", - "php", - "csharp", - "kotlin", "c", "cpp" ], @@ -433,11 +375,16 @@ "CWE-22" ], "rules": [ + "cra-ai-20-python-shell-command", + "cra-ai-20-python-sql-string", + "cra-ai-20-python-unsafe-deserialization", + "cra-ai-20-node-shell-command", + "cra-ai-20-node-reflected-input", "cra-ai-20-c-unbounded-string-function", "cra-ai-20-c-scanf-unbounded-string", "cra-ai-20-c-non-literal-format-string" ], - "check": "The code must not write past a buffer or let input control a format string: strcpy, strcat, sprintf, gets, scanf(\"%s\") or a non-literal format argument violates it." + "check": "Untrusted input must not reach a shell, an SQL statement or an HTML response unencoded, and the code must not write past a buffer or let input control a format string: a command or query built from a variable, request input echoed into a response, strcpy, strcat, sprintf, gets, scanf(\"%s\") or a non-literal format argument violates it." }, { "tool": "cppcheck", diff --git a/control-map/src/lib.rs b/control-map/src/lib.rs index 5963673..6066302 100644 --- a/control-map/src/lib.rs +++ b/control-map/src/lib.rs @@ -292,8 +292,8 @@ mod tests { let s = ControlMap::cra().unwrap().summary(); assert!(s.covered > 0); assert!(s.not_code_checkable > 0); - // needs_tooling is now empty: every code-checkable control is either - // tool-covered or covered by the grounded surface pass. + // needs_tooling is empty: every code-checkable control is either + // covered by our own rules and tools or by the grounded surface pass. assert_eq!(s.needs_tooling, 0); } @@ -329,8 +329,9 @@ mod tests { #[test] fn coverage_after_grounded_promotion() { let s = ControlMap::cra().unwrap().summary(); - // 9 off-the-shelf + 4 custom-semgrep + 8 grounded surface controls (promoted - // after the grounded path was validated live). + // Our own semgrep rules, gitleaks, cppcheck, syft/OSV and 8 grounded + // surface controls (promoted after the grounded path was validated + // live). assert_eq!(s.covered, 21); // Nothing left as needs_tooling — every code-checkable control is covered. assert_eq!(s.needs_tooling, 0); diff --git a/docs/design/derive-checks-from-controls.md b/docs/design/derive-checks-from-controls.md index fa9d1a1..114acac 100644 --- a/docs/design/derive-checks-from-controls.md +++ b/docs/design/derive-checks-from-controls.md @@ -14,7 +14,7 @@ coverage. ## How it works today -1. **Detectors run on their own:** semgrep (the registry and our CRA rule pack), +1. **Detectors run on their own:** semgrep (our CRA rule pack; registry rules are not licensed for a service), cppcheck, gitleaks, syft/osv and the PLC linter. 2. **Our control map** (`control-map/data/cra_control_map.json`, written and reviewed by us) binds each of the 40 CRA Annex I controls to the tools, rule ids, CWEs and diff --git a/docs/features/control-mapping.md b/docs/features/control-mapping.md index 9b8aa97..77ed8ac 100644 --- a/docs/features/control-mapping.md +++ b/docs/features/control-mapping.md @@ -22,10 +22,10 @@ Every control lands in one of three buckets, recorded in the `control-map` LUT ( | `needs_tooling` | Code-checkable, but no off-the-shelf tool digs it out — we author a detector or use the grounded surface check | | `not_code_checkable` | A design/process property — out of static-scan scope | -For the **CRA** framework (40 controls) the split is **21 covered · 0 needs_tooling · 19 not_code_checkable**. The originally uncovered controls were resolved as a hybrid: +For the **CRA** framework (40 controls) the split is **21 covered · 0 needs_tooling · 19 not_code_checkable**. Every semgrep binding names our own rules only: the Semgrep registry rules are not run (their licence allows internal use only, not a service for others), so a binding covers exactly the languages its rules are written for. The originally uncovered controls were resolved as a hybrid: - **Custom semgrep detectors**, shipped in the binary and matched back to controls **by rule id** so a broad CWE can't over-attribute: - - for Python and JavaScript/TypeScript: `cra-ai-1`, `7`, `10`, `14` (secure-by-default, weak password hashing, insecure session cookies, weak data-at-rest ciphers); + - for Python and JavaScript/TypeScript: `cra-ai-1`, `7`, `10`, `14` (secure-by-default, weak password hashing, insecure session cookies, weak data-at-rest ciphers), `cra-ai-20` (shell commands and SQL built from variables, request input echoed into a response), `cra-ai-8` (hard-coded credentials, Python) and `cra-ai-15` (plain `http://` requests); - for C and C++ firmware: `cra-ai-8`, `13`, `16`, `20` (hard-coded credentials including `#define` macros, broken hash/cipher, `rand()`, unbounded string functions and non-literal format strings), next to cppcheck for memory safety. - **8 grounded surface checks** (`cra-ai-6`, `11`, `12`, `24`, `27`, `28`, `29`, `30`): the absence-based controls (no rate limiting, no security logging, no update-signature check…) that have no syntactic pattern. - **Marked not_code_checkable** (`cra-ai-2`, `3`, `4`, `5`, among the 19): minimal attack surface, secure architecture, least privilege, tamper protection. diff --git a/docs/guide/scanning.md b/docs/guide/scanning.md index dd04f68..d1d899d 100644 --- a/docs/guide/scanning.md +++ b/docs/guide/scanning.md @@ -16,8 +16,9 @@ names while the scan runs. - *Archiv entpacken* -- for an uploaded archive instead of a repository. - *Projekttyp bestimmen* -- firmware, PLC project, backend service, and so on. - *Firmware analysieren* -- for firmware, lists the libraries and toolchain the build uses. -2. **Static code analysis** (*Statische Codeanalyse*) -- Semgrep over the whole - tree; for C and C++ also cppcheck, which follows values through the code +2. **Static code analysis** (*Statische Codeanalyse*) -- Semgrep with + Prüfwerk's own rules (Python, JavaScript/TypeScript, C and C++; see + [Tools](/reference/tools)); for C and C++ also cppcheck, which follows values through the code (out-of-bounds writes, uninitialised reads, null dereferences). Vendor and third-party code (HAL, CMSIS, vendored libraries) is left out of the code findings and listed under **Nicht ausgeführt**; it stays in the SBOM. diff --git a/docs/reference/tools.md b/docs/reference/tools.md index 77d8bd6..61f086c 100644 --- a/docs/reference/tools.md +++ b/docs/reference/tools.md @@ -4,11 +4,24 @@ Prüfwerk uses a combination of open-source scanners and AI-powered analysis to ## Semgrep -- Static Analysis (SAST) -[Semgrep](https://semgrep.dev/) is an open-source static analysis tool that finds vulnerabilities by matching patterns in source code. It supports many languages and has an extensive rule library. +[Semgrep](https://semgrep.dev/) is an open-source static analysis engine (LGPL-2.1) that finds vulnerabilities by matching patterns in source code. -Prüfwerk runs Semgrep with its public `auto` ruleset plus its own CRA rules -for controls no off-the-shelf rule covers (secure defaults, weak password -hashing, insecure session cookies, weak ciphers for data at rest). +Prüfwerk runs the engine with **its own CRA rules only**: + +- Python and JavaScript/TypeScript: secure defaults, weak password hashing, + insecure session cookies, weak ciphers for data at rest, shell commands and + SQL statements built from variables, request input echoed into a response, + plain `http://` requests, and (Python) hard-coded credentials. +- C and C++: unbounded string functions, non-literal format strings, + hard-coded credentials, broken hashes and ciphers, `rand()` for security. + +The rules of the Semgrep registry (`--config=auto`, `p/...`) are not used: +their licence (Semgrep Rules License v1.0) allows internal use only, not a +service offered to others, and `auto` cannot run without sending metrics to +Semgrep. Semgrep runs with `--metrics=off` and no version check, so nothing +about your code leaves the scan. Code in other languages gets no Semgrep +findings; the CRA view says so (*Keine Prüfregel für den gefundenen Code*) +instead of reporting it as clean. Semgrep produces **Codeanalyse (SAST)** findings with file paths, line numbers, and rule descriptions. diff --git a/fixtures/nightly/baselines/archive-order-intake-tgz.json b/fixtures/nightly/baselines/archive-order-intake-tgz.json index 160ec30..bc0652b 100644 --- a/fixtures/nightly/baselines/archive-order-intake-tgz.json +++ b/fixtures/nightly/baselines/archive-order-intake-tgz.json @@ -9,6 +9,9 @@ "findings": [ "gitleaks:github-pat service.env:5", "gitleaks:slack-bot-token service.env:6", + "semgrep:cra-ai-20-node-reflected-input server.js:15", + "semgrep:cra-ai-20-node-shell-command server.js:10", + "semgrep:cra-ai-20-python-shell-command auth.py:15", "semgrep:cra-ai-7-weak-password-hash auth.py:9" ], "cves": [ @@ -20,13 +23,5 @@ "GHSA-vh95-rmgr-6w4m", "GHSA-xvch-5gv4-984h", "GHSA-xxjr-mmjv-4gpg" - ], - "registry_rules": [ - "generic.secrets.security.detected-github-token.detected-github-token", - "javascript.express.security.audit.express-check-csurf-middleware-usage.express-check-csurf-middleware-usage", - "javascript.express.security.audit.xss.direct-response-write.direct-response-write", - "javascript.express.security.injection.raw-html-format.raw-html-format", - "javascript.lang.security.detect-child-process.detect-child-process", - "python.lang.security.audit.subprocess-shell-true.subprocess-shell-true" ] } diff --git a/fixtures/nightly/baselines/archive-order-intake.json b/fixtures/nightly/baselines/archive-order-intake.json index 160ec30..bc0652b 100644 --- a/fixtures/nightly/baselines/archive-order-intake.json +++ b/fixtures/nightly/baselines/archive-order-intake.json @@ -9,6 +9,9 @@ "findings": [ "gitleaks:github-pat service.env:5", "gitleaks:slack-bot-token service.env:6", + "semgrep:cra-ai-20-node-reflected-input server.js:15", + "semgrep:cra-ai-20-node-shell-command server.js:10", + "semgrep:cra-ai-20-python-shell-command auth.py:15", "semgrep:cra-ai-7-weak-password-hash auth.py:9" ], "cves": [ @@ -20,13 +23,5 @@ "GHSA-vh95-rmgr-6w4m", "GHSA-xvch-5gv4-984h", "GHSA-xxjr-mmjv-4gpg" - ], - "registry_rules": [ - "generic.secrets.security.detected-github-token.detected-github-token", - "javascript.express.security.audit.express-check-csurf-middleware-usage.express-check-csurf-middleware-usage", - "javascript.express.security.audit.xss.direct-response-write.direct-response-write", - "javascript.express.security.injection.raw-html-format.raw-html-format", - "javascript.lang.security.detect-child-process.detect-child-process", - "python.lang.security.audit.subprocess-shell-true.subprocess-shell-true" ] } diff --git a/fixtures/nightly/baselines/firmware-zephyr-example.json b/fixtures/nightly/baselines/firmware-zephyr-example.json index 0203aa7..fe6b0bb 100644 --- a/fixtures/nightly/baselines/firmware-zephyr-example.json +++ b/fixtures/nightly/baselines/firmware-zephyr-example.json @@ -17,6 +17,5 @@ "toolchain:zephyr-sdk@" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-arduino.json b/fixtures/nightly/baselines/fw-arduino.json index 4dce252..285ffc5 100644 --- a/fixtures/nightly/baselines/fw-arduino.json +++ b/fixtures/nightly/baselines/fw-arduino.json @@ -5,6 +5,5 @@ "toolchain:arduino-cli@" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-c-sensor-node.json b/fixtures/nightly/baselines/fw-c-sensor-node.json index 788a0a5..b2eb69d 100644 --- a/fixtures/nightly/baselines/fw-c-sensor-node.json +++ b/fixtures/nightly/baselines/fw-c-sensor-node.json @@ -22,6 +22,5 @@ "semgrep:cra-ai-8-c-hardcoded-credential comms.c:9", "semgrep:cra-ai-8-c-hardcoded-credential net_config.h:7" ], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-cargo-embedded.json b/fixtures/nightly/baselines/fw-cargo-embedded.json index b00fb12..566c2f7 100644 --- a/fixtures/nightly/baselines/fw-cargo-embedded.json +++ b/fixtures/nightly/baselines/fw-cargo-embedded.json @@ -7,6 +7,5 @@ "toolchain:rustc@1.82.0" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-cmake.json b/fixtures/nightly/baselines/fw-cmake.json index 2f6a7ee..d24f193 100644 --- a/fixtures/nightly/baselines/fw-cmake.json +++ b/fixtures/nightly/baselines/fw-cmake.json @@ -5,6 +5,5 @@ "toolchain:arm-none-eabi-gcc@" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-embedded-libs.json b/fixtures/nightly/baselines/fw-embedded-libs.json index f4eb264..220ca63 100644 --- a/fixtures/nightly/baselines/fw-embedded-libs.json +++ b/fixtures/nightly/baselines/fw-embedded-libs.json @@ -78,6 +78,5 @@ "CVE-2026-77235", "CVE-2026-77236", "CVE-2026-77237" - ], - "registry_rules": [] + ] } diff --git a/fixtures/nightly/baselines/fw-espidf.json b/fixtures/nightly/baselines/fw-espidf.json index 745f597..27f3e55 100644 --- a/fixtures/nightly/baselines/fw-espidf.json +++ b/fixtures/nightly/baselines/fw-espidf.json @@ -8,6 +8,5 @@ "toolchain:esp-idf-toolchain@" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-freertos-cmake.json b/fixtures/nightly/baselines/fw-freertos-cmake.json index 6a62dd6..11a26f5 100644 --- a/fixtures/nightly/baselines/fw-freertos-cmake.json +++ b/fixtures/nightly/baselines/fw-freertos-cmake.json @@ -6,6 +6,5 @@ "toolchain:arm-none-eabi-gcc@" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-freertos-lostbuild.json b/fixtures/nightly/baselines/fw-freertos-lostbuild.json index af8bc05..77ad58b 100644 --- a/fixtures/nightly/baselines/fw-freertos-lostbuild.json +++ b/fixtures/nightly/baselines/fw-freertos-lostbuild.json @@ -8,6 +8,5 @@ "toolchain:arm-none-eabi-gcc@" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-make-onboarded-as-service.json b/fixtures/nightly/baselines/fw-make-onboarded-as-service.json index 2f6a7ee..d24f193 100644 --- a/fixtures/nightly/baselines/fw-make-onboarded-as-service.json +++ b/fixtures/nightly/baselines/fw-make-onboarded-as-service.json @@ -5,6 +5,5 @@ "toolchain:arm-none-eabi-gcc@" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-make.json b/fixtures/nightly/baselines/fw-make.json index 2f6a7ee..d24f193 100644 --- a/fixtures/nightly/baselines/fw-make.json +++ b/fixtures/nightly/baselines/fw-make.json @@ -5,6 +5,5 @@ "toolchain:arm-none-eabi-gcc@" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-platformio.json b/fixtures/nightly/baselines/fw-platformio.json index a74f99d..5ac539c 100644 --- a/fixtures/nightly/baselines/fw-platformio.json +++ b/fixtures/nightly/baselines/fw-platformio.json @@ -7,6 +7,5 @@ "library:knolleary/PubSubClient@2.8" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-yocto-layer.json b/fixtures/nightly/baselines/fw-yocto-layer.json index c3201d9..795f5ee 100644 --- a/fixtures/nightly/baselines/fw-yocto-layer.json +++ b/fixtures/nightly/baselines/fw-yocto-layer.json @@ -5,6 +5,5 @@ ], "sbom": [], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-zephyr-example-pinned.json b/fixtures/nightly/baselines/fw-zephyr-example-pinned.json index 0203aa7..fe6b0bb 100644 --- a/fixtures/nightly/baselines/fw-zephyr-example-pinned.json +++ b/fixtures/nightly/baselines/fw-zephyr-example-pinned.json @@ -17,6 +17,5 @@ "toolchain:zephyr-sdk@" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/fw-zephyr-pinned.json b/fixtures/nightly/baselines/fw-zephyr-pinned.json index 527b667..18e8a93 100644 --- a/fixtures/nightly/baselines/fw-zephyr-pinned.json +++ b/fixtures/nightly/baselines/fw-zephyr-pinned.json @@ -9,6 +9,5 @@ "toolchain:zephyr-sdk@" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/git-cra-vuln-demo.json b/fixtures/nightly/baselines/git-cra-vuln-demo.json index 9b09cd1..6ec41c0 100644 --- a/fixtures/nightly/baselines/git-cra-vuln-demo.json +++ b/fixtures/nightly/baselines/git-cra-vuln-demo.json @@ -4,13 +4,12 @@ "sbom": [], "findings": [ "gitleaks:stripe-access-token auth.py:2", - "semgrep:cra-ai-14-python-weak-cipher crypto.py:8" + "semgrep:cra-ai-14-python-weak-cipher crypto.py:8", + "semgrep:cra-ai-15-python-cleartext-http net.py:4", + "semgrep:cra-ai-20-python-shell-command db.py:9", + "semgrep:cra-ai-20-python-sql-string db.py:5", + "semgrep:cra-ai-8-python-hardcoded-credential auth.py:2", + "semgrep:cra-ai-8-python-hardcoded-credential auth.py:3" ], - "cves": [], - "registry_rules": [ - "generic.secrets.security.detected-stripe-api-key.detected-stripe-api-key", - "python.lang.security.audit.insecure-transport.requests.request-with-http.request-with-http", - "python.pycryptodome.security.insecure-cipher-algorithm-des.insecure-cipher-algorithm-des", - "python.sqlalchemy.security.sqlalchemy-execute-raw-query.sqlalchemy-execute-raw-query" - ] + "cves": [] } diff --git a/fixtures/nightly/baselines/js-bun-binary.json b/fixtures/nightly/baselines/js-bun-binary.json index 3e52135..6a04c99 100644 --- a/fixtures/nightly/baselines/js-bun-binary.json +++ b/fixtures/nightly/baselines/js-bun-binary.json @@ -7,11 +7,8 @@ "findings": [ "gitleaks:generic-api-key session.ts:8", "gitleaks:npm-access-token .env.local:3", - "gitleaks:stripe-access-token .env.local:2" + "gitleaks:stripe-access-token .env.local:2", + "semgrep:cra-ai-20-node-shell-command cli.js:9" ], - "cves": [], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "generic.secrets.security.detected-stripe-api-key.detected-stripe-api-key" - ] + "cves": [] } diff --git a/fixtures/nightly/baselines/js-bun.json b/fixtures/nightly/baselines/js-bun.json index 48afffc..a38b21b 100644 --- a/fixtures/nightly/baselines/js-bun.json +++ b/fixtures/nightly/baselines/js-bun.json @@ -9,7 +9,8 @@ "findings": [ "gitleaks:generic-api-key session.ts:8", "gitleaks:npm-access-token .env.local:3", - "gitleaks:stripe-access-token .env.local:2" + "gitleaks:stripe-access-token .env.local:2", + "semgrep:cra-ai-20-node-reflected-input server.js:9" ], "cves": [ "GHSA-29mw-wpgm-hmr9", @@ -43,12 +44,5 @@ "GHSA-xhjh-pmcv-23jw", "GHSA-xx6v-rp6x-q39c", "GHSA-xxjr-mmjv-4gpg" - ], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "generic.secrets.security.detected-stripe-api-key.detected-stripe-api-key", - "javascript.express.security.audit.express-check-csurf-middleware-usage.express-check-csurf-middleware-usage", - "javascript.express.security.audit.xss.direct-response-write.direct-response-write", - "javascript.express.security.injection.raw-html-format.raw-html-format" ] } diff --git a/fixtures/nightly/baselines/js-no-lockfile.json b/fixtures/nightly/baselines/js-no-lockfile.json index 3e52135..6a04c99 100644 --- a/fixtures/nightly/baselines/js-no-lockfile.json +++ b/fixtures/nightly/baselines/js-no-lockfile.json @@ -7,11 +7,8 @@ "findings": [ "gitleaks:generic-api-key session.ts:8", "gitleaks:npm-access-token .env.local:3", - "gitleaks:stripe-access-token .env.local:2" + "gitleaks:stripe-access-token .env.local:2", + "semgrep:cra-ai-20-node-shell-command cli.js:9" ], - "cves": [], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "generic.secrets.security.detected-stripe-api-key.detected-stripe-api-key" - ] + "cves": [] } diff --git a/fixtures/nightly/baselines/js-npm-lock-v3.json b/fixtures/nightly/baselines/js-npm-lock-v3.json index 4b51abc..b55fac5 100644 --- a/fixtures/nightly/baselines/js-npm-lock-v3.json +++ b/fixtures/nightly/baselines/js-npm-lock-v3.json @@ -10,7 +10,8 @@ "findings": [ "gitleaks:generic-api-key session.ts:8", "gitleaks:npm-access-token .env.local:3", - "gitleaks:stripe-access-token .env.local:2" + "gitleaks:stripe-access-token .env.local:2", + "semgrep:cra-ai-20-node-reflected-input server.js:9" ], "cves": [ "GHSA-29mw-wpgm-hmr9", @@ -44,12 +45,5 @@ "GHSA-xhjh-pmcv-23jw", "GHSA-xx6v-rp6x-q39c", "GHSA-xxjr-mmjv-4gpg" - ], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "generic.secrets.security.detected-stripe-api-key.detected-stripe-api-key", - "javascript.express.security.audit.express-check-csurf-middleware-usage.express-check-csurf-middleware-usage", - "javascript.express.security.audit.xss.direct-response-write.direct-response-write", - "javascript.express.security.injection.raw-html-format.raw-html-format" ] } diff --git a/fixtures/nightly/baselines/js-pnpm.json b/fixtures/nightly/baselines/js-pnpm.json index 48afffc..a38b21b 100644 --- a/fixtures/nightly/baselines/js-pnpm.json +++ b/fixtures/nightly/baselines/js-pnpm.json @@ -9,7 +9,8 @@ "findings": [ "gitleaks:generic-api-key session.ts:8", "gitleaks:npm-access-token .env.local:3", - "gitleaks:stripe-access-token .env.local:2" + "gitleaks:stripe-access-token .env.local:2", + "semgrep:cra-ai-20-node-reflected-input server.js:9" ], "cves": [ "GHSA-29mw-wpgm-hmr9", @@ -43,12 +44,5 @@ "GHSA-xhjh-pmcv-23jw", "GHSA-xx6v-rp6x-q39c", "GHSA-xxjr-mmjv-4gpg" - ], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "generic.secrets.security.detected-stripe-api-key.detected-stripe-api-key", - "javascript.express.security.audit.express-check-csurf-middleware-usage.express-check-csurf-middleware-usage", - "javascript.express.security.audit.xss.direct-response-write.direct-response-write", - "javascript.express.security.injection.raw-html-format.raw-html-format" ] } diff --git a/fixtures/nightly/baselines/js-yarn-berry.json b/fixtures/nightly/baselines/js-yarn-berry.json index 619626c..a38b21b 100644 --- a/fixtures/nightly/baselines/js-yarn-berry.json +++ b/fixtures/nightly/baselines/js-yarn-berry.json @@ -9,7 +9,8 @@ "findings": [ "gitleaks:generic-api-key session.ts:8", "gitleaks:npm-access-token .env.local:3", - "gitleaks:stripe-access-token .env.local:2" + "gitleaks:stripe-access-token .env.local:2", + "semgrep:cra-ai-20-node-reflected-input server.js:9" ], "cves": [ "GHSA-29mw-wpgm-hmr9", @@ -43,13 +44,5 @@ "GHSA-xhjh-pmcv-23jw", "GHSA-xx6v-rp6x-q39c", "GHSA-xxjr-mmjv-4gpg" - ], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "generic.secrets.security.detected-stripe-api-key.detected-stripe-api-key", - "javascript.express.security.audit.express-check-csurf-middleware-usage.express-check-csurf-middleware-usage", - "javascript.express.security.audit.xss.direct-response-write.direct-response-write", - "javascript.express.security.injection.raw-html-format.raw-html-format", - "package_managers.yarn.yarn-missing-minimal-age-gate.yarn-missing-minimal-age-gate" ] } diff --git a/fixtures/nightly/baselines/js-yarn-classic.json b/fixtures/nightly/baselines/js-yarn-classic.json index 48afffc..a38b21b 100644 --- a/fixtures/nightly/baselines/js-yarn-classic.json +++ b/fixtures/nightly/baselines/js-yarn-classic.json @@ -9,7 +9,8 @@ "findings": [ "gitleaks:generic-api-key session.ts:8", "gitleaks:npm-access-token .env.local:3", - "gitleaks:stripe-access-token .env.local:2" + "gitleaks:stripe-access-token .env.local:2", + "semgrep:cra-ai-20-node-reflected-input server.js:9" ], "cves": [ "GHSA-29mw-wpgm-hmr9", @@ -43,12 +44,5 @@ "GHSA-xhjh-pmcv-23jw", "GHSA-xx6v-rp6x-q39c", "GHSA-xxjr-mmjv-4gpg" - ], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "generic.secrets.security.detected-stripe-api-key.detected-stripe-api-key", - "javascript.express.security.audit.express-check-csurf-middleware-usage.express-check-csurf-middleware-usage", - "javascript.express.security.audit.xss.direct-response-write.direct-response-write", - "javascript.express.security.injection.raw-html-format.raw-html-format" ] } diff --git a/fixtures/nightly/baselines/mobile-android-gradle-catalog.json b/fixtures/nightly/baselines/mobile-android-gradle-catalog.json index dcaf40e..c18f738 100644 --- a/fixtures/nightly/baselines/mobile-android-gradle-catalog.json +++ b/fixtures/nightly/baselines/mobile-android-gradle-catalog.json @@ -5,6 +5,5 @@ ], "sbom": [], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/mobile-android-gradle-lock.json b/fixtures/nightly/baselines/mobile-android-gradle-lock.json index 1092d79..a7ce391 100644 --- a/fixtures/nightly/baselines/mobile-android-gradle-lock.json +++ b/fixtures/nightly/baselines/mobile-android-gradle-lock.json @@ -11,6 +11,5 @@ "GHSA-3cqm-mf7h-prrj", "GHSA-4jrv-ppp4-jm57", "GHSA-w33c-445m-f8w7" - ], - "registry_rules": [] + ] } diff --git a/fixtures/nightly/baselines/mobile-flutter.json b/fixtures/nightly/baselines/mobile-flutter.json index de02fd2..a4eff81 100644 --- a/fixtures/nightly/baselines/mobile-flutter.json +++ b/fixtures/nightly/baselines/mobile-flutter.json @@ -10,6 +10,5 @@ "findings": [], "cves": [ "GHSA-9324-jv53-9cc8" - ], - "registry_rules": [] + ] } diff --git a/fixtures/nightly/baselines/mobile-ios-cocoapods.json b/fixtures/nightly/baselines/mobile-ios-cocoapods.json index 27c868c..3b24239 100644 --- a/fixtures/nightly/baselines/mobile-ios-cocoapods.json +++ b/fixtures/nightly/baselines/mobile-ios-cocoapods.json @@ -8,6 +8,5 @@ "cocoapods:AFNetworking@2.5.1" ], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/mobile-ios-spm-unlocked.json b/fixtures/nightly/baselines/mobile-ios-spm-unlocked.json index dcaf40e..c18f738 100644 --- a/fixtures/nightly/baselines/mobile-ios-spm-unlocked.json +++ b/fixtures/nightly/baselines/mobile-ios-spm-unlocked.json @@ -5,6 +5,5 @@ ], "sbom": [], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/mobile-ios-spm-xcode.json b/fixtures/nightly/baselines/mobile-ios-spm-xcode.json index 37931e4..9e1cecf 100644 --- a/fixtures/nightly/baselines/mobile-ios-spm-xcode.json +++ b/fixtures/nightly/baselines/mobile-ios-spm-xcode.json @@ -13,6 +13,5 @@ "GHSA-qppj-fm5r-hxr3", "GHSA-w3f6-pc54-gfw7", "GHSA-xvr7-p2c6-j83w" - ], - "registry_rules": [] + ] } diff --git a/fixtures/nightly/baselines/mobile-react-native.json b/fixtures/nightly/baselines/mobile-react-native.json index cc01e07..6bedbdd 100644 --- a/fixtures/nightly/baselines/mobile-react-native.json +++ b/fixtures/nightly/baselines/mobile-react-native.json @@ -42,6 +42,5 @@ "GHSA-xhjh-pmcv-23jw", "GHSA-xx6v-rp6x-q39c", "GHSA-xxjr-mmjv-4gpg" - ], - "registry_rules": [] + ] } diff --git a/fixtures/nightly/baselines/plc-codesys-proemion.json b/fixtures/nightly/baselines/plc-codesys-proemion.json index 01b59d5..a7495cb 100644 --- a/fixtures/nightly/baselines/plc-codesys-proemion.json +++ b/fixtures/nightly/baselines/plc-codesys-proemion.json @@ -44,6 +44,5 @@ "cves": [ "CVE-2022-4046", "CVE-2025-41738" - ], - "registry_rules": [] + ] } diff --git a/fixtures/nightly/baselines/plc-codesys-synthetic.json b/fixtures/nightly/baselines/plc-codesys-synthetic.json index 1bbf3a1..5fc718a 100644 --- a/fixtures/nightly/baselines/plc-codesys-synthetic.json +++ b/fixtures/nightly/baselines/plc-codesys-synthetic.json @@ -81,6 +81,5 @@ "CVE-2026-0393", "CVE-2026-44468", "CVE-2026-44469" - ], - "registry_rules": [] + ] } diff --git a/fixtures/nightly/baselines/plc-conveyor-line.json b/fixtures/nightly/baselines/plc-conveyor-line.json index 48a18f2..af168ef 100644 --- a/fixtures/nightly/baselines/plc-conveyor-line.json +++ b/fixtures/nightly/baselines/plc-conveyor-line.json @@ -12,6 +12,5 @@ "plc-control-logic:plc-insecure-protocol-port traffic_light.st:45", "plc-control-logic:plc-safety-bypass traffic_light.st:59" ], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/plc-corrupt-archive.json b/fixtures/nightly/baselines/plc-corrupt-archive.json index 12ce802..43e8bf8 100644 --- a/fixtures/nightly/baselines/plc-corrupt-archive.json +++ b/fixtures/nightly/baselines/plc-corrupt-archive.json @@ -5,6 +5,5 @@ ], "sbom": [], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/plc-ladder.json b/fixtures/nightly/baselines/plc-ladder.json index 4aa67dd..77c7523 100644 --- a/fixtures/nightly/baselines/plc-ladder.json +++ b/fixtures/nightly/baselines/plc-ladder.json @@ -8,6 +8,5 @@ "plc-control-logic:plc-insecure-protocol-port mixer_ld.xml:7", "plc-control-logic:plc-insecure-protocol-port mixer_ld.xml:8" ], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/plc-live-endpoint.json b/fixtures/nightly/baselines/plc-live-endpoint.json index 91b0c49..0b0fe6f 100644 --- a/fixtures/nightly/baselines/plc-live-endpoint.json +++ b/fixtures/nightly/baselines/plc-live-endpoint.json @@ -10,6 +10,5 @@ "plc-control-logic:plc-insecure-protocol-port traffic_light.st:45", "plc-control-logic:plc-safety-bypass traffic_light.st:59" ], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/plc-pump-station.json b/fixtures/nightly/baselines/plc-pump-station.json index b1b7377..8740aaa 100644 --- a/fixtures/nightly/baselines/plc-pump-station.json +++ b/fixtures/nightly/baselines/plc-pump-station.json @@ -20,6 +20,5 @@ "plc-control-logic:plc-safety-bypass pump_station.st:37", "plc-control-logic:plc-unstructured-jump pump_station.st:45" ], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/py-bare-pyproject.json b/fixtures/nightly/baselines/py-bare-pyproject.json index 188fd29..dbf61b6 100644 --- a/fixtures/nightly/baselines/py-bare-pyproject.json +++ b/fixtures/nightly/baselines/py-bare-pyproject.json @@ -9,16 +9,10 @@ "gitleaks:gitlab-pat service.env:4", "ruff:E722 app.py:45", "ruff:F401 app.py:4", - "semgrep:cra-ai-1-tls-verify-disabled auth.py:12" + "semgrep:cra-ai-1-tls-verify-disabled auth.py:12", + "semgrep:cra-ai-20-python-shell-command app.py:32", + "semgrep:cra-ai-20-python-unsafe-deserialization app.py:16", + "semgrep:cra-ai-8-python-hardcoded-credential auth.py:7" ], - "cves": [], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "python.flask.security.injection.subprocess-injection.subprocess-injection", - "python.flask.security.insecure-deserialization.insecure-deserialization", - "python.lang.security.audit.subprocess-shell-true.subprocess-shell-true", - "python.lang.security.dangerous-subprocess-use.dangerous-subprocess-use", - "python.lang.security.deserialization.avoid-pyyaml-load.avoid-pyyaml-load", - "python.requests.security.disabled-cert-validation.disabled-cert-validation" - ] + "cves": [] } diff --git a/fixtures/nightly/baselines/py-pipenv.json b/fixtures/nightly/baselines/py-pipenv.json index 286b0ee..c828b79 100644 --- a/fixtures/nightly/baselines/py-pipenv.json +++ b/fixtures/nightly/baselines/py-pipenv.json @@ -10,7 +10,10 @@ "findings": [ "gitleaks:generic-api-key auth.py:7", "gitleaks:gitlab-pat service.env:4", - "semgrep:cra-ai-1-tls-verify-disabled auth.py:12" + "semgrep:cra-ai-1-tls-verify-disabled auth.py:12", + "semgrep:cra-ai-20-python-shell-command app.py:32", + "semgrep:cra-ai-20-python-unsafe-deserialization app.py:16", + "semgrep:cra-ai-8-python-hardcoded-credential auth.py:7" ], "cves": [ "GHSA-2xpw-w6gg-jr37", @@ -37,6 +40,7 @@ "GHSA-qccp-gfcp-xxvc", "GHSA-r64q-w8jr-g9qp", "GHSA-v845-jxx5-vc9f", + "GHSA-vxq7-64xx-v4gw", "GHSA-wqvq-5m8c-6g24", "GHSA-x84v-xcm2-53pg", "PYSEC-2018-28", @@ -65,14 +69,5 @@ "PYSEC-2026-1998", "PYSEC-2026-1999", "PYSEC-2026-2275" - ], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "python.flask.security.injection.subprocess-injection.subprocess-injection", - "python.flask.security.insecure-deserialization.insecure-deserialization", - "python.lang.security.audit.subprocess-shell-true.subprocess-shell-true", - "python.lang.security.dangerous-subprocess-use.dangerous-subprocess-use", - "python.lang.security.deserialization.avoid-pyyaml-load.avoid-pyyaml-load", - "python.requests.security.disabled-cert-validation.disabled-cert-validation" ] } diff --git a/fixtures/nightly/baselines/py-poetry.json b/fixtures/nightly/baselines/py-poetry.json index 7fd27b3..d19b1f8 100644 --- a/fixtures/nightly/baselines/py-poetry.json +++ b/fixtures/nightly/baselines/py-poetry.json @@ -12,7 +12,10 @@ "gitleaks:gitlab-pat service.env:4", "ruff:E722 app.py:45", "ruff:F401 app.py:4", - "semgrep:cra-ai-1-tls-verify-disabled auth.py:12" + "semgrep:cra-ai-1-tls-verify-disabled auth.py:12", + "semgrep:cra-ai-20-python-shell-command app.py:32", + "semgrep:cra-ai-20-python-unsafe-deserialization app.py:16", + "semgrep:cra-ai-8-python-hardcoded-credential auth.py:7" ], "cves": [ "GHSA-2xpw-w6gg-jr37", @@ -39,6 +42,7 @@ "GHSA-qccp-gfcp-xxvc", "GHSA-r64q-w8jr-g9qp", "GHSA-v845-jxx5-vc9f", + "GHSA-vxq7-64xx-v4gw", "GHSA-wqvq-5m8c-6g24", "GHSA-x84v-xcm2-53pg", "PYSEC-2018-28", @@ -67,14 +71,5 @@ "PYSEC-2026-1998", "PYSEC-2026-1999", "PYSEC-2026-2275" - ], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "python.flask.security.injection.subprocess-injection.subprocess-injection", - "python.flask.security.insecure-deserialization.insecure-deserialization", - "python.lang.security.audit.subprocess-shell-true.subprocess-shell-true", - "python.lang.security.dangerous-subprocess-use.dangerous-subprocess-use", - "python.lang.security.deserialization.avoid-pyyaml-load.avoid-pyyaml-load", - "python.requests.security.disabled-cert-validation.disabled-cert-validation" ] } diff --git a/fixtures/nightly/baselines/py-requirements.json b/fixtures/nightly/baselines/py-requirements.json index 7fd27b3..d19b1f8 100644 --- a/fixtures/nightly/baselines/py-requirements.json +++ b/fixtures/nightly/baselines/py-requirements.json @@ -12,7 +12,10 @@ "gitleaks:gitlab-pat service.env:4", "ruff:E722 app.py:45", "ruff:F401 app.py:4", - "semgrep:cra-ai-1-tls-verify-disabled auth.py:12" + "semgrep:cra-ai-1-tls-verify-disabled auth.py:12", + "semgrep:cra-ai-20-python-shell-command app.py:32", + "semgrep:cra-ai-20-python-unsafe-deserialization app.py:16", + "semgrep:cra-ai-8-python-hardcoded-credential auth.py:7" ], "cves": [ "GHSA-2xpw-w6gg-jr37", @@ -39,6 +42,7 @@ "GHSA-qccp-gfcp-xxvc", "GHSA-r64q-w8jr-g9qp", "GHSA-v845-jxx5-vc9f", + "GHSA-vxq7-64xx-v4gw", "GHSA-wqvq-5m8c-6g24", "GHSA-x84v-xcm2-53pg", "PYSEC-2018-28", @@ -67,14 +71,5 @@ "PYSEC-2026-1998", "PYSEC-2026-1999", "PYSEC-2026-2275" - ], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "python.flask.security.injection.subprocess-injection.subprocess-injection", - "python.flask.security.insecure-deserialization.insecure-deserialization", - "python.lang.security.audit.subprocess-shell-true.subprocess-shell-true", - "python.lang.security.dangerous-subprocess-use.dangerous-subprocess-use", - "python.lang.security.deserialization.avoid-pyyaml-load.avoid-pyyaml-load", - "python.requests.security.disabled-cert-validation.disabled-cert-validation" ] } diff --git a/fixtures/nightly/baselines/py-uv.json b/fixtures/nightly/baselines/py-uv.json index 7fd27b3..d19b1f8 100644 --- a/fixtures/nightly/baselines/py-uv.json +++ b/fixtures/nightly/baselines/py-uv.json @@ -12,7 +12,10 @@ "gitleaks:gitlab-pat service.env:4", "ruff:E722 app.py:45", "ruff:F401 app.py:4", - "semgrep:cra-ai-1-tls-verify-disabled auth.py:12" + "semgrep:cra-ai-1-tls-verify-disabled auth.py:12", + "semgrep:cra-ai-20-python-shell-command app.py:32", + "semgrep:cra-ai-20-python-unsafe-deserialization app.py:16", + "semgrep:cra-ai-8-python-hardcoded-credential auth.py:7" ], "cves": [ "GHSA-2xpw-w6gg-jr37", @@ -39,6 +42,7 @@ "GHSA-qccp-gfcp-xxvc", "GHSA-r64q-w8jr-g9qp", "GHSA-v845-jxx5-vc9f", + "GHSA-vxq7-64xx-v4gw", "GHSA-wqvq-5m8c-6g24", "GHSA-x84v-xcm2-53pg", "PYSEC-2018-28", @@ -67,14 +71,5 @@ "PYSEC-2026-1998", "PYSEC-2026-1999", "PYSEC-2026-2275" - ], - "registry_rules": [ - "generic.secrets.security.detected-generic-secret.detected-generic-secret", - "python.flask.security.injection.subprocess-injection.subprocess-injection", - "python.flask.security.insecure-deserialization.insecure-deserialization", - "python.lang.security.audit.subprocess-shell-true.subprocess-shell-true", - "python.lang.security.dangerous-subprocess-use.dangerous-subprocess-use", - "python.lang.security.deserialization.avoid-pyyaml-load.avoid-pyyaml-load", - "python.requests.security.disabled-cert-validation.disabled-cert-validation" ] } diff --git a/fixtures/nightly/baselines/unscanned-container-image.json b/fixtures/nightly/baselines/unscanned-container-image.json index f50bc62..b0d058f 100644 --- a/fixtures/nightly/baselines/unscanned-container-image.json +++ b/fixtures/nightly/baselines/unscanned-container-image.json @@ -5,6 +5,5 @@ ], "sbom": [], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/unscanned-firmware-image.json b/fixtures/nightly/baselines/unscanned-firmware-image.json index ab70d4e..d43cb22 100644 --- a/fixtures/nightly/baselines/unscanned-firmware-image.json +++ b/fixtures/nightly/baselines/unscanned-firmware-image.json @@ -7,6 +7,5 @@ ], "sbom": [], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/baselines/unscanned-mobile-package.json b/fixtures/nightly/baselines/unscanned-mobile-package.json index bf13955..e8b5577 100644 --- a/fixtures/nightly/baselines/unscanned-mobile-package.json +++ b/fixtures/nightly/baselines/unscanned-mobile-package.json @@ -5,6 +5,5 @@ ], "sbom": [], "findings": [], - "cves": [], - "registry_rules": [] + "cves": [] } diff --git a/fixtures/nightly/targets.json b/fixtures/nightly/targets.json index 93e5268..87d116e 100644 --- a/fixtures/nightly/targets.json +++ b/fixtures/nightly/targets.json @@ -339,8 +339,8 @@ "sast_rule_ids": [ "github-pat", "slack-bot-token", - "python.lang.security.audit.subprocess-shell-true.subprocess-shell-true", - "javascript.lang.security.detect-child-process.detect-child-process" + "cra-ai-20-python-shell-command", + "cra-ai-20-node-shell-command" ] } }, @@ -361,8 +361,8 @@ "sast_rule_ids": [ "github-pat", "slack-bot-token", - "python.lang.security.audit.subprocess-shell-true.subprocess-shell-true", - "javascript.lang.security.detect-child-process.detect-child-process" + "cra-ai-20-python-shell-command", + "cra-ai-20-node-shell-command" ] } },