fix(scan): "Prüfung starten" always scans, and a skipped scan says why (#419)
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 3s
CI / Deploy Docs (push) Skipped
CI / Deploy MCP (push) Successful in 4m4s
CI / Deploy Dashboard (push) Successful in 5m43s
CI / Deploy Agent (push) Successful in 7m0s

This commit was merged in pull request #419.
This commit is contained in:
sharang committed 2026-09-28 20:52:10 +00:00
1 parent 420ce241cd
commit 6fe7874ccd
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)