feat(controls): the catalog's ratings, and a check text per binding (#381) (#399)
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Docs (push) Skipped
CI / Deploy MCP (push) Successful in 3m59s
CI / Deploy Dashboard (push) Successful in 5m48s
CI / Deploy Agent (push) Successful in 7m40s

This commit was merged in pull request #399.
This commit is contained in:
sharang committed 2026-09-25 19:10:10 +00:00
1 parent fdf22e99c0
commit 33394cc609
13 files changed
+261 -31

No files matched your search

+26 -13
View File
@@ -95,7 +95,8 @@
"cwe": [],
"rules": [
"cra-ai-7-weak-password-hash"
]
],
"check": "Passwords must be stored with a slow, salted password hash (bcrypt, scrypt, Argon2id, PBKDF2); a fast or unsalted hash (MD5, SHA-1, SHA-256) of a password violates it."
}
],
"note": null,
@@ -110,7 +111,8 @@
"scan_type": "secret_detection",
"languages": [],
"cwe": [],
"rules": []
"rules": [],
"check": "No credential (password, key, token) may be written into the product's source or configuration: every installation would ship the same secret."
},
{
"tool": "semgrep",
@@ -134,7 +136,8 @@
],
"rules": [
"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."
}
],
"note": null,
@@ -149,7 +152,8 @@
"scan_type": "secret_detection",
"languages": [],
"cwe": [],
"rules": []
"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",
@@ -169,7 +173,8 @@
"CWE-798",
"CWE-522"
],
"rules": []
"rules": [],
"check": "Credentials must not be kept or compared in plain text; a hard-coded or plain-text stored secret violates it."
}
],
"note": null,
@@ -191,7 +196,8 @@
"rules": [
"cra-ai-10-session-cookie-insecure",
"cra-ai-10-express-cookie-insecure"
]
],
"check": "Session cookies must be protected: set Secure and HttpOnly (and SameSite). A session cookie configured without them violates it."
}
],
"note": null,
@@ -279,7 +285,8 @@
],
"rules": [
"cra-ai-13-c-broken-hash-or-cipher"
]
],
"check": "Data must not be protected with a broken algorithm: MD5, SHA-1 or DES used for integrity or confidentiality violates it. A non-security use (a cache key, a checksum of public data) does not."
}
],
"note": null,
@@ -301,7 +308,8 @@
"rules": [
"cra-ai-14-python-weak-cipher",
"cra-ai-14-node-weak-cipher"
]
],
"check": "Stored data must be encrypted with a current cipher and mode (AES-GCM, ChaCha20-Poly1305); DES, RC4, ECB mode or a hard-coded key violates it."
}
],
"note": null,
@@ -329,7 +337,8 @@
"CWE-319",
"CWE-311"
],
"rules": []
"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."
}
],
"note": null,
@@ -344,7 +353,8 @@
"scan_type": "secret_detection",
"languages": [],
"cwe": [],
"rules": []
"rules": [],
"check": "Keys must not be committed to the source: a private key or secret key in the repository violates it."
},
{
"tool": "semgrep",
@@ -368,7 +378,8 @@
],
"rules": [
"cra-ai-16-c-predictable-random"
]
],
"check": "Keys, nonces, tokens and session ids must come from a cryptographically secure random source (the MCU's hardware RNG, a DRBG); rand() used for them violates it."
}
],
"note": null,
@@ -425,7 +436,8 @@
"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."
},
{
"tool": "cppcheck",
@@ -454,7 +466,8 @@
"CWE-787",
"CWE-788"
],
"rules": []
"rules": [],
"check": "The code must be free of memory-safety defects: out-of-bounds access, use of uninitialised memory, leaks, null dereferences and similar defects violate it."
}
],
"note": null,
+29 -7
View File
@@ -41,6 +41,11 @@ pub struct ScanBinding {
/// Optional specific rule ids this control keys on.
#[serde(default)]
pub rules: Vec<String>,
/// What a finding of this binding means for the control, for the judge.
/// The catalog's prose is written for the whole control ("SAST in the
/// CI/CD pipeline"); a buffer overflow is judged against this instead.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub check: Option<String>,
}
impl ScanBinding {
@@ -128,15 +133,32 @@ impl ControlMap {
cwe: Option<&str>,
rule_id: Option<&str>,
) -> Vec<&ControlEntry> {
self.bindings_for_finding(tool, cwe, rule_id)
.into_iter()
.map(|(control, _)| control)
.collect()
}
/// Like [`Self::controls_for_finding`], with the binding that matched each
/// control (for its [`ScanBinding::check`] text).
pub fn bindings_for_finding(
&self,
tool: &str,
cwe: Option<&str>,
rule_id: Option<&str>,
) -> Vec<(&ControlEntry, &ScanBinding)> {
self.controls
.iter()
.filter(|c| {
c.scans.iter().any(|s| {
s.tool == tool
&& (cwe.is_some_and(|w| s.cwe.iter().any(|x| x == w))
|| rule_id
.is_some_and(|r| s.rules.iter().any(|b| rule_id_matches(b, r))))
})
.filter_map(|c| {
c.scans
.iter()
.find(|s| {
s.tool == tool
&& (cwe.is_some_and(|w| s.cwe.iter().any(|x| x == w))
|| rule_id
.is_some_and(|r| s.rules.iter().any(|b| rule_id_matches(b, r))))
})
.map(|s| (c, s))
})
.collect()
}