Skip to content

Commit

Permalink
fix: check for vulnerabilities presence
Browse files Browse the repository at this point in the history
  • Loading branch information
mhrabovcin committed Feb 19, 2024
1 parent 8ba7f98 commit e548b82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/actions/copacetic-action/pkg/image/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ func (r *Report) WriteTo(path string) error {
return os.WriteFile(path, data, 0o755)
}

func (r *Report) Vulnerabilities() []types.DetectedVulnerability {
vulnerabilities := []types.DetectedVulnerability{}
for _, resultClass := range r.Results {
vulnerabilities = append(vulnerabilities, resultClass.Vulnerabilities...)
}
return vulnerabilities
}

type CmdErr struct {
Err error
Stdout []byte
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/copacetic-action/pkg/patch/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ func Run(ctx context.Context, imageRef string, reg registry.Registry, imageTagSu
return withErr(t, err), err
}

if len(report.Results) == 0 {
if len(report.Vulnerabilities()) == 0 {
logger.Info("no fixable vulnerabilities found in scanned image", "scannedImage", imagePatch.Scanned)
return t, nil
}

logger.Info("found patchable vulnerabilities", "report", report.Results)
logger.Info("found patchable vulnerabilities", "vulnerabilites", report.Vulnerabilities())

buildId, err := randutil.Alphanumeric(5)
logger.Info("generated unique buildId", "buildId", buildId)
Expand Down

0 comments on commit e548b82

Please sign in to comment.