feat(control-map): a missing Content-Security-Policy is evidence for cra-ai-1 (#998) (#1011)
CI / Check (push) Skipped
CI / Agent integration (push) Skipped
CI / Detect Changes (push) Successful in 3s
CI / Deploy Dashboard (push) Skipped
CI / Deploy MCP (push) Skipped
CI / Deploy Docs (push) Successful in 1m9s
CI / Deploy Agent (push) Successful in 6m12s

This commit was merged in pull request #1011.
This commit is contained in:
sharang committed 2026-11-16 11:57:55 +00:00
1 parent 98be82c0d0
commit 246e2c4ac5
3 files changed
+40 -3

No files matched your search

+12
View File
@@ -137,6 +137,18 @@
"yocto-local-conf-no-security-flags"
],
"check": "The image's shipped configuration must be secure by default: an sshd_config that permits root or password logins, or a distro built without security_flags.inc (stack protector, FORTIFY_SOURCE, PIE, RELRO), violates it."
},
{
"tool": "dast",
"scan_type": "dast",
"languages": [],
"cwe": [
"CWE-16",
"CWE-693"
],
"rules": [],
"check": "The running application leaves a browser protection off by default: a missing or weak Content-Security-Policy or another missing security header on what it serves.",
"attach_only": true
}
],
"note": null,
+27 -3
View File
@@ -231,6 +231,29 @@ mod tests {
assert!(map.controls_for_cwe("CWE-0").is_empty());
}
#[test]
fn a_missing_content_security_policy_is_evidence_for_secure_defaults() {
// DAST reports a missing CSP as CWE-16 and a missing protection
// mechanism as CWE-693 (#998). Neither makes the control count as
// checked: the DAST checks look at what one URL serves.
let map = ControlMap::cra().expect("map");
for cwe in ["CWE-16", "CWE-693"] {
let ids: Vec<&str> = map
.controls_for_cwe(cwe)
.iter()
.map(|c| c.control.as_str())
.collect();
assert_eq!(ids, ["cra-ai-1"], "{cwe}");
}
let dast = map
.coverage("cra-ai-1")
.and_then(|c| c.scans.iter().find(|s| s.tool == "dast"))
.expect("a dast binding");
assert!(dast.attach_only);
// So the CRA status never reads "checked" because of it.
assert!(!dast.applies_to(&["python".to_string()]));
}
#[test]
fn cra_map_loads_all_40_controls() {
let map = ControlMap::cra().expect("CRA map should parse");
@@ -306,14 +329,15 @@ mod tests {
#[test]
fn every_code_binding_names_its_languages() {
// Only tools that do not read source code may be language-independent;
// a rule binding without languages would claim every language.
// Only tools that do not read source code may be language-independent
// (DAST tests the running application); a rule binding without
// languages would claim every language.
let map = ControlMap::cra().expect("map");
for control in &map.controls {
for scan in &control.scans {
let reads_code = !matches!(
scan.tool.as_str(),
"gitleaks" | "secret-files" | "syft" | "osv" | "binary-inventory"
"gitleaks" | "secret-files" | "syft" | "osv" | "binary-inventory" | "dast"
);
assert_eq!(
reads_code,
+1
View File
@@ -36,6 +36,7 @@ For the **CRA** framework (40 controls) the split is **21 covered · 0 needs_too
- **mobsfscan** for Android and iOS apps, bound **by CWE** (a mobsfscan binding only ever attaches mobsfscan findings): `cra-ai-1` (debuggable, exported components, outdated `minSdkVersion`), `7`, `8`, `9`, `13`, `14`, `15` (cleartext, TLS, App Transport Security), `16` and `20`. Each binding lists only the languages mobsfscan has rules for under those CWEs, so `cra-ai-1` covers Java and Kotlin (its manifest checks) but not Swift.
- **DevSkim** for C# and VB.NET (#494), bound **by CWE** (each DevSkim rule gets its CWE in `pipeline/devskim.rs`; its SARIF carries none): `cra-ai-1` (tracing), `8`, `10` (cookies without Secure), `13`, `14` (DPAPI without entropy), `15`, `16` and `20` (deserialisation, XXE).
- **Yocto recipe lint** (oelint-adv and our `yocto-config` rules), bound **by rule id** with the language `bitbake`: `cra-ai-1` (debug and root-login image features, sshd root/password logins, a distro without `security_flags.inc`), `cra-ai-8` (empty-password image features, passwords in `EXTRA_USERS_PARAMS`) `cra-ai-6` (downloads without a checksum, `AUTOREV`, git tags) and `cra-ai-2` (network access in tasks, `http://` fetches). `cra-ai-2` stays not code-checkable; these are its only bindings, so the CRA status assesses it only where the scanned languages include `bitbake` (a Yocto layer tree), and shows it as not code-checkable everywhere else.
- **DAST** (#998), bound **by CWE** and `attach_only`: `cra-ai-1` for a missing or weak Content-Security-Policy (CWE-16) and a missing protection mechanism (CWE-693) on what the running application serves. The DAST checks look at one URL, so the binding attaches these findings to the control but never makes it count as checked. DAST findings with other CWEs get the controls any binding lists for their CWE.
- **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. A not-code-checkable control with a binding that applies to the scanned languages is assessed like a covered one there; today that is only `cra-ai-2` on Yocto layer trees.