Skip to content

Commit 915c689

Browse files
authored
Fix audit diff err when target to compare not found (jfrog#499)
1 parent 07643b8 commit 915c689

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

commands/audit/audit.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,19 +375,14 @@ func populateScanTargets(cmdResults *results.SecurityCommandResults, params *Aud
375375
// No need to generate the SBOM if we are not going to use it.
376376
continue
377377
}
378-
targetResultsToCompare, err := getTargetResultsToCompare(cmdResults, params.ResultsToCompare(), targetResult)
379-
if err != nil {
380-
cmdResults.AddGeneralError(fmt.Errorf("failed to get target results to compare: %s", err.Error()), false)
381-
continue
382-
}
383378
bom.GenerateSbomForTarget(params.BomGenerator().WithOptions(buildinfo.WithDescriptors(targetResult.GetDescriptors())),
384379
bom.SbomGeneratorParams{
385380
Target: targetResult,
386381
AllowPartialResults: params.AllowPartialResults(),
387382
ScanResultsOutputDir: params.scanResultsOutputDir,
388383
// Diff mode - SCA
389384
DiffMode: params.DiffMode(),
390-
TargetResultToCompare: targetResultsToCompare,
385+
TargetResultToCompare: getTargetResultsToCompare(cmdResults, params.ResultsToCompare(), targetResult),
391386
},
392387
)
393388
}
@@ -399,16 +394,18 @@ func populateScanTargets(cmdResults *results.SecurityCommandResults, params *Aud
399394
log.Info(fmt.Sprintf("Performing scans on %d targets:\n%s", len(cmdResults.Targets), scanInfo))
400395
}
401396

402-
func getTargetResultsToCompare(cmdResults, resultsToCompare *results.SecurityCommandResults, targetResult *results.TargetResults) (targetResultsToCompare *results.TargetResults, err error) {
397+
func getTargetResultsToCompare(cmdResults, resultsToCompare *results.SecurityCommandResults, targetResult *results.TargetResults) (targetResultsToCompare *results.TargetResults) {
403398
if resultsToCompare == nil {
404399
return
405400
}
406401
targetResultsToCompare = results.SearchTargetResultsByRelativePath(
407402
utils.GetRelativePath(targetResult.Target, cmdResults.GetCommonParentPath()),
408403
resultsToCompare,
409404
)
405+
// Let's check if the target results to compare are valid.
406+
// If the current target result is a new module, it will not have any previous target results to compare with.
410407
if targetResultsToCompare == nil || targetResultsToCompare.ScaResults == nil || targetResultsToCompare.ScaResults.Sbom == nil {
411-
err = fmt.Errorf("no target results found to compare")
408+
log.Debug(fmt.Sprintf("No previous target results found to compare with for %s", targetResult.Target))
412409
}
413410
return
414411
}

jas/analyzermanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
const (
2626
ApplicabilityFeatureId = "contextual_analysis"
2727
AnalyzerManagerZipName = "analyzerManager.zip"
28-
defaultAnalyzerManagerVersion = "1.21.4"
28+
defaultAnalyzerManagerVersion = "1.22.0"
2929
analyzerManagerDownloadPath = "xsc-gen-exe-analyzer-manager-local/v1"
3030
analyzerManagerDirName = "analyzerManager"
3131
analyzerManagerExecutableName = "analyzerManager"

0 commit comments

Comments
 (0)