Skip to content

Commit

Permalink
fix(trivy): Sanitize image names that contains slashs
Browse files Browse the repository at this point in the history
  • Loading branch information
julienvey committed Dec 13, 2022
1 parent 8f240e3 commit e35dbf3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/trivy/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"os"
"path"
"strings"

"github.com/radiofrance/dib/pkg/types"
)
Expand Down Expand Up @@ -53,7 +54,8 @@ func (b TestRunner) RunTest(opts types.RunTestOptions) error {
if err != nil {
return fmt.Errorf("failed to create directory %s: %w", path.Join(opts.ReportRootDir, "trivy"), err)
}
filePath := path.Join(opts.ReportRootDir, "trivy", fmt.Sprintf("%s.json", opts.ImageName))
filePath := path.Join(opts.ReportRootDir, "trivy",
fmt.Sprintf("%s.json", strings.ReplaceAll(opts.ImageName, "/", "_")))
fileOutput, err := os.Create(filePath)
if err != nil {
return fmt.Errorf("failed to create file %s: %w", filePath, err)
Expand Down

0 comments on commit e35dbf3

Please sign in to comment.