Skip to content

Commit

Permalink
Merge branch 'main' into feat/hidesarif
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsimon authored Dec 21, 2021
2 parents 9faa805 + 6f21258 commit bf582c1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
9 changes: 8 additions & 1 deletion checks/evaluation/binary_artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ func BinaryArtifacts(name string, dl checker.DetailLogger,
return checker.CreateMaxScoreResult(name, "no binaries found in the repo")
}

score := checker.MaxResultScore
for _, f := range r.Files {
dl.Warn3(&checker.LogMessage{
Path: f.Path, Type: checker.FileTypeBinary,
Text: "binary detected",
})
// We remove one point for each binary.
score--
}

return checker.CreateMinScoreResult(name, "binaries present in source code")
if score < checker.MinResultScore {
score = checker.MinResultScore
}

return checker.CreateResultWithScore(name, "binaries present in source code", score)
}
29 changes: 28 additions & 1 deletion e2e/binary_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,34 @@ var _ = Describe("E2E TEST:"+checks.CheckBinaryArtifacts, func() {
Expect(result.Error).Should(BeNil())
Expect(result.Pass).Should(BeFalse())
// New version.
Expect(scut.ValidateTestReturn(nil, " binary artifacts", &expected, &result, &dl)).Should(BeTrue())
Expect(scut.ValidateTestReturn(nil, "binary artifacts", &expected, &result, &dl)).Should(BeTrue())
Expect(repoClient.Close()).Should(BeNil())
})
It("Should return binary artifacts present in source code", func() {
dl := scut.TestDetailLogger{}
repo, err := githubrepo.MakeGithubRepo("ossf-tests/scorecard-check-binary-artifacts-e2e-4-binaries")
Expect(err).Should(BeNil())
repoClient := githubrepo.CreateGithubRepoClient(context.Background(), logger)
err = repoClient.InitRepo(repo)
Expect(err).Should(BeNil())

req := checker.CheckRequest{
Ctx: context.Background(),
RepoClient: repoClient,
Repo: repo,
Dlogger: &dl,
}
// TODO: upload real binaries to the repo as well.
expected := scut.TestReturn{
Error: nil,
Score: checker.MaxResultScore - 4,
NumberOfWarn: 4,
NumberOfInfo: 0,
NumberOfDebug: 0,
}
result := checks.BinaryArtifacts(&req)
// New version.
Expect(scut.ValidateTestReturn(nil, "binary artifacts", &expected, &result, &dl)).Should(BeTrue())
Expect(repoClient.Close()).Should(BeNil())
})
})
Expand Down

0 comments on commit bf582c1

Please sign in to comment.