-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,17 +10,19 @@ import ( | |
"github.com/jfrog/jfrog-client-go/xray/services" | ||
xrayUtils "github.com/jfrog/jfrog-client-go/xray/services/utils" | ||
"os" | ||
"strings" | ||
) | ||
|
||
const serverDetailsErrorMessage = "cant get xray server details" | ||
|
||
var ( | ||
analyzerManagerExecuter utils.AnalyzerManagerInterface = &utils.AnalyzerManager{} | ||
skippedDirs = []string{"**/*test*/**", "**/*venv*/**", "**/*node_modules*/**", "**/*target*/**"} | ||
scannersToExclude = []string{} | ||
Comment on lines
19
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is not related to this PR, but is more general - One design pattern is to pass a pointer of the struct when needed to each one of the scanners. |
||
) | ||
|
||
func GetExtendedScanResults(xrayResults []services.ScanResponse, dependencyTrees []*xrayUtils.GraphNode, | ||
serverDetails *config.ServerDetails) (*utils.ExtendedScanResults, error) { | ||
serverDetails *config.ServerDetails, excludeScan string) (*utils.ExtendedScanResults, error) { | ||
if serverDetails == nil { | ||
return nil, errors.New(serverDetailsErrorMessage) | ||
} | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Let's also trim strings to allow for example: |
||
applicabilityScanResults, eligibleForApplicabilityScan, err := getApplicabilityScanResults(xrayResults, | ||
dependencyTrees, serverDetails, analyzerManagerExecuter) | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ const ( | |
secretsScannersNames = "tokens, entropy" | ||
secretsScannerType = "secrets-scan" | ||
secScanFailureMessage = "failed to run secrets scan. Cause: %s" | ||
secretsFeatureName = "secrets" | ||
) | ||
|
||
type SecretScanManager struct { | ||
|
@@ -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 commentThe 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 |
||
} | ||
if err = secretScanManager.run(); err != nil { | ||
if utils.IsNotEntitledError(err) || utils.IsUnsupportedCommandError(err) { | ||
return nil, false, nil | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -243,3 +243,12 @@ func GetResultSeverity(result *sarif.Result) string { | |||||||||||||||
} | ||||||||||||||||
return SeverityDefaultValue | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func ExcludeScan(scansToBeExcluded []string, scan string) bool { | ||||||||||||||||
for _, s := range scansToBeExcluded { | ||||||||||||||||
if s == scan { | ||||||||||||||||
return true | ||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
return false | ||||||||||||||||
Comment on lines
+248
to
+253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be inlined:
Suggested change
|
||||||||||||||||
} |
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