Documentation
¶
Index ¶
- Constants
- Variables
- func BuildSecurityScanReportForRepo(tags []string, opts *options) error
- func GetSecurityScanReport(url string) (string, error)
- func GetTemplateFile(trivyTemplate string) (string, error)
- func IsImageNotFoundErr(logs string) bool
- func NewLatestPatchRepositoryReleasePredicate(releases []*github.RepositoryRelease) *latestPatchRepositoryReleasePredicate
- func NewSecurityScanRepositoryReleasePredicate(constraint *semver.Constraints) *securityScanRepositoryReleasePredicate
- func RootApp(ctx context.Context) *cobra.Command
- func RunTrivyScan(image, version, templateFile, output string) (bool, bool, error)
- type GithubIssueWriter
- type GithubRepo
- type SarifMetadata
- type SecurityScanOpts
- type SecurityScanRepo
- func (r *SecurityScanRepo) GetImagesToScan(versionToScan *semver.Version) ([]string, error)
- func (r *SecurityScanRepo) RunGithubSarifScan(release *github.RepositoryRelease, sarifTplFile string) error
- func (r *SecurityScanRepo) RunMarkdownScan(ctx context.Context, release *github.RepositoryRelease, markdownTplFile string) error
- func (r *SecurityScanRepo) UploadSecurityScanToGithub(fileName, versionTag string) error
- type SecurityScanner
Constants ¶
const MarkdownTrivyTemplate = `` /* 505-byte string literal not displayed */
Template for markdown docs
const SarifTrivyTemplate = `` /* 3578-byte string literal not displayed */
Template for Sarif files to be uploaded to Github, which displays results on the 'Security' tab. Taken from https://github.com/aquasecurity/trivy/blob/main/contrib/sarif.tpl
const VulnerabilityFoundStatusCode = 52
Status code returned by Trivy if a vulnerability is found
Variables ¶
var ( MissingGithubTokenError = func(envVar string) error { return eris.Errorf("Must either set GITHUB_TOKEN or set %s environment variable to true", envVar) } FileNotFoundError = func(path string, branch string) error { return eris.Errorf("Could not find file at path %s on branch %s", path, branch) } MalformedVersionImageConstraintLine = func(line string) error { return eris.Errorf("Could not properly split version image constraint line: %s", line) } )
Functions ¶
func BuildSecurityScanReportForRepo ¶ added in v0.21.20
func GetSecurityScanReport ¶ added in v0.21.20
func GetTemplateFile ¶
Create tempoarary file that contains the trivy template Trivy CLI only accepts files as input for a template, so this is a workaround
func IsImageNotFoundErr ¶
func NewLatestPatchRepositoryReleasePredicate ¶ added in v0.21.27
func NewLatestPatchRepositoryReleasePredicate(releases []*github.RepositoryRelease) *latestPatchRepositoryReleasePredicate
func NewSecurityScanRepositoryReleasePredicate ¶ added in v0.21.27
func NewSecurityScanRepositoryReleasePredicate(constraint *semver.Constraints) *securityScanRepositoryReleasePredicate
Types ¶
type GithubIssueWriter ¶ added in v0.21.27
type GithubIssueWriter struct {
// contains filtered or unexported fields
}
GithubIssueWriter is responsible for creating Github issues to track vulnerabilities that have been discovered in images within a release. It is configured with a Predicate that filters which releases to write issues for, and which to skip
func NewGithubIssueWriter ¶ added in v0.21.27
func NewGithubIssueWriter(repo GithubRepo, client *github.Client, issuePredicate githubutils.RepositoryReleasePredicate) *GithubIssueWriter
func (*GithubIssueWriter) CreateUpdateVulnerabilityIssue ¶ added in v0.21.27
func (g *GithubIssueWriter) CreateUpdateVulnerabilityIssue(ctx context.Context, release *github.RepositoryRelease, vulnerabilityMarkdown string) error
Creates/Updates a Github Issue per image The github issue will have the markdown table report of the image's vulnerabilities example: https://github.com/solo-io/solo-projects/issues/2458
type GithubRepo ¶ added in v0.21.27
func (GithubRepo) Address ¶ added in v0.21.27
func (r GithubRepo) Address() string
type SarifMetadata ¶
type SecurityScanOpts ¶
type SecurityScanOpts struct { // The following directory structure will be created in your output dir. /* OUTPUT_DIR/ ├─ markdown_results/ │ ├─ repo1/ │ │ ├─ 1.4.12/ │ │ ├─ 1.5.0/ │ ├─ repo2/ │ │ ├─ 1.4.13/ │ │ ├─ 1.5.1/ ├─ sarif_results/ │ ├─ repo1/ │ │ ├─ 1.4.12/ │ │ ├─ 1.5.0/ │ ├─ repo2/ │ │ ├─ 1.4.13/ │ │ ├─ 1.5.1/ */ OutputDir string // A mapping of version constraints to images scanned. // If 1.6 had images "gloo", "discovery" and 1.7 introduced a new image "rate-limit", // the map would look like: /* ' >= 1.6': ["gloo", "discovery"] ' >= 1.7': ["gloo", "discovery", "rate-limit"] */ // where the patch number is explicitly not set so that these versions can match all // 1.6.x-x releases ImagesPerVersion map[string][]string // VersionConstraint on releases to security scan // any releases that do not pass this constraint will not be security scanned. // If left empty, all versions will be scanned VersionConstraint *semver.Constraints // Required: image repo (quay.io, grc.io, gchr.io) ImageRepo string // Uploads Sarif file to github security code-scanning results // e.g. https://github.com/solo-io/gloo/security/code-scanning UploadCodeScanToGithub bool // Creates github issue if image vulnerabilities are found CreateGithubIssuePerVersion bool // Only create github issue if: // 1. Image vulnerabilities are found // 2. The version is the latest patch version (Major.Minor.Patch) // If set to true, will override the behavior of CreateGithubIssuePerVersion CreateGithubIssueForLatestPatchVersion bool }
type SecurityScanRepo ¶
type SecurityScanRepo struct { Repo string Owner string Opts *SecurityScanOpts // contains filtered or unexported fields }
func (*SecurityScanRepo) GetImagesToScan ¶
func (r *SecurityScanRepo) GetImagesToScan(versionToScan *semver.Version) ([]string, error)
func (*SecurityScanRepo) RunGithubSarifScan ¶
func (r *SecurityScanRepo) RunGithubSarifScan(release *github.RepositoryRelease, sarifTplFile string) error
func (*SecurityScanRepo) RunMarkdownScan ¶
func (r *SecurityScanRepo) RunMarkdownScan(ctx context.Context, release *github.RepositoryRelease, markdownTplFile string) error
func (*SecurityScanRepo) UploadSecurityScanToGithub ¶
func (r *SecurityScanRepo) UploadSecurityScanToGithub(fileName, versionTag string) error
Uploads Github security scan in .sarif file format to Github Security Tab under "Code Scanning"
type SecurityScanner ¶
type SecurityScanner struct { Repos []*SecurityScanRepo // contains filtered or unexported fields }
func (*SecurityScanner) GenerateSecurityScans ¶
func (s *SecurityScanner) GenerateSecurityScans(ctx context.Context) error
Main method to call on SecurityScanner which generates .md and .sarif files in OutputDir as defined above per repo. If UploadCodeScanToGithub is true, sarif files will be uploaded to the repository's code-scanning endpoint.