MCPcopy
hub / github.com/ossf/scorecard / Vulnerabilities

Function Vulnerabilities

checks/raw/vulnerabilities.go:25–43  ·  view source on GitHub ↗

Vulnerabilities retrieves the raw data for the Vulnerabilities check.

(c *checker.CheckRequest)

Source from the content-addressed store, hash-verified

23
24// Vulnerabilities retrieves the raw data for the Vulnerabilities check.
25func Vulnerabilities(c *checker.CheckRequest) (checker.VulnerabilitiesData, error) {
26 commitHash := ""
27 commits, err := c.RepoClient.ListCommits()
28 if err == nil && len(commits) > 0 && !allOf(commits, hasEmptySHA) {
29 commitHash = commits[0].SHA
30 }
31
32 localPath, err := c.RepoClient.LocalPath()
33 if err != nil {
34 return checker.VulnerabilitiesData{}, fmt.Errorf("RepoClient.LocalPath: %w", err)
35 }
36 resp, err := c.VulnerabilitiesClient.ListUnfixedVulnerabilities(c.Ctx, commitHash, localPath)
37 if err != nil {
38 return checker.VulnerabilitiesData{}, fmt.Errorf("vulnerabilitiesClient.ListUnfixedVulnerabilities: %w", err)
39 }
40 return checker.VulnerabilitiesData{
41 Vulnerabilities: resp.Vulnerabilities,
42 }, nil
43}
44
45type predicateOnCommitFn func(clients.Commit) bool
46

Callers 3

VulnerabilitiesFunction · 0.92
assignRawDataFunction · 0.92
TestVulnerabilitiesFunction · 0.70

Calls 4

allOfFunction · 0.85
ListCommitsMethod · 0.65
LocalPathMethod · 0.65

Tested by 1

TestVulnerabilitiesFunction · 0.56