Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions pkg/infrastructure/scanner/trivy.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ type trivyOS struct {
}

type trivyResult struct {
Target string `json:"Target"`
Class string `json:"Class"`
Type string `json:"Type"`
Vulnerabilities []trivyVuln `json:"Vulnerabilities"`
Secrets []trivySecret `json:"Secrets"`
Misconfigs []trivyMisconfig `json:"Misconfigurations"`
Licenses []trivyLicense `json:"Licenses"`
Target string `json:"Target"`
Class string `json:"Class"`
Type string `json:"Type"`
Vulnerabilities []trivyVuln `json:"Vulnerabilities"`
Secrets []trivySecret `json:"Secrets"`
Misconfigs []trivyMisconfig `json:"Misconfigurations"`
Licenses []trivyLicense `json:"Licenses"`
}

type trivyCVSS struct {
Expand Down Expand Up @@ -96,14 +96,16 @@ type trivyLicense struct {
func RunTrivy(imageName string, comprehensive bool) (*domain.TrivyResult, error) {
log.Infof("Running Trivy on: %s (comprehensive=%v)", imageName, comprehensive)

securityChecks := "vuln"
// Prefer --scanners (Trivy renamed --security-checks). Use "misconfig"
// rather than the deprecated "config" scanner name.
scanners := "vuln"
if comprehensive {
securityChecks = "vuln,secret,config"
scanners = "vuln,secret,misconfig"
}

cmd := exec.Command("trivy", "image",
"--format", "json",
"--security-checks", securityChecks,
"--scanners", scanners,
imageName,
)

Expand Down