From 94dca7e96f1867641920cb22257de7ba8c9a73d2 Mon Sep 17 00:00:00 2001 From: Rah Pid <206018639+cx-rah-pid@users.noreply.github.com> Date: Fri, 29 Aug 2025 17:16:54 +0530 Subject: [PATCH 1/2] modified excluded engine type for agent Visual Studio --- internal/commands/result.go | 2 +- internal/commands/result_test.go | 48 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/internal/commands/result.go b/internal/commands/result.go index 585e8f384..eaac7bcb5 100644 --- a/internal/commands/result.go +++ b/internal/commands/result.go @@ -1160,7 +1160,7 @@ func filterScsResultsByAgent(results *wrappers.ScanResultsCollection, agent stri commonParams.VSCodeAgent: {commonParams.SCSScorecardType}, commonParams.JetbrainsAgent: {commonParams.SCSScorecardType, commonParams.SCSSecretDetectionType}, commonParams.EclipseAgent: {commonParams.SCSScorecardType, commonParams.SCSSecretDetectionType}, - commonParams.VisualStudioAgent: {commonParams.SCSScorecardType, commonParams.SCSSecretDetectionType}, + commonParams.VisualStudioAgent: {commonParams.SCSScorecardType}, } excludedTypes := make(map[string]struct{}) diff --git a/internal/commands/result_test.go b/internal/commands/result_test.go index 5558e7153..72eb52102 100644 --- a/internal/commands/result_test.go +++ b/internal/commands/result_test.go @@ -241,6 +241,54 @@ func TestRunNilResults_Other_AgentsShouldNotShowAnyResults(t *testing.T) { removeFileBySuffix(t, printer.FormatJSON) } +func TestRunScsResultsShow_Other_AgentShouldShowSCSResults(t *testing.T) { + clearFlags() + mock.HasScs = true + mock.ScsScanPartial = false + mock.ScorecardScanned = true + mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true} + + execCmdNilAssertion(t, "results", "show", "--scan-id", "SCS_ONLY", "--report-format", "json", "--agent", params.VisualStudioAgent) + assertTypePresentJSON(t, params.SCSScorecardType, 0) + assertTypePresentJSON(t, params.SCSSecretDetectionType, 2) + assertTotalCountJSON(t, 2) + + removeFileBySuffix(t, printer.FormatJSON) + mock.SetScsMockVarsToDefault() +} + +func TestFilterScsResultsByAgent_ShouldIncludeSCSAndSAST(t *testing.T) { + results := &wrappers.ScanResultsCollection{ + Results: []*wrappers.ScanResult{ + {Type: params.SCSScorecardType}, + {Type: params.ScsType}, + {Type: params.SastType}, + }, + } + + filteredResults := filterScsResultsByAgent(results, params.VisualStudioAgent) + + hasSCS := false + hasSCSScorecard := false + hasSAST := false + + for _, result := range filteredResults.Results { + switch result.Type { + case params.ScsType: + hasSCS = true + case params.SCSScorecardType: + hasSCSScorecard = true + case params.SastType: + hasSAST = true + } + } + + assert.Assert(t, hasSCS, "Expected SCS type to be included for Visual Studio agent") + assert.Assert(t, !hasSCSScorecard, "Expected SCSScorecard type to be excluded for Visual Studio agent") + assert.Assert(t, hasSAST, "Expected SAST type to be excluded for Visual Studio agent") + assert.Equal(t, len(filteredResults.Results), 2, "Expected 2 results (SCS and SAST) after filtering for Visual Studio agent") +} + func TestResultsExitCode_OnCanceledScan_PrintOnlyScanIDAndStatusCanceledToConsole(t *testing.T) { model := wrappers.ScanResponseModel{ ID: "fake-scan-id-kics-fail-sast-canceled-id", From ea11e398715dffc379193a4a009c912cbdb8fda8 Mon Sep 17 00:00:00 2001 From: Rah Pid <206018639+cx-rah-pid@users.noreply.github.com> Date: Wed, 10 Sep 2025 19:05:17 +0530 Subject: [PATCH 2/2] fixed resubmit scs issue --- internal/commands/scan.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/commands/scan.go b/internal/commands/scan.go index 5de62de5a..fdf20e749 100644 --- a/internal/commands/scan.go +++ b/internal/commands/scan.go @@ -1030,6 +1030,7 @@ func getResubmitConfiguration(scansWrapper wrappers.ScansWrapper, projectID, use if len(allScansModel.Scans) > 0 { scanModelResponse := allScansModel.Scans[0] + scanModelResponse.ReplaceMicroEnginesWithSCS() config = scanModelResponse.Metadata.Configs engines := scanModelResponse.Engines // Check if there are no scan types sent using the flags, and use the latest scan engine types