Skip to content

Commit

Permalink
Check OSS-Fuzz using project list
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Schrock <sschrock@google.com>
  • Loading branch information
spencerschrock committed Mar 1, 2023
1 parent 8add330 commit 5335f4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 12 additions & 10 deletions checks/raw/fuzzing.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package raw
import (
"bytes"
"fmt"
"io"
"net/http"
"regexp"
"strings"

Expand All @@ -29,6 +31,7 @@ import (

const (
fuzzerOSSFuzz = "OSSFuzz"
ossFuzzProjectURL = "https://oss-fuzz-build-logs.storage.googleapis.com/status.json"
fuzzerClusterFuzzLite = "ClusterFuzzLite"
oneFuzz = "OneFuzz"
fuzzerBuiltInGo = "GoBuiltInFuzzer"
Expand Down Expand Up @@ -167,20 +170,19 @@ func checkOneFuzz(c *checker.CheckRequest) (bool, error) {
}

func checkOSSFuzz(c *checker.CheckRequest) (bool, error) {
if c.OssFuzzRepo == nil {
return false, nil
resp, err := http.Get(ossFuzzProjectURL)
if err != nil {
return false, sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("http.Get: %v", err))
}

req := clients.SearchRequest{
Query: c.RepoClient.URI(),
Filename: "project.yaml",
defer resp.Body.Close()
if resp.StatusCode >= 400 {
return false, sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("fetch OSS-Fuzz project list: %s", resp.Status))
}
result, err := c.OssFuzzRepo.Search(req)
body, err := io.ReadAll(resp.Body)
if err != nil {
e := sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("Client.Search.Code: %v", err))
return false, e
return false, sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("io.ReadAll: %v", err))
}
return result.Hits > 0, nil
return bytes.Contains(body, []byte(c.RepoClient.URI())), nil
}

func checkFuzzFunc(c *checker.CheckRequest, lang clients.LanguageName) (bool, []checker.File, error) {
Expand Down
2 changes: 0 additions & 2 deletions e2e/fuzzing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (
var _ = Describe("E2E TEST:"+checks.CheckFuzzing, func() {
Context("E2E TEST:Validating use of fuzzing tools", func() {
It("Should return use of OSS-Fuzz", func() {
//nolint:lll
Skip("Skipping OSS-Fuzz test due to issues searching google/oss-fuzz with the REST API. https://github.com/ossf/scorecard/issues/2670")
dl := scut.TestDetailLogger{}
repo, err := githubrepo.MakeGithubRepo("tensorflow/tensorflow")
Expect(err).Should(BeNil())
Expand Down

0 comments on commit 5335f4b

Please sign in to comment.