-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply allow-partial-results to JAS scans #223
Apply allow-partial-results to JAS scans #223
Conversation
…r capturing and handling (commented above them)
@@ -242,7 +242,8 @@ func RunJasScans(auditParallelRunner *utils.SecurityParallelRunner, auditParams | |||
} | |||
auditParallelRunner.JasWg.Add(1) | |||
if _, jasErr := auditParallelRunner.Runner.AddTaskWithError(createJasScansTasks(auditParallelRunner, scanResults, serverDetails, auditParams, jasScanner, jfrogAppsConfig), func(taskErr error) { | |||
generalError = errors.Join(generalError, fmt.Errorf("failed while adding JAS scan tasks: %s", taskErr.Error())) | |||
// TODO this change was for capturing a missed error that is coming from the threads | |||
scanResults.AddGeneralError(fmt.Errorf("failed while adding JAS scan tasks: %s", taskErr.Error()), auditParams.AllowPartialResults()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is a bug fix.
We missed capturing errors coming from the threads and tried to propagate them up the stack, where they "got lost" in the process or got override. This fix ensure we add the to the GeneralError so it will be examined later on in the process
} | ||
if generalError := runner.AddJasScannersTasks(params); generalError != nil { | ||
if generalError = runner.AddJasScannersTasks(params); generalError != nil { | ||
// TODO this fix was in order to avoid capturing the error twice when using partial-results. if this is disables the error is collected twice - once from the target error and once from general error | ||
_ = targetResult.AddTargetError(fmt.Errorf("%s failed to add JAS scan tasks: %s", logPrefix, generalError.Error()), auditParams.AllowPartialResults()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bug fix.
After adding the error to TargetError (or logging it if partial results are allowed) we left generalError as it was and it propagated up the stack and caught again later in the process. this caused the error to be logged twice.
After handling it, due to the new way we handle errors, there is no need to propagate the error by returning it after we handle it once
…sed value of allowPartial to the relevant funcs
Merging this branch will not change overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, see my comment
dev
branch.go vet ./...
.go fmt ./...
.This PR introduces improvement for the Allow-Partial-Results ability that was previously applied only on SCA scan and now is applied of JAS scans throughout its process.
This enables the code to capture failures and continue running even if some of the JAS scans have failed. Errors that we cannot continue after them remained as is and will fail the flow.
This is a continuance for this PR: #200