Skip to content

Commit

Permalink
improving SCA exploitable path validations (#594)
Browse files Browse the repository at this point in the history
* improving sca exploitable path validations

* error message

* review suggestions

* deleting unreachable unity test
  • Loading branch information
igorlombacx committed Oct 20, 2023
1 parent 215ddd1 commit baad8fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions internal/commands/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -2426,9 +2426,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

0 comments on commit baad8fb

Please sign in to comment.