Projects STRLCPY scorecard Commits 236b2964
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    checks/raw/vulnerabilities.go
    skipped 14 lines
    15 15  package raw
    16 16   
    17 17  import (
    18  - "errors"
    19 18   "fmt"
    20 19   
    21 20   "github.com/ossf/scorecard/v4/checker"
    22 21   "github.com/ossf/scorecard/v4/clients"
    23 22  )
    24  - 
    25  -var errNoCommitFound = errors.New("no commit found")
    26 23   
    27 24  // Vulnerabilities retrieves the raw data for the Vulnerabilities check.
    28 25  func Vulnerabilities(c *checker.CheckRequest) (checker.VulnerabilitiesData, error) {
    skipped 2 lines
    31 28   return checker.VulnerabilitiesData{}, fmt.Errorf("repoClient.ListCommits: %w", err)
    32 29   }
    33 30   
    34  - if len(commits) < 1 || commits[0].SHA == "" {
    35  - return checker.VulnerabilitiesData{}, fmt.Errorf("%w", errNoCommitFound)
     31 + if len(commits) < 1 || allOf(commits, hasEmptySHA) {
     32 + return checker.VulnerabilitiesData{}, nil
    36 33   }
    37 34   
    38 35   resp, err := c.VulnerabilitiesClient.HasUnfixedVulnerabilities(c.Ctx, commits[0].SHA)
    skipped 11 lines
    50 47   vulns = append(vulns, v)
    51 48   }
    52 49   return checker.VulnerabilitiesData{Vulnerabilities: vulns}, nil
     50 +}
     51 + 
     52 +type predicateOnCommitFn func(clients.Commit) bool
     53 + 
     54 +var hasEmptySHA predicateOnCommitFn = func(c clients.Commit) bool {
     55 + return c.SHA == ""
     56 +}
     57 + 
     58 +func allOf(commits []clients.Commit, predicate func(clients.Commit) bool) bool {
     59 + for i := range commits {
     60 + if !predicate(commits[i]) {
     61 + return false
     62 + }
     63 + }
     64 + return true
    53 65  }
    54 66   
    55 67  func getVulnerabilities(resp *clients.VulnerabilitiesResponse) []string {
    skipped 7 lines
  • ■ ■ ■ ■ ■ ■
    checks/raw/vulnerabilities_test.go
    skipped 53 lines
    54 54   vulnsResponse: clients.VulnerabilitiesResponse{},
    55 55   },
    56 56   {
    57  - name: "err response",
    58  - wantErr: true,
     57 + name: "no commits",
     58 + wantErr: false,
    59 59   numberofCommits: 0,
    60 60   vulnsResponse: clients.VulnerabilitiesResponse{},
    61 61   },
    skipped 60 lines
  • ■ ■ ■ ■ ■ ■
    cron/format/json.go
    skipped 92 lines
    93 93   Metadata: r.Metadata,
    94 94   }
    95 95   
    96  - //nolint
     96 +
    97 97   for _, checkResult := range r.Checks {
    98 98   tmpResult := jsonCheckResult{
    99 99   Name: checkResult.Name,
    skipped 42 lines
    142 142   AggregateScore: jsonFloatScore(score),
    143 143   }
    144 144   
    145  - //nolint
     145 +
    146 146   for _, checkResult := range r.Checks {
    147 147   doc, e := checkDocs.GetCheck(checkResult.Name)
    148 148   if e != nil {
    skipped 31 lines
Please wait...
Page is in error, reload to recover