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

+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()
}