fix(compliance): claim "no violation found" only where a rule checked the code (#368)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 7m30s
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 7m30s
The CRA status called every covered control clean once a scan had completed, even when none of its rules covers the scanned code (a C repo and Python-only rules). The scan run now records the source languages it saw outside vendor code, each control-map binding declares its languages, and a control is "no violation found" only if a binding applies; otherwise it is not assessed, with the reason. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
1 parent
5f7c947fb3
commit
dee24610f8
12 files changed
+631
-48
No files matched your search
@@ -9,6 +9,11 @@
|
||||
{
|
||||
"tool": "semgrep",
|
||||
"scan_type": "sast",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": [
|
||||
"cra-ai-1-flask-debug-enabled",
|
||||
@@ -56,6 +61,18 @@
|
||||
{
|
||||
"tool": "grounded-control-check",
|
||||
"scan_type": "code_review",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"go",
|
||||
"java",
|
||||
"ruby",
|
||||
"php",
|
||||
"rust",
|
||||
"csharp",
|
||||
"kotlin"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
}
|
||||
@@ -70,6 +87,9 @@
|
||||
{
|
||||
"tool": "semgrep",
|
||||
"scan_type": "sast",
|
||||
"languages": [
|
||||
"python"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": [
|
||||
"cra-ai-7-weak-password-hash"
|
||||
@@ -86,12 +106,25 @@
|
||||
{
|
||||
"tool": "gitleaks",
|
||||
"scan_type": "secret_detection",
|
||||
"languages": [],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
},
|
||||
{
|
||||
"tool": "semgrep",
|
||||
"scan_type": "sast",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"java",
|
||||
"go",
|
||||
"ruby",
|
||||
"php",
|
||||
"csharp",
|
||||
"kotlin",
|
||||
"c"
|
||||
],
|
||||
"cwe": [
|
||||
"CWE-798",
|
||||
"CWE-259"
|
||||
@@ -111,12 +144,24 @@
|
||||
{
|
||||
"tool": "gitleaks",
|
||||
"scan_type": "secret_detection",
|
||||
"languages": [],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
},
|
||||
{
|
||||
"tool": "semgrep",
|
||||
"scan_type": "sast",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"java",
|
||||
"go",
|
||||
"ruby",
|
||||
"php",
|
||||
"csharp",
|
||||
"kotlin"
|
||||
],
|
||||
"cwe": [
|
||||
"CWE-798",
|
||||
"CWE-522"
|
||||
@@ -134,6 +179,11 @@
|
||||
{
|
||||
"tool": "semgrep",
|
||||
"scan_type": "sast",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": [
|
||||
"cra-ai-10-session-cookie-insecure",
|
||||
@@ -151,6 +201,18 @@
|
||||
{
|
||||
"tool": "grounded-control-check",
|
||||
"scan_type": "code_review",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"go",
|
||||
"java",
|
||||
"ruby",
|
||||
"php",
|
||||
"rust",
|
||||
"csharp",
|
||||
"kotlin"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
}
|
||||
@@ -165,6 +227,18 @@
|
||||
{
|
||||
"tool": "grounded-control-check",
|
||||
"scan_type": "code_review",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"go",
|
||||
"java",
|
||||
"ruby",
|
||||
"php",
|
||||
"rust",
|
||||
"csharp",
|
||||
"kotlin"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
}
|
||||
@@ -179,6 +253,18 @@
|
||||
{
|
||||
"tool": "semgrep",
|
||||
"scan_type": "sast",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"java",
|
||||
"go",
|
||||
"ruby",
|
||||
"php",
|
||||
"csharp",
|
||||
"kotlin",
|
||||
"c"
|
||||
],
|
||||
"cwe": [
|
||||
"CWE-327",
|
||||
"CWE-326"
|
||||
@@ -198,6 +284,11 @@
|
||||
{
|
||||
"tool": "semgrep",
|
||||
"scan_type": "sast",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": [
|
||||
"cra-ai-14-python-weak-cipher",
|
||||
@@ -215,6 +306,17 @@
|
||||
{
|
||||
"tool": "semgrep",
|
||||
"scan_type": "sast",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"java",
|
||||
"go",
|
||||
"ruby",
|
||||
"php",
|
||||
"csharp",
|
||||
"kotlin"
|
||||
],
|
||||
"cwe": [
|
||||
"CWE-319",
|
||||
"CWE-311"
|
||||
@@ -232,12 +334,25 @@
|
||||
{
|
||||
"tool": "gitleaks",
|
||||
"scan_type": "secret_detection",
|
||||
"languages": [],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
},
|
||||
{
|
||||
"tool": "semgrep",
|
||||
"scan_type": "sast",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"java",
|
||||
"go",
|
||||
"ruby",
|
||||
"php",
|
||||
"csharp",
|
||||
"kotlin",
|
||||
"c"
|
||||
],
|
||||
"cwe": [
|
||||
"CWE-798",
|
||||
"CWE-321"
|
||||
@@ -278,6 +393,18 @@
|
||||
{
|
||||
"tool": "semgrep",
|
||||
"scan_type": "sast",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"java",
|
||||
"go",
|
||||
"ruby",
|
||||
"php",
|
||||
"csharp",
|
||||
"kotlin",
|
||||
"c"
|
||||
],
|
||||
"cwe": [
|
||||
"CWE-89",
|
||||
"CWE-78",
|
||||
@@ -293,6 +420,10 @@
|
||||
{
|
||||
"tool": "cppcheck",
|
||||
"scan_type": "sast",
|
||||
"languages": [
|
||||
"c",
|
||||
"cpp"
|
||||
],
|
||||
"cwe": [
|
||||
"CWE-119",
|
||||
"CWE-120",
|
||||
@@ -333,12 +464,14 @@
|
||||
{
|
||||
"tool": "osv",
|
||||
"scan_type": "cve",
|
||||
"languages": [],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
},
|
||||
{
|
||||
"tool": "syft",
|
||||
"scan_type": "sbom",
|
||||
"languages": [],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
}
|
||||
@@ -353,6 +486,7 @@
|
||||
{
|
||||
"tool": "syft",
|
||||
"scan_type": "sbom",
|
||||
"languages": [],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
}
|
||||
@@ -367,6 +501,18 @@
|
||||
{
|
||||
"tool": "grounded-control-check",
|
||||
"scan_type": "code_review",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"go",
|
||||
"java",
|
||||
"ruby",
|
||||
"php",
|
||||
"rust",
|
||||
"csharp",
|
||||
"kotlin"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
}
|
||||
@@ -395,6 +541,18 @@
|
||||
{
|
||||
"tool": "grounded-control-check",
|
||||
"scan_type": "code_review",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"go",
|
||||
"java",
|
||||
"ruby",
|
||||
"php",
|
||||
"rust",
|
||||
"csharp",
|
||||
"kotlin"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
}
|
||||
@@ -409,6 +567,18 @@
|
||||
{
|
||||
"tool": "grounded-control-check",
|
||||
"scan_type": "code_review",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"go",
|
||||
"java",
|
||||
"ruby",
|
||||
"php",
|
||||
"rust",
|
||||
"csharp",
|
||||
"kotlin"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
}
|
||||
@@ -423,6 +593,18 @@
|
||||
{
|
||||
"tool": "grounded-control-check",
|
||||
"scan_type": "code_review",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"go",
|
||||
"java",
|
||||
"ruby",
|
||||
"php",
|
||||
"rust",
|
||||
"csharp",
|
||||
"kotlin"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
}
|
||||
@@ -437,6 +619,18 @@
|
||||
{
|
||||
"tool": "grounded-control-check",
|
||||
"scan_type": "code_review",
|
||||
"languages": [
|
||||
"python",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"go",
|
||||
"java",
|
||||
"ruby",
|
||||
"php",
|
||||
"rust",
|
||||
"csharp",
|
||||
"kotlin"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
}
|
||||
@@ -465,12 +659,14 @@
|
||||
{
|
||||
"tool": "syft",
|
||||
"scan_type": "sbom",
|
||||
"languages": [],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
},
|
||||
{
|
||||
"tool": "osv",
|
||||
"scan_type": "cve",
|
||||
"languages": [],
|
||||
"cwe": [],
|
||||
"rules": []
|
||||
}
|
||||
|
||||
@@ -30,6 +30,11 @@ pub struct ScanBinding {
|
||||
pub tool: String,
|
||||
/// Scan family, e.g. `"sast"`, `"secret_detection"`, `"sbom"`, `"cve"`.
|
||||
pub scan_type: String,
|
||||
/// The source languages this binding checks (`"c"`, `"python"`, …), as
|
||||
/// the rules behind it declare them. Empty means language-independent
|
||||
/// (secrets in any file, dependencies from any manifest).
|
||||
#[serde(default)]
|
||||
pub languages: Vec<String>,
|
||||
/// CWEs whose findings map to this control (used to attach findings back).
|
||||
#[serde(default)]
|
||||
pub cwe: Vec<String>,
|
||||
@@ -38,6 +43,13 @@ pub struct ScanBinding {
|
||||
pub rules: Vec<String>,
|
||||
}
|
||||
|
||||
impl ScanBinding {
|
||||
/// Whether this binding checks code in any of `languages`.
|
||||
pub fn applies_to(&self, languages: &[String]) -> bool {
|
||||
self.languages.is_empty() || self.languages.iter().any(|l| languages.contains(l))
|
||||
}
|
||||
}
|
||||
|
||||
/// One control's entry in the LUT.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ControlEntry {
|
||||
@@ -56,6 +68,15 @@ pub struct ControlEntry {
|
||||
pub note: Option<String>,
|
||||
}
|
||||
|
||||
impl ControlEntry {
|
||||
/// Whether a scan of code in `languages` checks this control at all: at
|
||||
/// least one of its bindings applies. Only then can "no violation found"
|
||||
/// be claimed for it.
|
||||
pub fn checked_for(&self, languages: &[String]) -> bool {
|
||||
self.scans.iter().any(|s| s.applies_to(languages))
|
||||
}
|
||||
}
|
||||
|
||||
/// The control → scan lookup table for one framework.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ControlMap {
|
||||
@@ -190,6 +211,43 @@ mod tests {
|
||||
assert_eq!(map.summary().total(), 40);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_control_is_checked_only_for_the_languages_its_rules_cover() {
|
||||
let map = ControlMap::cra().expect("map");
|
||||
let c_only = ["c".to_string()];
|
||||
let python = ["python".to_string()];
|
||||
let secure_defaults = map.coverage("cra-ai-1").expect("cra-ai-1");
|
||||
let memory_safety = map.coverage("cra-ai-20").expect("cra-ai-20");
|
||||
let secrets = map.coverage("cra-ai-9").expect("cra-ai-9");
|
||||
|
||||
// Only Python/JS rules check secure defaults.
|
||||
assert!(!secure_defaults.checked_for(&c_only));
|
||||
assert!(secure_defaults.checked_for(&python));
|
||||
// Our C rules and cppcheck check memory safety in C.
|
||||
assert!(memory_safety.checked_for(&c_only));
|
||||
// gitleaks reads any file, so no language is needed.
|
||||
assert!(secrets.checked_for(&[]));
|
||||
}
|
||||
|
||||
#[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.
|
||||
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" | "syft" | "osv");
|
||||
assert_eq!(
|
||||
reads_code,
|
||||
!scan.languages.is_empty(),
|
||||
"{} / {}",
|
||||
control.control,
|
||||
scan.tool
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hardcoded_password_control_is_tool_covered() {
|
||||
let map = ControlMap::cra().unwrap();
|
||||
|
||||
Reference in new issue
Block a user