fix(scan): "Prüfung starten" always scans, and a skipped scan says why
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 7m51s

A manual rescan of a repository without new commits stopped after change
detection ("No new commits, skipping scan") and closed the run with only
that one stage done, so the dashboard showed every other stage as pending,
for good. A scan a person starts now always runs in full (after an update of
Prüfwerk or a changed setting it can find something else); scheduled and
webhook scans still skip an unchanged repository, and the run records it as
a skipped stage, "Keine neuen Commits seit der letzten Prüfung".

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:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-09-28 22:41:32 +02:00
1 parent 8972db0594
commit 493957624a
3 files changed
+44 -5

No files matched your search

+27 -5
View File
@@ -69,7 +69,12 @@ impl PipelineOrchestrator {
}
#[tracing::instrument(skip_all, fields(repo_id = repo.name.as_str()))]
async fn run_pipeline(&self, repo: &RepoView, scan_run_id: &str) -> Result<u32, AgentError> {
async fn run_pipeline(
&self,
repo: &RepoView,
scan_run_id: &str,
trigger: &ScanTrigger,
) -> Result<u32, AgentError> {
let repo_id = repo.id.as_ref().map(|id| id.to_hex()).unwrap_or_default();
// Stage 0: Change detection
@@ -83,8 +88,22 @@ impl PipelineOrchestrator {
);
let repo_path = git_ops.clone_or_fetch(&repo.git_url, &repo.name)?;
if !GitOps::has_new_commits(&repo_path, repo.last_scanned_commit.as_deref())? {
// A scheduled or webhook scan of an unchanged repository has nothing
// new to find; one a person started always runs (after an update of
// Prüfwerk itself, or a changed setting, it can find something else).
if *trigger != ScanTrigger::Manual
&& !GitOps::has_new_commits(&repo_path, repo.last_scanned_commit.as_deref())?
{
tracing::info!("[{repo_id}] No new commits, skipping scan");
self.skip_stage(
scan_run_id,
SkippedStage::new(
"change_detection",
SkipCode::NoNewCommits,
"no new commits since the last scan",
),
)
.await;
return Ok(0);
}
@@ -584,7 +603,7 @@ impl PipelineOrchestrator {
.await?
.ok_or_else(|| AgentError::Other(format!("Onboarded target {target_id} not found")))?;
let scan_run = ScanRun::new(target_id.to_string(), trigger);
let scan_run = ScanRun::new(target_id.to_string(), trigger.clone());
let insert = self.db.scan_runs().insert_one(&scan_run).await?;
let scan_run_id = insert
.inserted_id
@@ -592,7 +611,9 @@ impl PipelineOrchestrator {
.map(|id| id.to_hex())
.unwrap_or_default();
let result = self.run_target_pipeline(&target, &scan_run_id).await;
let result = self
.run_target_pipeline(&target, &scan_run_id, &trigger)
.await;
match &result {
Ok(count) => {
self.db
@@ -655,6 +676,7 @@ impl PipelineOrchestrator {
&self,
target: &OnboardedTarget,
scan_run_id: &str,
trigger: &ScanTrigger,
) -> Result<u32, AgentError> {
let target_id = target.id.map(|id| id.to_hex()).unwrap_or_default();
let plan = build_scan_plan(target);
@@ -737,7 +759,7 @@ impl PipelineOrchestrator {
match target.code_artifact() {
Some(code) if code.kind == ArtifactKind::GitRepo => {
let repo = RepoView::from_target(target, code, &self.secrets);
let n = self.run_pipeline(&repo, scan_run_id).await?;
let n = self.run_pipeline(&repo, scan_run_id, trigger).await?;
self.finalize_target(target, &repo, n).await?;
new_count += n;
self.dast_after_code_scan(&target_id, &plan, scan_run_id)
+3
View File
@@ -181,6 +181,9 @@ pub enum SkipCode {
/// Some components were not matched against known vulnerabilities;
/// `subject` names the lookup, and the components where known.
CveLookupIncomplete,
/// A scheduled or webhook scan found no new commits since the last scan,
/// so nothing was scanned again.
NoNewCommits,
}
/// Why a scan run failed, stable for the dashboard to word.
+14
View File
@@ -383,6 +383,10 @@ pub mod scans {
/// this dashboard does not know yet; it is then shown as it is.
pub fn stage(id: &str) -> Option<Text> {
let text = match id {
"change_detection" => Text {
de: "Änderungserkennung",
en: "Change detection",
},
"ingest" => Text {
de: "Einlesen der Dateien",
en: "Reading the upload",
@@ -550,6 +554,16 @@ pub mod scans {
),
(SkipCode::CveLookupIncomplete, Lang::De) => format!("Nicht abgeglichen: {subject}"),
(SkipCode::CveLookupIncomplete, Lang::En) => format!("Not matched: {subject}"),
(SkipCode::NoNewCommits, Lang::De) => {
"Keine neuen Commits seit der letzten Prüfung, daher nicht erneut geprüft. \
„Prüfung starten“ prüft trotzdem vollständig."
.into()
}
(SkipCode::NoNewCommits, Lang::En) => {
"No new commits since the last scan, so it was not scanned again. \
\"Run scan\" always scans in full."
.into()
}
}
}