Skip to content

Commit

Permalink
improving warning log and adding debug prints for POC checks
Browse files Browse the repository at this point in the history
  • Loading branch information
eranturgeman committed Sep 22, 2024
1 parent 6943f32 commit 72bc2fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions commands/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-cli-security/utils/xray/scangraph"
"github.com/jfrog/jfrog-cli-security/utils/xsc"
"github.com/jfrog/jfrog-client-go/utils/log"
"golang.org/x/exp/slices"

xrayutils "github.com/jfrog/jfrog-cli-security/utils/xray"
Expand Down Expand Up @@ -196,6 +197,9 @@ func RunAudit(auditParams *AuditParams) (results *utils.Results, err error) {
}
jasScanner := &jas.JasScanner{}
if results.ExtendedScanResults.EntitledForJas {
log.Debug(fmt.Sprintf("Server details Nil check [after checking Jas entitlement]: serverDetails == nil -> %t", serverDetails == nil))
log.Debug(fmt.Sprintf("Server details URL check [after checking Jas entitlement]: %s", serverDetails.Url))
log.Debug(fmt.Sprintf("Server details Xray URL check [after checking Jas entitlement]: %s", serverDetails.XrayUrl))
// Download (if needed) the analyzer manager and run scanners.
auditParallelRunner.JasWg.Add(1)
if _, jasErr := auditParallelRunner.Runner.AddTaskWithError(func(threadId int) error {
Expand Down Expand Up @@ -256,6 +260,9 @@ func downloadAnalyzerManagerAndRunScanners(auditParallelRunner *utils.SecurityPa
if err != nil {
return fmt.Errorf("failed to create jas scanner: %s", err.Error())
}
log.Debug(fmt.Sprintf("Server details Nil check [before entering AddJasScannersTasks]: serverDetails == nil -> %t", serverDetails == nil))
log.Debug(fmt.Sprintf("Server details URL check [before entering AddJasScannersTasks]: %s", serverDetails.Url))
log.Debug(fmt.Sprintf("Server details Xray URL check [before entering AddJasScannersTasks]: %s", serverDetails.XrayUrl))
if err = runner.AddJasScannersTasks(auditParallelRunner, scanResults, auditParams.DirectDependencies(), serverDetails, auditParams.thirdPartyApplicabilityScan, scanner, applicability.ApplicabilityScannerType, secrets.SecretsScannerType, auditParallelRunner.AddErrorToChan, auditParams.ScansToPerform(), auditParams.configProfile, auditParams.scanResultsOutputDir); err != nil {
return fmt.Errorf("%s failed to run JAS scanners: %s", clientutils.GetLogMsgPrefix(threadId, false), err.Error())
}
Expand Down
5 changes: 4 additions & 1 deletion jas/runner/jasrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import (
func AddJasScannersTasks(securityParallelRunner *utils.SecurityParallelRunner, scanResults *utils.Results, directDependencies *[]string,
serverDetails *config.ServerDetails, thirdPartyApplicabilityScan bool, scanner *jas.JasScanner, scanType applicability.ApplicabilityScanType,
secretsScanType secrets.SecretsScanType, errHandlerFunc func(error), scansToPreform []utils.SubScanType, configProfile *services.ConfigProfile, scansOutputDir string) (err error) {
log.Debug(fmt.Sprintf("Server details Nil check [before initiating JAS scanners]: serverDetails == nil -> %t", serverDetails == nil))
log.Debug(fmt.Sprintf("Server details URL check [before initiating JAS scanners]: %s", serverDetails.Url))

Check failure on line 27 in jas/runner/jasrunner.go

View workflow job for this annotation

GitHub Actions / Static-Check

SA5011: possible nil pointer dereference (staticcheck)
log.Debug(fmt.Sprintf("Server details Xray URL check [before initiating JAS scanners]: %s", serverDetails.XrayUrl))

Check failure on line 28 in jas/runner/jasrunner.go

View workflow job for this annotation

GitHub Actions / Static-Check

SA5011: possible nil pointer dereference (staticcheck)
if serverDetails == nil || len(serverDetails.Url) == 0 {

Check failure on line 29 in jas/runner/jasrunner.go

View workflow job for this annotation

GitHub Actions / Static-Check

SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
log.Warn("To include 'Advanced Security' scan as part of the audit output, please run the 'jf c add' command before running this command.")
log.Warn("To include 'Advanced Security' scan as part of the audit output:\n1) Run the 'jf c add' command before running this command, if using 'audit' from CLI.\n2) Validate JF_URL is properly defined and passed if using Frogbot.")
return
}
// For docker scan we support only secrets and contextual scans.
Expand Down

0 comments on commit 72bc2fe

Please sign in to comment.