Skip to content

Commit

Permalink
dont log lack of signature if we have provenance
Browse files Browse the repository at this point in the history
reduce test warn counts for cases where there is provenance but no signature

Signed-off-by: Spencer Schrock <[email protected]>
  • Loading branch information
spencerschrock committed Apr 11, 2024
1 parent 6d18776 commit b9d51bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion checks/evaluation/signed_releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func SignedReleases(name string,
return checker.CreateRuntimeErrorResult(name, e)
}

// keep track of releases which have provenance so we don't log about signatures
// on our second pass through below
hasProvenance := make(map[string]bool)

// Debug all releases and check for OutcomeNotApplicable
// All probes have OutcomeNotApplicable in case the project has no
// releases. Therefore, check for any finding with OutcomeNotApplicable.
Expand All @@ -67,7 +71,9 @@ func SignedReleases(name string,
loggedReleases = append(loggedReleases, releaseName)
}

// Check if outcome is NotApplicable
if f.Probe == releasesHaveProvenance.Probe && f.Outcome == finding.OutcomeTrue {
hasProvenance[releaseName] = true
}
}

totalTrue := 0
Expand Down Expand Up @@ -100,6 +106,9 @@ func SignedReleases(name string,
}
case finding.OutcomeFalse:
logLevel = checker.DetailWarn
if f.Probe == releasesAreSigned.Probe && hasProvenance[releaseName] {
continue
}
default:
logLevel = checker.DetailDebug
}
Expand Down
6 changes: 3 additions & 3 deletions checks/evaluation/signed_releases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestSignedReleases(t *testing.T) {
result: scut.TestReturn{
Score: checker.MaxResultScore,
NumberOfInfo: 1,
NumberOfWarn: 1,
NumberOfWarn: 0,
NumberOfDebug: 1,
},
},
Expand All @@ -126,7 +126,7 @@ func TestSignedReleases(t *testing.T) {
result: scut.TestReturn{
Score: 6,
NumberOfInfo: 2,
NumberOfWarn: 4,
NumberOfWarn: 3,
NumberOfDebug: 3,
},
},
Expand All @@ -152,7 +152,7 @@ func TestSignedReleases(t *testing.T) {
result: scut.TestReturn{
Score: 7,
NumberOfInfo: 4,
NumberOfWarn: 6,
NumberOfWarn: 4,
NumberOfDebug: 5,
},
},
Expand Down

0 comments on commit b9d51bb

Please sign in to comment.