Skip to content

Commit

Permalink
fix: compare trivy scan results
Browse files Browse the repository at this point in the history
  • Loading branch information
mhrabovcin committed Feb 19, 2024
1 parent 7f39e49 commit 89fdc44
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .github/actions/copacetic-action/pkg/patch/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log/slog"
"os"
"reflect"

"github.com/google/go-containerregistry/pkg/name"
"go.step.sm/crypto/randutil"
Expand Down Expand Up @@ -59,7 +60,11 @@ func Run(ctx context.Context, imageRef string, reg registry.Registry, imageTagSu
return t, nil
}

logger.Info("found patchable vulnerabilities", "vulnerabilites", report.Vulnerabilities())
logger.Info(
"found patchable vulnerabilities",
"scanned", imagePatch.Scanned,
"vulnerabilites", report.Vulnerabilities(),
)

buildId, err := randutil.Alphanumeric(5)
logger.Info("generated unique buildId", "buildId", buildId)
Expand Down Expand Up @@ -100,6 +105,10 @@ func Run(ctx context.Context, imageRef string, reg registry.Registry, imageTagSu
"original", report.Vulnerabilities(),
"patched", patchedReport.Vulnerabilities(),
)
if reflect.DeepEqual(report.Vulnerabilities(), patchedReport.Vulnerabilities()) {
logger.Warn("no vulnerabilties were fixed by running copa", "scannedImage", imagePatch.Scanned)
return t, nil
}

// Add labels to the newly built image
labels := map[string]string{
Expand Down

0 comments on commit 89fdc44

Please sign in to comment.