Vulnerabilities retrieves the raw data for the Vulnerabilities check.
(c *checker.CheckRequest)
| 23 | |
| 24 | // Vulnerabilities retrieves the raw data for the Vulnerabilities check. |
| 25 | func 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 | |
| 45 | type predicateOnCommitFn func(clients.Commit) bool |
| 46 |