Skip to content

Commit bbca1ad

Browse files
Merge pull request #1295 from Checkmarx/feature/AST-110820
2 parents dd4e250 + a7268f2 commit bbca1ad

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

internal/commands/result.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ func filterScsResultsByAgent(results *wrappers.ScanResultsCollection, agent stri
11611161
commonParams.VSCodeAgent: {commonParams.SCSScorecardType},
11621162
commonParams.JetbrainsAgent: {commonParams.SCSScorecardType},
11631163
commonParams.EclipseAgent: {commonParams.SCSScorecardType, commonParams.SCSSecretDetectionType},
1164-
commonParams.VisualStudioAgent: {commonParams.SCSScorecardType, commonParams.SCSSecretDetectionType},
1164+
commonParams.VisualStudioAgent: {commonParams.SCSScorecardType},
11651165
}
11661166

11671167
excludedTypes := make(map[string]struct{})

internal/commands/result_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,54 @@ func TestRunNilResults_Other_AgentsShouldNotShowAnyResults(t *testing.T) {
242242
removeFileBySuffix(t, printer.FormatJSON)
243243
}
244244

245+
func TestRunScsResultsShow_Other_AgentShouldShowSCSResults(t *testing.T) {
246+
clearFlags()
247+
mock.HasScs = true
248+
mock.ScsScanPartial = false
249+
mock.ScorecardScanned = true
250+
mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true}
251+
252+
execCmdNilAssertion(t, "results", "show", "--scan-id", "SCS_ONLY", "--report-format", "json", "--agent", params.VisualStudioAgent)
253+
assertTypePresentJSON(t, params.SCSScorecardType, 0)
254+
assertTypePresentJSON(t, params.SCSSecretDetectionType, 2)
255+
assertTotalCountJSON(t, 2)
256+
257+
removeFileBySuffix(t, printer.FormatJSON)
258+
mock.SetScsMockVarsToDefault()
259+
}
260+
261+
func TestFilterScsResultsByAgent_ShouldIncludeSCSAndSAST(t *testing.T) {
262+
results := &wrappers.ScanResultsCollection{
263+
Results: []*wrappers.ScanResult{
264+
{Type: params.SCSScorecardType},
265+
{Type: params.ScsType},
266+
{Type: params.SastType},
267+
},
268+
}
269+
270+
filteredResults := filterScsResultsByAgent(results, params.VisualStudioAgent)
271+
272+
hasSCS := false
273+
hasSCSScorecard := false
274+
hasSAST := false
275+
276+
for _, result := range filteredResults.Results {
277+
switch result.Type {
278+
case params.ScsType:
279+
hasSCS = true
280+
case params.SCSScorecardType:
281+
hasSCSScorecard = true
282+
case params.SastType:
283+
hasSAST = true
284+
}
285+
}
286+
287+
assert.Assert(t, hasSCS, "Expected SCS type to be included for Visual Studio agent")
288+
assert.Assert(t, !hasSCSScorecard, "Expected SCSScorecard type to be excluded for Visual Studio agent")
289+
assert.Assert(t, hasSAST, "Expected SAST type to be excluded for Visual Studio agent")
290+
assert.Equal(t, len(filteredResults.Results), 2, "Expected 2 results (SCS and SAST) after filtering for Visual Studio agent")
291+
}
292+
245293
func TestResultsExitCode_OnCanceledScan_PrintOnlyScanIDAndStatusCanceledToConsole(t *testing.T) {
246294
model := wrappers.ScanResponseModel{
247295
ID: "fake-scan-id-kics-fail-sast-canceled-id",

0 commit comments

Comments
 (0)