Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions commands/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,11 @@ func initAuditCmdResults(params *AuditParams) (cmdResults *results.SecurityComma
cmdResults.SetEntitledForJas(entitledForJas)
}
if entitledForJas {
if utils.IsJASRequested(cmdResults.CmdType, params.ScansToPerform()...) {
if err = jas.ValidateRequiredInstalledSoftware(); err != nil {
return cmdResults.AddGeneralError(err, false)
}
}
cmdResults.SetSecretValidation(jas.CheckForSecretValidation(xrayManager, params.GetXrayVersion(), slices.Contains(params.ScansToPerform(), utils.SecretTokenValidationScan)))
}
return
Expand Down
5 changes: 5 additions & 0 deletions commands/scan/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ func (scanCmd *ScanCommand) initScanCmdResults(cmdType utils.CommandType) (xrayM
} else {
cmdResults.SetEntitledForJas(entitledForJas)
if entitledForJas {
if utils.IsJASRequested(cmdResults.CmdType, scanCmd.scansToPerform...) {
if err = jas.ValidateRequiredInstalledSoftware(); err != nil {
return xrayManager, cmdResults.AddGeneralError(err, false)
}
}
cmdResults.SetSecretValidation(jas.CheckForSecretValidation(xrayManager, scanCmd.xrayVersion, scanCmd.validateSecrets))
}
}
Expand Down
13 changes: 13 additions & 0 deletions jas/analyzermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ const (

type JasDiffScanEnvValue string

var scannersRequiredInstalledSoftware = []string{
"git", "unzip", "curl",
}

var exitCodeErrorsMap = map[int]string{
notEntitledExitCode: "got not entitled error from analyzer manager",
unsupportedCommandExitCode: "got unsupported scan command error from analyzer manager",
Expand Down Expand Up @@ -327,3 +331,12 @@ func RunAnalyzerManagerWithPipesAndDownload(envVars map[string]string, cmd strin
}
return RunAnalyzerManagerWithPipes(envVars, cmd, inputPipe, outputPipe, errorPipe, timeout, args...)
}

func ValidateRequiredInstalledSoftware() (err error) {
for _, software := range scannersRequiredInstalledSoftware {
if softwarePath, e := exec.LookPath(software); e != nil || softwarePath == "" {
err = errors.Join(err, fmt.Errorf("could not find the required '%s' executable in the system PATH to run the Advanced Security Scans", software))
}
}
return
}
Loading