-
Notifications
You must be signed in to change notification settings - Fork 59
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
Exclude JAS Scan Flag #836
base: dev
Are you sure you want to change the base?
Conversation
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.
Looks good @orto17!
Please consider my inline comments.
@@ -48,6 +48,9 @@ func getIacScanResults(serverDetails *config.ServerDetails, analyzerManager util | |||
err = errors.Join(err, cleanupFunc()) | |||
} | |||
}() | |||
if utils.ExcludeScan(scannersToExclude, iacScanCommand) { | |||
return nil, false, nil |
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.
Let's add a debug level log that the IaC scan is skipped
analyzerManagerExecuter utils.AnalyzerManagerInterface = &utils.AnalyzerManager{} | ||
skippedDirs = []string{"**/*test*/**", "**/*venv*/**", "**/*node_modules*/**", "**/*target*/**"} | ||
scannersToExclude = []string{} |
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 comment is not related to this PR, but is more general -
Please prefer not to use global variables. Instead, the recommended way is to use a new JasManager struct.
One design pattern is to pass a pointer of the struct when needed to each one of the scanners.
Another design pattern is to use inheritance/decoration, whereby every scanner contains the JasManager struct.
@@ -39,6 +41,7 @@ func GetExtendedScanResults(xrayResults []services.ScanResponse, dependencyTrees | |||
if err = utils.CreateAnalyzerManagerLogDir(); err != nil { | |||
return nil, err | |||
} | |||
scannersToExclude = strings.Split(excludeScan, ";") |
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.
Let's also trim strings to allow for example: --exclude-scan=contextual_analysis; secrets
@@ -49,6 +50,9 @@ func getSecretsScanResults(serverDetails *config.ServerDetails, analyzerManager | |||
err = errors.Join(err, cleanupFunc()) | |||
} | |||
}() | |||
if utils.ExcludeScan(scannersToExclude, secretsFeatureName) { | |||
return nil, false, nil |
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.
Let's add a debug level log that the secret scan is skipped
for _, s := range scansToBeExcluded { | ||
if s == scan { | ||
return true | ||
} | ||
} | ||
return false |
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.
Can be inlined:
for _, s := range scansToBeExcluded { | |
if s == scan { | |
return true | |
} | |
} | |
return false | |
return slices.Contains(scansToBeExcluded, scan) |
This PR contains the following:
-exclude-scan=contextual_analysis;secrets