Skip to content

Commit 94dca7e

Browse files
modified excluded engine type for agent Visual Studio
1 parent d6cc44a commit 94dca7e

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
@@ -1160,7 +1160,7 @@ func filterScsResultsByAgent(results *wrappers.ScanResultsCollection, agent stri
11601160
commonParams.VSCodeAgent: {commonParams.SCSScorecardType},
11611161
commonParams.JetbrainsAgent: {commonParams.SCSScorecardType, commonParams.SCSSecretDetectionType},
11621162
commonParams.EclipseAgent: {commonParams.SCSScorecardType, commonParams.SCSSecretDetectionType},
1163-
commonParams.VisualStudioAgent: {commonParams.SCSScorecardType, commonParams.SCSSecretDetectionType},
1163+
commonParams.VisualStudioAgent: {commonParams.SCSScorecardType},
11641164
}
11651165

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

internal/commands/result_test.go

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

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

0 commit comments

Comments
 (0)