Skip to content

Commit

Permalink
⚠️ Replace Positive and Negative outcomes with True and False (#4017)
Browse files Browse the repository at this point in the history
* rename positive to true

Signed-off-by: Spencer Schrock <sschrock@google.com>

* rename negative to false

Signed-off-by: Spencer Schrock <sschrock@google.com>

---------

Signed-off-by: Spencer Schrock <sschrock@google.com>
  • Loading branch information
spencerschrock committed Apr 8, 2024
1 parent ba4fb1b commit b577d79
Show file tree
Hide file tree
Showing 168 changed files with 1,100 additions and 1,098 deletions.
4 changes: 2 additions & 2 deletions checker/check_result.go
Expand Up @@ -248,11 +248,11 @@ func LogFindings(findings []finding.Finding, dl DetailLogger) {
for i := range findings {
f := &findings[i]
switch f.Outcome {
case finding.OutcomeNegative:
case finding.OutcomeFalse:
dl.Warn(&LogMessage{
Finding: f,
})
case finding.OutcomePositive:
case finding.OutcomeTrue:
dl.Info(&LogMessage{
Finding: f,
})
Expand Down
6 changes: 3 additions & 3 deletions checks/evaluation/binary_artifacts.go
Expand Up @@ -35,13 +35,13 @@ func BinaryArtifacts(name string,
return checker.CreateRuntimeErrorResult(name, e)
}

if findings[0].Outcome == finding.OutcomePositive {
if findings[0].Outcome == finding.OutcomeTrue {
return checker.CreateMaxScoreResult(name, "no binaries found in the repo")
}

for i := range findings {
f := &findings[i]
if f.Outcome != finding.OutcomeNegative {
if f.Outcome != finding.OutcomeFalse {
continue
}
dl.Warn(&checker.LogMessage{
Expand All @@ -52,7 +52,7 @@ func BinaryArtifacts(name string,
})
}

// There are only negative findings.
// There are only false findings.
// Deduct the number of findings from max score
numberOfBinaryFilesFound := len(findings)

Expand Down
46 changes: 23 additions & 23 deletions checks/evaluation/binary_artifacts_test.go
Expand Up @@ -27,9 +27,9 @@ import (
func TestBinaryArtifacts(t *testing.T) {
t.Parallel()
lineStart := uint(123)
negativeFinding := finding.Finding{
falseFinding := finding.Finding{
Probe: "freeOfUnverifiedBinaryArtifacts",
Outcome: finding.OutcomeNegative,
Outcome: finding.OutcomeFalse,

Location: &finding.Location{
Path: "path",
Expand All @@ -48,7 +48,7 @@ func TestBinaryArtifacts(t *testing.T) {
findings: []finding.Finding{
{
Probe: "freeOfUnverifiedBinaryArtifacts",
Outcome: finding.OutcomePositive,
Outcome: finding.OutcomeTrue,
},
},
result: scut.TestReturn{
Expand All @@ -58,7 +58,7 @@ func TestBinaryArtifacts(t *testing.T) {
{
name: "one binary artifact",
findings: []finding.Finding{
negativeFinding,
falseFinding,
},
result: scut.TestReturn{
Score: 9,
Expand All @@ -70,7 +70,7 @@ func TestBinaryArtifacts(t *testing.T) {
findings: []finding.Finding{
{
Probe: "freeOfUnverifiedBinaryArtifacts",
Outcome: finding.OutcomeNegative,
Outcome: finding.OutcomeFalse,
Location: &finding.Location{
Path: "path",
Type: finding.FileTypeBinary,
Expand All @@ -79,7 +79,7 @@ func TestBinaryArtifacts(t *testing.T) {
},
{
Probe: "freeOfUnverifiedBinaryArtifacts",
Outcome: finding.OutcomeNegative,
Outcome: finding.OutcomeFalse,
Location: &finding.Location{
Path: "path",
Type: finding.FileTypeBinary,
Expand All @@ -95,11 +95,11 @@ func TestBinaryArtifacts(t *testing.T) {
{
name: "five binary artifact",
findings: []finding.Finding{
negativeFinding,
negativeFinding,
negativeFinding,
negativeFinding,
negativeFinding,
falseFinding,
falseFinding,
falseFinding,
falseFinding,
falseFinding,
},
result: scut.TestReturn{
Score: 5,
Expand All @@ -109,18 +109,18 @@ func TestBinaryArtifacts(t *testing.T) {
{
name: "twelve binary artifact - ensure score doesn't drop below min",
findings: []finding.Finding{
negativeFinding,
negativeFinding,
negativeFinding,
negativeFinding,
negativeFinding,
negativeFinding,
negativeFinding,
negativeFinding,
negativeFinding,
negativeFinding,
negativeFinding,
negativeFinding,
falseFinding,
falseFinding,
falseFinding,
falseFinding,
falseFinding,
falseFinding,
falseFinding,
falseFinding,
falseFinding,
falseFinding,
falseFinding,
falseFinding,
},
result: scut.TestReturn{
Score: checker.MinResultScore,
Expand Down
30 changes: 15 additions & 15 deletions checks/evaluation/branch_protection.go
Expand Up @@ -119,12 +119,12 @@ func BranchProtection(name string,
e := sce.WithMessage(sce.ErrScorecardInternal, "probe is missing branch name")
return checker.CreateRuntimeErrorResult(name, e)
// Now we can check whether the branch is protected:
case f.Outcome == finding.OutcomeNegative:
case f.Outcome == finding.OutcomeFalse:
protectedBranches[branchName] = false
dl.Warn(&checker.LogMessage{
Text: fmt.Sprintf("branch protection not enabled for branch '%s'", branchName),
})
case f.Outcome == finding.OutcomePositive:
case f.Outcome == finding.OutcomeTrue:
protectedBranches[branchName] = true
default:
continue
Expand Down Expand Up @@ -177,7 +177,7 @@ func BranchProtection(name string,
reviewerWeight := 2
max = reviewerWeight
noOfRequiredReviewers, _ := strconv.Atoi(f.Values["numberOfRequiredReviewers"]) //nolint:errcheck
if f.Outcome == finding.OutcomePositive && noOfRequiredReviewers > 0 {
if f.Outcome == finding.OutcomeTrue && noOfRequiredReviewers > 0 {
branchScores[branchName].scores.review += reviewerWeight
}
branchScores[branchName].maxes.review += max
Expand Down Expand Up @@ -259,9 +259,9 @@ func logWithDebug(f *finding.Finding, doLogging bool, dl checker.DetailLogger) {
switch f.Outcome {
case finding.OutcomeNotAvailable:
debug(dl, doLogging, f.Message)
case finding.OutcomePositive:
case finding.OutcomeTrue:
info(dl, doLogging, f.Message)
case finding.OutcomeNegative:
case finding.OutcomeFalse:
warn(dl, doLogging, f.Message)
default:
// To satisfy linter
Expand All @@ -270,9 +270,9 @@ func logWithDebug(f *finding.Finding, doLogging bool, dl checker.DetailLogger) {

func logWithoutDebug(f *finding.Finding, doLogging bool, dl checker.DetailLogger) {
switch f.Outcome {
case finding.OutcomePositive:
case finding.OutcomeTrue:
info(dl, doLogging, f.Message)
case finding.OutcomeNegative:
case finding.OutcomeFalse:
warn(dl, doLogging, f.Message)
default:
// To satisfy linter
Expand All @@ -281,7 +281,7 @@ func logWithoutDebug(f *finding.Finding, doLogging bool, dl checker.DetailLogger

func logInfoOrWarn(f *finding.Finding, doLogging bool, dl checker.DetailLogger) {
switch f.Outcome {
case finding.OutcomePositive:
case finding.OutcomeTrue:
info(dl, doLogging, f.Message)
default:
warn(dl, doLogging, f.Message)
Expand Down Expand Up @@ -384,7 +384,7 @@ func warn(dl checker.DetailLogger, doLogging bool, desc string, args ...interfac
func deleteAndForcePushProtection(f *finding.Finding, doLogging bool, dl checker.DetailLogger) (int, int) {
var score, max int
logWithoutDebug(f, doLogging, dl)
if f.Outcome == finding.OutcomePositive {
if f.Outcome == finding.OutcomeTrue {
score++
}
max++
Expand All @@ -395,7 +395,7 @@ func deleteAndForcePushProtection(f *finding.Finding, doLogging bool, dl checker
func nonAdminContextProtection(f *finding.Finding, doLogging bool, dl checker.DetailLogger) (int, int) {
var score, max int
logInfoOrWarn(f, doLogging, dl)
if f.Outcome == finding.OutcomePositive {
if f.Outcome == finding.OutcomeTrue {
score++
}
max++
Expand All @@ -404,7 +404,7 @@ func nonAdminContextProtection(f *finding.Finding, doLogging bool, dl checker.De

func adminReviewProtection(f *finding.Finding, doLogging bool, dl checker.DetailLogger) (int, int) {
var score, max int
if f.Outcome == finding.OutcomePositive {
if f.Outcome == finding.OutcomeTrue {
score++
}
logWithDebug(f, doLogging, dl)
Expand All @@ -418,7 +418,7 @@ func adminThoroughReviewProtection(f *finding.Finding, doLogging bool, dl checke
var score, max int

logWithDebug(f, doLogging, dl)
if f.Outcome == finding.OutcomePositive {
if f.Outcome == finding.OutcomeTrue {
score++
}
if f.Outcome != finding.OutcomeNotAvailable {
Expand All @@ -429,15 +429,15 @@ func adminThoroughReviewProtection(f *finding.Finding, doLogging bool, dl checke

func nonAdminThoroughReviewProtection(f *finding.Finding, doLogging bool, dl checker.DetailLogger) (int, int) {
var score, max int
if f.Outcome == finding.OutcomePositive {
if f.Outcome == finding.OutcomeTrue {
noOfRequiredReviews, _ := strconv.Atoi(f.Values["numberOfRequiredReviewers"]) //nolint:errcheck
if noOfRequiredReviews >= minReviews {
info(dl, doLogging, f.Message)
score++
} else {
warn(dl, doLogging, f.Message)
}
} else if f.Outcome == finding.OutcomeNegative {
} else if f.Outcome == finding.OutcomeFalse {
warn(dl, doLogging, f.Message)
}
max++
Expand All @@ -446,7 +446,7 @@ func nonAdminThoroughReviewProtection(f *finding.Finding, doLogging bool, dl che

func codeownerBranchProtection(f *finding.Finding, doLogging bool, dl checker.DetailLogger) (int, int) {
var score, max int
if f.Outcome == finding.OutcomePositive {
if f.Outcome == finding.OutcomeTrue {
info(dl, doLogging, f.Message)
score++
} else {
Expand Down

0 comments on commit b577d79

Please sign in to comment.