Skip to content

Commit

Permalink
remove hasBadgeNotFound probe
Browse files Browse the repository at this point in the history
Signed-off-by: AdamKorcz <[email protected]>
  • Loading branch information
AdamKorcz committed Oct 5, 2023
1 parent 4e4b6a0 commit b24e339
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 214 deletions.
34 changes: 21 additions & 13 deletions checks/evaluation/cii_best_practices.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/ossf/scorecard/v4/checker"
sce "github.com/ossf/scorecard/v4/errors"
"github.com/ossf/scorecard/v4/finding"
"github.com/ossf/scorecard/v4/probes/hasBadgeNotFound"
"github.com/ossf/scorecard/v4/probes/hasGoldBadge"
"github.com/ossf/scorecard/v4/probes/hasInProgressBadge"
"github.com/ossf/scorecard/v4/probes/hasPassingBadge"
Expand All @@ -42,7 +41,6 @@ func CIIBestPractices(name string,
findings []finding.Finding, dl checker.DetailLogger,
) checker.CheckResult {
expectedProbes := []string{
hasBadgeNotFound.Probe,
hasGoldBadge.Probe,
hasSilverBadge.Probe,
hasInProgressBadge.Probe,
Expand All @@ -55,16 +53,32 @@ func CIIBestPractices(name string,
return checker.CreateRuntimeErrorResult(name, e)
}

var score, numberOfPositives int
var countBadges int
// Sanity check that we don't have multiple positives
for i := range findings {
f := &findings[i]

if f.Outcome == finding.OutcomePositive {
countBadges++
}
}

var score int
var text string

if countBadges > 1 {
errText := "invalid probe results: multiple badges detected"
e := sce.WithMessage(sce.ErrScorecardInternal, errText)
return checker.CreateRuntimeErrorResult(name, e)
} else if countBadges == 0 {
text = "no effort to earn an OpenSSF best practices badge detected"
return checker.CreateResultWithScore(name, text, minScore)
}

for i := range findings {
f := &findings[i]
if f.Outcome == finding.OutcomePositive {
numberOfPositives++
switch f.Probe {
case hasBadgeNotFound.Probe:
score = minScore
text = "no effort to earn an OpenSSF best practices badge detected"
case hasInProgressBadge.Probe:
score = inProgressScore
text = "badge detected: InProgress"
Expand All @@ -84,12 +98,6 @@ func CIIBestPractices(name string,
}
}

if numberOfPositives != 1 {
errText := "invalid probe results: multiple badges detected"
e := sce.WithMessage(sce.ErrScorecardInternal, errText)
return checker.CreateRuntimeErrorResult(name, e)
}

if score == -1 {
e := sce.WithMessage(sce.ErrScorecardInternal, text)
return checker.CreateRuntimeErrorResult(name, e)
Expand Down
18 changes: 0 additions & 18 deletions checks/evaluation/cii_best_practices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ func TestCIIBestPractices(t *testing.T) {
name: "Badge not found",
findings: []finding.Finding{
{
Probe: "hasBadgeNotFound",
Outcome: finding.OutcomePositive,
}, {
Probe: "hasGoldBadge",
Outcome: finding.OutcomeNegative,
}, {
Expand All @@ -59,9 +56,6 @@ func TestCIIBestPractices(t *testing.T) {
name: "Has InProgress Badge",
findings: []finding.Finding{
{
Probe: "hasBadgeNotFound",
Outcome: finding.OutcomeNegative,
}, {
Probe: "hasGoldBadge",
Outcome: finding.OutcomeNegative,
}, {
Expand All @@ -86,9 +80,6 @@ func TestCIIBestPractices(t *testing.T) {
name: "Has Passing Badge",
findings: []finding.Finding{
{
Probe: "hasBadgeNotFound",
Outcome: finding.OutcomeNegative,
}, {
Probe: "hasGoldBadge",
Outcome: finding.OutcomeNegative,
}, {
Expand All @@ -113,9 +104,6 @@ func TestCIIBestPractices(t *testing.T) {
name: "Has Silver Badge",
findings: []finding.Finding{
{
Probe: "hasBadgeNotFound",
Outcome: finding.OutcomeNegative,
}, {
Probe: "hasGoldBadge",
Outcome: finding.OutcomeNegative,
}, {
Expand All @@ -140,9 +128,6 @@ func TestCIIBestPractices(t *testing.T) {
name: "Has Gold Badge",
findings: []finding.Finding{
{
Probe: "hasBadgeNotFound",
Outcome: finding.OutcomeNegative,
}, {
Probe: "hasGoldBadge",
Outcome: finding.OutcomePositive,
}, {
Expand All @@ -167,9 +152,6 @@ func TestCIIBestPractices(t *testing.T) {
name: "Has Unknown Badge",
findings: []finding.Finding{
{
Probe: "hasBadgeNotFound",
Outcome: finding.OutcomeNegative,
}, {
Probe: "hasGoldBadge",
Outcome: finding.OutcomeNegative,
}, {
Expand Down
2 changes: 0 additions & 2 deletions probes/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/ossf/scorecard/v4/probes/fuzzedWithPropertyBasedHaskell"
"github.com/ossf/scorecard/v4/probes/fuzzedWithPropertyBasedJavascript"
"github.com/ossf/scorecard/v4/probes/fuzzedWithPropertyBasedTypescript"
"github.com/ossf/scorecard/v4/probes/hasBadgeNotFound"
"github.com/ossf/scorecard/v4/probes/hasGoldBadge"
"github.com/ossf/scorecard/v4/probes/hasInProgressBadge"
"github.com/ossf/scorecard/v4/probes/hasPassingBadge"
Expand Down Expand Up @@ -72,7 +71,6 @@ var (
fuzzedWithPropertyBasedJavascript.Run,
}
CIIBestPractices = []ProbeImpl{
hasBadgeNotFound.Run,
hasGoldBadge.Run,
hasSilverBadge.Run,
hasInProgressBadge.Run,
Expand Down
29 changes: 0 additions & 29 deletions probes/hasBadgeNotFound/def.yml

This file was deleted.

64 changes: 0 additions & 64 deletions probes/hasBadgeNotFound/impl.go

This file was deleted.

88 changes: 0 additions & 88 deletions probes/hasBadgeNotFound/impl_test.go

This file was deleted.

0 comments on commit b24e339

Please sign in to comment.