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
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:
1 parent
98be82c0d0
commit
246e2c4ac5
3 files changed
+40
-3
No files matched your search
+27
-3
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user