feat(scans): PLC control mapping shows as its own phase
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 7m40s
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 7m40s
The LLM control mapping on the PLC path ran inside "SPS-Analyse", so a scan sat on that phase for minutes while Qwen mapped the findings. The parser and rules now finish first, then the run moves to "Controls zuordnen" for the semantic pass, as on the code path. The pass follows the breakpilot.semantic_mapping flag here too. 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
fce9edfbeb
commit
a891bea798
1 file changed
+61
-18
@@ -844,28 +844,19 @@ impl PipelineOrchestrator {
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
let mut all_findings = Vec::new();
|
||||
// Each source's findings next to the tree they were found in: the
|
||||
// control mapping below reads the flagged regions from it.
|
||||
let mut analysed = Vec::with_capacity(sources.len());
|
||||
let mut all_sbom: Vec<SbomEntry> = Vec::new();
|
||||
let mut sbom_seen = std::collections::BTreeSet::new();
|
||||
for a in &sources {
|
||||
let Some(path) = ingest_set.get(&a.id).and_then(|ia| ia.working_path.clone()) else {
|
||||
continue;
|
||||
};
|
||||
let mut source_findings = crate::pipeline::plc::analyze_tree(&path, target_id);
|
||||
// Control mapping for the PLC path (run_plc_scan is separate from
|
||||
// run_pipeline, which does its own mapping). PLC findings carry
|
||||
// file_path/line/cwe, so the semantic pass reads each region under this
|
||||
// source's `path` and stamps master-control refs. The LUT + grounded
|
||||
// surface passes are code-pattern / CRA-specific and don't apply to
|
||||
// IEC 61131-3 control logic, so only the semantic pass runs here.
|
||||
crate::controls::semantic_stamp_findings(
|
||||
&self.config,
|
||||
self.llm.clone(),
|
||||
&path,
|
||||
&mut source_findings,
|
||||
)
|
||||
.await;
|
||||
all_findings.extend(source_findings);
|
||||
analysed.push((
|
||||
path.clone(),
|
||||
crate::pipeline::plc::analyze_tree(&path, target_id),
|
||||
));
|
||||
// Control-application SBOM: CODESYS libraries + runtime from a
|
||||
// `.projectarchive` (uploaded, or committed in the working tree).
|
||||
let archive = a
|
||||
@@ -902,6 +893,7 @@ impl PipelineOrchestrator {
|
||||
}
|
||||
}
|
||||
}
|
||||
let all_findings = self.map_plc_findings(scan_run_id, analysed).await;
|
||||
tracing::info!(
|
||||
target_id,
|
||||
artifacts = sources.len(),
|
||||
@@ -1602,6 +1594,40 @@ impl PipelineOrchestrator {
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Control mapping for the PLC path (`run_plc_scan` is separate from
|
||||
/// `run_pipeline`, which does its own). PLC findings carry
|
||||
/// file_path/line/cwe, so the semantic pass reads each region under its
|
||||
/// source's tree and stamps master-control refs. The LUT and grounded
|
||||
/// passes are code-pattern / CRA-specific and don't apply to IEC 61131-3
|
||||
/// control logic, so only the semantic pass runs. It asks the LLM about
|
||||
/// each finding and can take minutes, so it is a phase of its own.
|
||||
async fn map_plc_findings(
|
||||
&self,
|
||||
scan_run_id: &str,
|
||||
analysed: Vec<(std::path::PathBuf, Vec<Finding>)>,
|
||||
) -> Vec<Finding> {
|
||||
let mut all_findings = Vec::new();
|
||||
let map = self.config.breakpilot.semantic_mapping
|
||||
&& analysed.iter().any(|(_, findings)| !findings.is_empty());
|
||||
if map {
|
||||
self.update_phase(scan_run_id, ScanPhase::SemanticControlMapping)
|
||||
.await;
|
||||
}
|
||||
for (path, mut findings) in analysed {
|
||||
if map {
|
||||
crate::controls::semantic_stamp_findings(
|
||||
&self.config,
|
||||
self.llm.clone(),
|
||||
&path,
|
||||
&mut findings,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
all_findings.extend(findings);
|
||||
}
|
||||
all_findings
|
||||
}
|
||||
|
||||
pub(super) async fn update_phase(&self, scan_run_id: &str, phase: ScanPhase) {
|
||||
let Ok(phase) = mongodb::bson::to_bson(&phase) else {
|
||||
return;
|
||||
@@ -1688,6 +1714,9 @@ fn planned_phases(
|
||||
if plc || ics {
|
||||
if plc {
|
||||
phases.push(ScanPhase::PlcAnalysis);
|
||||
if config.breakpilot.semantic_mapping {
|
||||
phases.push(ScanPhase::SemanticControlMapping);
|
||||
}
|
||||
if config.plc_runtime.enabled && target.live_url().is_none() {
|
||||
phases.push(ScanPhase::PlcProvision);
|
||||
}
|
||||
@@ -1792,10 +1821,24 @@ mod tests {
|
||||
));
|
||||
let mut config = AgentConfig::default();
|
||||
config.plc_runtime.enabled = false;
|
||||
config.breakpilot.semantic_mapping = false;
|
||||
let plan = build_scan_plan(&target);
|
||||
|
||||
let phases = planned_phases(&target, &build_scan_plan(&target), &config);
|
||||
assert_eq!(
|
||||
planned_phases(&target, &plan, &config),
|
||||
[ScanPhase::Classification, ScanPhase::PlcAnalysis]
|
||||
);
|
||||
|
||||
assert_eq!(phases, [ScanPhase::Classification, ScanPhase::PlcAnalysis]);
|
||||
// The LLM control mapping is a phase of its own, so a long one shows.
|
||||
config.breakpilot.semantic_mapping = true;
|
||||
assert_eq!(
|
||||
planned_phases(&target, &plan, &config),
|
||||
[
|
||||
ScanPhase::Classification,
|
||||
ScanPhase::PlcAnalysis,
|
||||
ScanPhase::SemanticControlMapping
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user