Skip to content
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

improving SCA exploitable path validations #594

Merged
merged 6 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions internal/commands/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -2419,9 +2419,8 @@ func validateCreateScanFlags(cmd *cobra.Command) error {
exploitablePath, _ := cmd.Flags().GetString(commonParams.ExploitablePathFlag)
lastSastScanTime, _ := cmd.Flags().GetString(commonParams.LastSastScanTime)
exploitablePath = strings.ToLower(exploitablePath)
if !strings.Contains(strings.ToLower(actualScanTypes), commonParams.SastType) &&
(exploitablePath != "" || lastSastScanTime != "") {
return errors.Errorf("Please to use either --sca-exploitable-path or --sca-last-sast-scan-time flags in SCA, " +
if !strings.Contains(strings.ToLower(actualScanTypes), commonParams.SastType) && strings.EqualFold(exploitablePath, trueString) {
return errors.Errorf("Please to use --sca-exploitable-path flag in SCA, " +
"you must enable SAST scan type.")
}
err := validateBooleanString(exploitablePath)
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func TestCreateScanProjecGroupsError(t *testing.T) {
assert.Error(t, err, "Failed updating a project: Failed finding groups: [err]", err.Error())
}
func TestScanCreateLastSastScanTimeWithInvalidValue(t *testing.T) {
baseArgs := []string{"scan", "create", "--project-name", "MOCK", "-s", dummyRepo, "-b", "dummy_branch", "--sca-last-sast-scan-time", "notaniteger"}
baseArgs := []string{"scan", "create", "--project-name", "MOCK", "-s", dummyRepo, "-b", "dummy_branch", "--sca-exploitable-path", "true", "--sca-last-sast-scan-time", "notaniteger"}
err := execCmdNotNilAssertion(t, baseArgs...)
assert.ErrorContains(t, err, "Invalid value for --sca-last-sast-scan-time flag", err.Error())
}
Expand Down
Loading