Skip to content

Commit 9b642fe

Browse files
Merge branch 'main' into feature/saraChen/addStateIDToTriageShow
2 parents d098490 + 69a3b47 commit 9b642fe

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

internal/commands/predicates.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func NewResultsPredicatesCommand(resultsPredicatesWrapper wrappers.ResultsPredic
3535
func triageGetStatesSubCommand(customStatesWrapper wrappers.CustomStatesWrapper) *cobra.Command {
3636
triageGetStatesCmd := &cobra.Command{
3737
Use: "get-states",
38-
Short: "Fetch and display custom states.",
39-
Long: "Retrieves a list of custom states and prints their names.",
38+
Short: "Show the custom states that have been configured in your tenant",
39+
Long: "The get-states command shows information about each of the custom states that have been configured in your tenant account",
4040
Example: heredoc.Doc(
4141
`
4242
$ cx triage get-states
@@ -46,7 +46,7 @@ func triageGetStatesSubCommand(customStatesWrapper wrappers.CustomStatesWrapper)
4646
RunE: runTriageGetStates(customStatesWrapper),
4747
}
4848

49-
triageGetStatesCmd.PersistentFlags().Bool(params.AllStatesFlag, false, "Include deleted states")
49+
triageGetStatesCmd.PersistentFlags().Bool(params.AllStatesFlag, false, "Show all custom states, including the ones that have been deleted")
5050

5151
return triageGetStatesCmd
5252
}

internal/commands/result.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -986,9 +986,14 @@ func runGetResultCommand(
986986
return errors.Errorf("%s: CODE: %d, %s", failedGettingScan, errorModel.Code, errorModel.Message)
987987
}
988988

989-
policyResponseModel, err := services.HandlePolicyEvaluation(cmd, policyWrapper, scan, ignorePolicy, agent, waitDelay, policyTimeout)
990-
if err != nil {
991-
return err
989+
var policyResponseModel *wrappers.PolicyResponseModel
990+
if !isScanPending(string(scan.Status)) {
991+
policyResponseModel, err = services.HandlePolicyEvaluation(cmd, policyWrapper, scan, ignorePolicy, agent, waitDelay, policyTimeout)
992+
if err != nil {
993+
return err
994+
}
995+
} else {
996+
logger.PrintIfVerbose("Policy violations aren't returned in the pipeline for scans run in async mode.")
992997
}
993998

994999
if sastRedundancy {

test/integration/scan_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,3 +2135,32 @@ func TestScanCreate_WithContainerFilterFlagsAndResubmitFlag_CreatingScanWithLate
21352135
assert.Equal(t, createdScanConfig.Value[commands.ConfigContainersImagesFilterKey], "*dev", "Image tag filter should be equal")
21362136
assert.Equal(t, createdScanConfig.Value[commands.ConfigContainersPackagesFilterKey], "^internal-.*", "Package filter should be equal")
21372137
}
2138+
2139+
func TestCreateScanWithAsyncFlag_TryShowResults_PolicyNotEvaluated(t *testing.T) {
2140+
createASTIntegrationTestCommand(t)
2141+
configuration.LoadConfiguration()
2142+
args := []string{
2143+
"scan", "create",
2144+
flag(params.ProjectName), getProjectNameForScanTests(),
2145+
flag(params.SourcesFlag), Zip,
2146+
flag(params.ScanTypes), "sast,iac-security,sca",
2147+
flag(params.BranchFlag), "main",
2148+
flag(params.AsyncFlag),
2149+
flag(params.ScanInfoFormatFlag), printer.FormatJSON,
2150+
}
2151+
scanID, _ := executeCreateScan(t, args)
2152+
assert.Assert(t, scanID != "", "Scan ID should not be empty")
2153+
2154+
var buf bytes.Buffer
2155+
log.SetOutput(&buf)
2156+
2157+
_ = executeCmdNilAssertion(
2158+
t, "Results show generating JSON report with options should pass",
2159+
"results", "show",
2160+
flag(params.ScanIDFlag), scanID,
2161+
flag(params.TargetFormatFlag), printer.FormatSummaryConsole,
2162+
flag(params.DebugFlag),
2163+
)
2164+
log.SetOutput(os.Stderr)
2165+
assert.Assert(t, strings.Contains(buf.String(), "Policy violations aren't returned in the pipeline for scans run in async mode."), "policy shouldn't evaluate in running scan")
2166+
}

0 commit comments

Comments
 (0)