diff --git a/internal/commands/result.go b/internal/commands/result.go index e55622976..1afab952d 100644 --- a/internal/commands/result.go +++ b/internal/commands/result.go @@ -603,11 +603,10 @@ func convertScanToResultsSummary(scanInfo *wrappers.ScanResponseModel, resultsWr *containersIssues = 0 enginesStatusCode[commonParams.ContainersType] = 0 } - if wrappers.IsSCSEnabled { - scsIssues = new(int) - *scsIssues = 0 - enginesStatusCode[commonParams.ScsType] = 0 - } + + scsIssues = new(int) + *scsIssues = 0 + enginesStatusCode[commonParams.ScsType] = 0 if len(scanInfo.StatusDetails) > 0 { for _, statusDetailItem := range scanInfo.StatusDetails { @@ -618,7 +617,7 @@ func convertScanToResultsSummary(scanInfo *wrappers.ScanResponseModel, resultsWr scaIssues = notAvailableNumber } else if statusDetailItem.Name == commonParams.KicsType { kicsIssues = notAvailableNumber - } else if statusDetailItem.Name == commonParams.ScsType && wrappers.IsSCSEnabled { + } else if statusDetailItem.Name == commonParams.ScsType { *scsIssues = notAvailableNumber } else if statusDetailItem.Name == commonParams.ContainersType && wrappers.IsContainersEnabled { *containersIssues = notAvailableNumber @@ -664,9 +663,9 @@ func convertScanToResultsSummary(scanInfo *wrappers.ScanResponseModel, resultsWr if wrappers.IsContainersEnabled { summary.EnginesResult[commonParams.ContainersType] = &wrappers.EngineResultSummary{StatusCode: enginesStatusCode[commonParams.ContainersType]} } - if wrappers.IsSCSEnabled { - summary.EnginesResult[commonParams.ScsType] = &wrappers.EngineResultSummary{StatusCode: enginesStatusCode[commonParams.ScsType]} - } + + summary.EnginesResult[commonParams.ScsType] = &wrappers.EngineResultSummary{StatusCode: enginesStatusCode[commonParams.ScsType]} + baseURI, err := resultsWrapper.GetResultsURL(summary.ProjectID) if err != nil { return nil, err @@ -703,7 +702,7 @@ func summaryReport( summary.APISecurity = *apiSecRisks } - if summary.HasSCS() && wrappers.IsSCSEnabled { + if summary.HasSCS() { // Getting the base SCS overview. Results counts are overwritten in enhanceWithScanSummary->countResult SCSOverview, err := getScanOverviewForSCSScanner(scsScanOverviewWrapper, summary.ScanID) if err != nil { @@ -721,12 +720,12 @@ func summaryReport( setNotAvailableNumberIfZero(summary, &summary.SastIssues, commonParams.SastType) setNotAvailableNumberIfZero(summary, &summary.ScaIssues, commonParams.ScaType) setNotAvailableNumberIfZero(summary, &summary.KicsIssues, commonParams.KicsType) + setNotAvailableNumberIfZero(summary, summary.ScsIssues, commonParams.ScsType) + if wrappers.IsContainersEnabled { setNotAvailableNumberIfZero(summary, summary.ContainersIssues, commonParams.ContainersType) } - if wrappers.IsSCSEnabled { - setNotAvailableNumberIfZero(summary, summary.ScsIssues, commonParams.ScsType) - } + setRiskMsgAndStyle(summary) setNotAvailableEnginesStatusCode(summary) @@ -783,7 +782,7 @@ func enhanceWithScanSummary(summary *wrappers.ResultSummary, results *wrappers.S summary.TotalIssues = summary.SastIssues + summary.ScaIssues + summary.KicsIssues + summary.GetAPISecurityDocumentationTotal() - if summary.HasSCS() && wrappers.IsSCSEnabled { + if summary.HasSCS() { // Special case for SCS where status is partial if any microengines failed if summary.SCSOverview.Status == scanPartialString { summary.EnginesResult[commonParams.ScsType].StatusCode = scanPartialNumber @@ -876,7 +875,7 @@ func writeConsoleSummary(summary *wrappers.ResultSummary, featureFlagsWrapper wr printAPIsSecuritySummary(summary) } - if summary.HasSCS() && wrappers.IsSCSEnabled { + if summary.HasSCS() { printSCSSummary(summary.SCSOverview.MicroEngineOverviews, featureFlagsWrapper) } @@ -991,9 +990,8 @@ func printResultsSummaryTable(summary *wrappers.ResultSummary) { printTableRow("IAC", summary.EnginesResult[commonParams.KicsType], summary.EnginesResult[commonParams.KicsType].StatusCode) printTableRow("SAST", summary.EnginesResult[commonParams.SastType], summary.EnginesResult[commonParams.SastType].StatusCode) printTableRow("SCA", summary.EnginesResult[commonParams.ScaType], summary.EnginesResult[commonParams.ScaType].StatusCode) - if wrappers.IsSCSEnabled { - printTableRow("SCS", summary.EnginesResult[commonParams.ScsType], summary.EnginesResult[commonParams.ScsType].StatusCode) - } + printTableRow("SCS", summary.EnginesResult[commonParams.ScsType], summary.EnginesResult[commonParams.ScsType].StatusCode) + if wrappers.IsContainersEnabled { printTableRow("CONTAINERS", summary.EnginesResult[commonParams.ContainersType], summary.EnginesResult[commonParams.ContainersType].StatusCode) } @@ -1133,11 +1131,6 @@ func runGetCodeBashingCommand( } } -func setIsSCSEnabled(featureFlagsWrapper wrappers.FeatureFlagsWrapper) { - scsEngineCLIEnabled, _ := wrappers.GetSpecificFeatureFlag(featureFlagsWrapper, wrappers.SCSEngineCLIEnabled) - wrappers.IsSCSEnabled = scsEngineCLIEnabled.Status -} - func setIsContainersEnabled(agent string) { wrappers.IsContainersEnabled = !containsIgnoreCase(containerEngineUnsupportedAgents, agent) } @@ -1199,7 +1192,6 @@ func CreateScanReport( ) (*wrappers.ScanResultsCollection, error) { reportList := strings.Split(reportTypes, ",") results := &wrappers.ScanResultsCollection{} - setIsSCSEnabled(featureFlagsWrapper) setIsContainersEnabled(agent) summary, err := convertScanToResultsSummary(scan, resultsWrapper) if err != nil { @@ -1255,14 +1247,10 @@ func countResult(summary *wrappers.ResultSummary, result *wrappers.ScanResult) { return } } else if strings.HasPrefix(engineType, commonParams.SscsType) { - if wrappers.IsSCSEnabled { - addResultToSCSOverview(summary, result) - engineType = commonParams.ScsType - *summary.ScsIssues++ - summary.TotalIssues++ - } else { - return - } + addResultToSCSOverview(summary, result) + engineType = commonParams.ScsType + *summary.ScsIssues++ + summary.TotalIssues++ } else { return } @@ -1528,11 +1516,7 @@ func ReadResults( } if slices.Contains(scan.Engines, commonParams.ScsType) { - if !wrappers.IsSCSEnabled { - resultsModel = removeResultsByType(resultsModel, commonParams.SscsType) - } else { - resultsModel = filterScsResultsByAgent(resultsModel, agent) - } + resultsModel = filterScsResultsByAgent(resultsModel, agent) } resultsModel.ScanID = scan.ID @@ -2264,7 +2248,7 @@ func parseSonar(results *wrappers.ScanResultsCollection) ([]wrappers.SonarIssues } else if wrappers.IsContainersEnabled && engineType == commonParams.ContainersType { auxIssue.PrimaryLocation = parseContainersSonar(result) sonarIssues = append(sonarIssues, auxIssue) - } else if wrappers.IsSCSEnabled && strings.HasPrefix(engineType, commonParams.SscsType) { + } else if strings.HasPrefix(engineType, commonParams.SscsType) { sscsSonarIssue := parseSscsSonar(result, &auxIssue) sonarIssues = append(sonarIssues, sscsSonarIssue) } @@ -2309,7 +2293,7 @@ func initSonarIssue(result *wrappers.ScanResult) wrappers.SonarIssues { sonarIssue.RuleID = result.ID } else if wrappers.IsContainersEnabled && engineType == commonParams.ContainersType { sonarIssue.RuleID = result.ID - } else if wrappers.IsSCSEnabled && strings.HasPrefix(engineType, commonParams.SscsType) { + } else if strings.HasPrefix(engineType, commonParams.SscsType) { sonarIssue.RuleID = result.ID } @@ -2346,7 +2330,7 @@ func initSonarRules(result *wrappers.ScanResult) wrappers.SonarRules { sonarRules.Name = result.ScanResultData.ImageTag sonarRules.Description = html.UnescapeString(result.Description) sonarRules.ID = result.ID - } else if wrappers.IsSCSEnabled && strings.HasPrefix(engineType, commonParams.SscsType) { + } else if strings.HasPrefix(engineType, commonParams.SscsType) { sonarRules.Name = result.ScanResultData.RuleName sonarRules.Description = html.UnescapeString(result.ScanResultData.RuleDescription) sonarRules.ID = result.ID @@ -2584,7 +2568,7 @@ func findResult(result *wrappers.ScanResult) []wrappers.SarifScanResult { scanResults = parseSarifResultsSca(result, scanResults) } else if result.Type == commonParams.ContainersType && wrappers.IsContainersEnabled { scanResults = parseSarifResultsContainers(result, scanResults) - } else if strings.HasPrefix(result.Type, commonParams.SscsType) && wrappers.IsSCSEnabled { + } else if strings.HasPrefix(result.Type, commonParams.SscsType) { scanResults = parseSarifResultsSscs(result, scanResults) } diff --git a/internal/commands/result_test.go b/internal/commands/result_test.go index a7ccbb39b..e83c78a04 100644 --- a/internal/commands/result_test.go +++ b/internal/commands/result_test.go @@ -140,7 +140,6 @@ func TestResultsExitCode_OnPartialScan_PrintOnlyFailedScannersInfoToConsole(t *t func runScanCommand(t *testing.T, agent, scanID string) *wrappers.ScanResultsCollection { clearFlags() - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true} _, err := executeRedirectedOsStdoutTestCommand(createASTTestCommand(), "results", "show", "--scan-id", scanID, "--report-format", "json", "--agent", agent) @@ -171,7 +170,6 @@ func TestRunScsResultsShow_ASTCLI_AgentShouldShowAllResults(t *testing.T) { 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.DefaultAgent) assertTypePresentJSON(t, params.SCSScorecardType, 1) @@ -187,7 +185,6 @@ func TestRunScsResultsShow_VSCode_AgentShouldNotShowScorecardResults(t *testing. 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.VSCodeAgent) assertTypePresentJSON(t, params.SCSScorecardType, 0) @@ -203,7 +200,6 @@ func TestRunScsResultsShow_Jetbrains_AgentShouldShowScsResults(t *testing.T) { 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.JetbrainsAgent) assertTypePresentJSON(t, params.SCSScorecardType, 0) @@ -219,7 +215,6 @@ func TestRunWithoutScsResults_Other_AgentsShouldNotShowScsResults(t *testing.T) mock.HasScs = true mock.ScsScanPartial = false mock.ScorecardScanned = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true} execCmdNilAssertion(t, "results", "show", "--scan-id", "SAST_ONLY", "--report-format", "json", "--agent", params.EclipseAgent) assertTypePresentJSON(t, params.SCSScorecardType, 0) @@ -232,7 +227,6 @@ func TestRunWithoutScsResults_Other_AgentsShouldNotShowScsResults(t *testing.T) func TestRunNilResults_Other_AgentsShouldNotShowAnyResults(t *testing.T) { clearFlags() - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true} execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK_NO_VULNERABILITIES", "--report-format", "json", "--agent", params.VisualStudioAgent) assertTypePresentJSON(t, params.SCSScorecardType, 0) @@ -247,7 +241,6 @@ func TestRunScsResultsShow_Other_AgentShouldShowSCSResults(t *testing.T) { 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) @@ -1105,7 +1098,7 @@ func TestRunGetResultsByScanIdSummaryConsoleFormat_ScsNotScanned_ScsMissingInRep mock.HasScs = false mock.ScsScanPartial = false mock.ScorecardScanned = false - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true} + buffer, err := executeRedirectedOsStdoutTestCommand(createASTTestCommand(), "results", "show", "--scan-id", "MOCK", "--report-format", "summaryConsole") assert.NilError(t, err) @@ -1131,7 +1124,7 @@ func TestRunGetResultsByScanIdSummaryConsoleFormat_ScsCompleted_ScsCompletedInRe mock.HasScs = true mock.ScsScanPartial = false mock.ScorecardScanned = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true} + mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.CVSSV3Enabled, Status: true} buffer, err := executeRedirectedOsStdoutTestCommand(createASTTestCommand(), "results", "show", "--scan-id", "MOCK", "--report-format", "summaryConsole") @@ -1166,7 +1159,7 @@ func TestRunGetResultsByScanIdSummaryConsoleFormat_ScsPartial_ScsPartialInReport mock.HasScs = true mock.ScsScanPartial = true mock.ScorecardScanned = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true} + mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.CVSSV3Enabled, Status: true} buffer, err := executeRedirectedOsStdoutTestCommand(createASTTestCommand(), "results", "show", "--scan-id", "MOCK", "--report-format", "summaryConsole") @@ -1201,7 +1194,7 @@ func TestRunGetResultsByScanIdSummaryConsoleFormat_ScsScorecardNotScanned_Scorec mock.HasScs = true mock.ScsScanPartial = false mock.ScorecardScanned = false - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true} + mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.CVSSV3Enabled, Status: true} buffer, err := executeRedirectedOsStdoutTestCommand(createASTTestCommand(), "results", "show", "--scan-id", "MOCK", "--report-format", "summaryConsole") @@ -1223,33 +1216,6 @@ func TestRunGetResultsByScanIdSummaryConsoleFormat_ScsScorecardNotScanned_Scorec mock.SetScsMockVarsToDefault() } -func TestRunGetResultsByScanIdSummaryConsoleFormat_SCSFlagNotEnabled_SCSMissingInReport(t *testing.T) { - clearFlags() - mock.HasScs = true - mock.ScsScanPartial = false - mock.ScorecardScanned = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: false} - - buffer, err := executeRedirectedOsStdoutTestCommand(createASTTestCommand(), - "results", "show", "--scan-id", "MOCK", "--report-format", "summaryConsole,summaryJSON") - assert.NilError(t, err) - - stdoutString := buffer.String() - fmt.Print(stdoutString) - - scsSummary := "| SCS" - assert.Equal(t, !strings.Contains(stdoutString, scsSummary), true, - "Expected SCS summary to be missing:"+scsSummary) - secretDetectionSummary := "Secret Detection" - assert.Equal(t, !strings.Contains(stdoutString, secretDetectionSummary), true, - "Expected Secret Detection summary to be missing:"+secretDetectionSummary) - scorecardSummary := "Scorecard" - assert.Equal(t, !strings.Contains(stdoutString, scorecardSummary), true, - "Expected Scorecard summary to be missing:"+scorecardSummary) - - mock.SetScsMockVarsToDefault() -} - func TestGetResultsSummaryConsoleFormatWithCriticalDisabled(t *testing.T) { clearFlags() mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.CVSSV3Enabled, Status: false} @@ -1385,26 +1351,12 @@ func TestPrintPoliciesSummary_WhenNoRolViolated_ShouldNotContainPolicyViolation( assert.Assert(t, !strings.Contains(output, "Policy Management Violation "), "Output should not contain 'Policy Management Violation'") } -func TestRunGetResultsByScanIdJSONFormat_SCSFlagNotEnabled_SCSMissingInReport(t *testing.T) { - clearFlags() - mock.HasScs = true - mock.ScsScanPartial = false - mock.ScorecardScanned = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: false} - execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "json") - assertTypePresentJSON(t, params.SCSScorecardType, 0) - assertTypePresentJSON(t, params.SCSSecretDetectionType, 0) - - removeFileBySuffix(t, printer.FormatJSON) - mock.SetScsMockVarsToDefault() -} - func TestRunGetResultsByScanIdJSONFormat_SCSFlagEnabled_SCSPresentInReport(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", "MOCK", "--report-format", "json") assertTypePresentJSON(t, params.SCSScorecardType, 1) assertTypePresentJSON(t, params.SCSSecretDetectionType, 2) @@ -1413,26 +1365,12 @@ func TestRunGetResultsByScanIdJSONFormat_SCSFlagEnabled_SCSPresentInReport(t *te mock.SetScsMockVarsToDefault() } -func TestRunGetResultsByScanIdSonarFormat_SCSFlagNotEnabled_SCSMissingInReport(t *testing.T) { - clearFlags() - mock.HasScs = true - mock.ScsScanPartial = false - mock.ScorecardScanned = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: false} - execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "sonar") - assertTypePresentSonar(t, params.SCSScorecardType, 0) - assertTypePresentSonar(t, params.SCSSecretDetectionType, 0) - - removeFileBySuffix(t, printer.FormatSonar) - mock.SetScsMockVarsToDefault() -} - func TestRunGetResultsByScanIdSonarFormat_SCSFlagEnabled_SCSPresentInReport(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", "MOCK", "--report-format", "sonar") assertTypePresentSonar(t, params.SCSScorecardType, 1) assertTypePresentSonar(t, params.SCSSecretDetectionType, 2) @@ -1446,7 +1384,7 @@ func TestRunGetResultsByScanIdSarifFormat_SCSFlagEnabled_SCSNonEmpty_URI_Present mock.HasScs = true mock.ScsScanPartial = false mock.ScorecardScanned = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true} + execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "sarif") assertTypePresentSarif(t, params.SCSScorecardType, 1) assertTypePresentSarif(t, params.SCSSecretDetectionType, 2) @@ -1455,36 +1393,6 @@ func TestRunGetResultsByScanIdSarifFormat_SCSFlagEnabled_SCSNonEmpty_URI_Present mock.SetScsMockVarsToDefault() } -func TestRunGetResultsByScanIdSarifFormat_SCSFlagEnabled_SCSMissingInReport(t *testing.T) { - clearFlags() - mock.HasScs = true - mock.ScsScanPartial = false - mock.ScorecardScanned = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: false} - execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "sarif") - assertTypePresentSarif(t, params.SCSScorecardType, 0) - assertTypePresentSarif(t, params.SCSSecretDetectionType, 0) - - removeFileBySuffix(t, printer.FormatSarif) - mock.SetScsMockVarsToDefault() -} - -func TestRunGetResultsByScanIdSummaryJSONFormat_SCSFlagNotEnabled_SCSMissingInReport(t *testing.T) { - clearFlags() - mock.HasScs = true - mock.ScsScanPartial = false - mock.ScorecardScanned = true - ScsFlagValue := false - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: ScsFlagValue} - - execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "summaryJSON") - - assertResultsPresentSummaryJSON(t, ScsFlagValue, params.ScsType, nil) - - removeFileBySuffix(t, printer.FormatJSON) - mock.SetScsMockVarsToDefault() -} - func TestRunGetResultsByScanIdSummaryJSONFormat_SCSFlagEnabled_SCSPresentInReport(t *testing.T) { clearFlags() mock.HasScs = true @@ -1492,7 +1400,6 @@ func TestRunGetResultsByScanIdSummaryJSONFormat_SCSFlagEnabled_SCSPresentInRepor mock.ScorecardScanned = true ScsFlagValue := true expectedScsIssues := 3 - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: ScsFlagValue} execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "summaryJSON") @@ -1505,31 +1412,14 @@ func TestRunGetResultsByScanIdSummaryJSONFormat_SCSFlagEnabled_SCSPresentInRepor func TestRunGetResultsByScanIdSummaryMarkdownFormat_SCSFlagEnabled_SCSPresentInReport(t *testing.T) { clearFlags() mock.HasScs = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true} - execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "markdown") - // Read the contents of the file - markdownBytes, err := os.ReadFile(fmt.Sprintf("%s.%s", fileName, "md")) - assert.NilError(t, err, "Error reading file") - markdownString := string(markdownBytes) - assert.Equal(t, strings.Contains(markdownString, "SCS"), true, "SCS should be present in the markdown file") - - // Remove generated md file - removeFileBySuffix(t, "md") - mock.SetScsMockVarsToDefault() -} - -func TestRunGetResultsByScanIdSummaryMarkdownFormat_SCSFlagNotEnabled_SCSNotPresentInReport(t *testing.T) { - clearFlags() - mock.HasScs = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: false} execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "markdown") // Read the contents of the file markdownBytes, err := os.ReadFile(fmt.Sprintf("%s.%s", fileName, "md")) assert.NilError(t, err, "Error reading file") markdownString := string(markdownBytes) - assert.Equal(t, strings.Contains(markdownString, "SCS"), false, "SCS should not be present in the markdown file") + assert.Equal(t, strings.Contains(markdownString, "SCS"), true, "SCS should be present in the markdown file") // Remove generated md file removeFileBySuffix(t, "md") @@ -1539,7 +1429,7 @@ func TestRunGetResultsByScanIdSummaryMarkdownFormat_SCSFlagNotEnabled_SCSNotPres func TestRunGetResultsByScanIdSummaryHtmlFormat_SCSFlagEnabled_SCSPresentInReport(t *testing.T) { clearFlags() mock.HasScs = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: true} + execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "summaryHTML") // Read the contents of the file htmlBytes, err := os.ReadFile(fmt.Sprintf("%s.%s", fileName, "html")) @@ -1553,23 +1443,6 @@ func TestRunGetResultsByScanIdSummaryHtmlFormat_SCSFlagEnabled_SCSPresentInRepor mock.SetScsMockVarsToDefault() } -func TestRunGetResultsByScanIdSummaryHtmlFormat_SCSFlagNotEnabled_SCSNotPresentInReport(t *testing.T) { - clearFlags() - mock.HasScs = true - mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.SCSEngineCLIEnabled, Status: false} - execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "summaryHTML") - // Read the contents of the file - htmlBytes, err := os.ReadFile(fmt.Sprintf("%s.%s", fileName, "html")) - assert.NilError(t, err, "Error reading file") - - htmlString := string(htmlBytes) - assert.Equal(t, strings.Contains(htmlString, "SCS"), false, "SCS should not be present in the html file") - - // Remove generated md file - removeFileBySuffix(t, "html") - mock.SetScsMockVarsToDefault() -} - func TestFilterScsResultsByAgent_ShouldExcludeSCSAndContainers(t *testing.T) { results := &wrappers.ScanResultsCollection{ Results: []*wrappers.ScanResult{ diff --git a/internal/wrappers/feature-flags.go b/internal/wrappers/feature-flags.go index e5b229dc3..8f92b8cef 100644 --- a/internal/wrappers/feature-flags.go +++ b/internal/wrappers/feature-flags.go @@ -12,7 +12,6 @@ const PackageEnforcementEnabled = "PACKAGE_ENFORCEMENT_ENABLED" const CVSSV3Enabled = "CVSS_V3_ENABLED" const MinioEnabled = "MINIO_ENABLED" const SastCustomStateEnabled = "SAST_CUSTOM_STATES_ENABLED" -const SCSEngineCLIEnabled = "NEW_2MS_SCORECARD_RESULTS_CLI_ENABLED" const RiskManagementEnabled = "RISK_MANAGEMENT_IDES_PROJECT_RESULTS_SCORES_API_ENABLED" const OssRealtimeEnabled = "OSS_REALTIME_ENABLED" const ScsLicensingV2Enabled = "SSCS_NEW_LICENSING_ENABLED" diff --git a/internal/wrappers/results-summary.go b/internal/wrappers/results-summary.go index a08e83d64..d7cf67798 100644 --- a/internal/wrappers/results-summary.go +++ b/internal/wrappers/results-summary.go @@ -79,8 +79,6 @@ type EngineResultSummary struct { type EnginesResultsSummary map[string]*EngineResultSummary -var IsSCSEnabled bool - var IsContainersEnabled bool func (engineSummary *EnginesResultsSummary) GetCriticalIssues() int { @@ -161,9 +159,6 @@ func (r *ResultSummary) ContainersIssuesValue() int { return *r.ContainersIssues } -func (r *ResultSummary) SCSEnabled() bool { - return IsSCSEnabled -} func (r *ResultSummary) HasSCS() bool { return r.HasEngine(params.ScsType) } @@ -786,9 +781,9 @@ const nonAsyncSummary = `
{{if .ContainersEnabled}}
Containers
{{end}} - {{if .SCSEnabled}}
SCS +
SCS
-
{{end}} +
@@ -797,7 +792,7 @@ const nonAsyncSummary = `
{{if lt .KicsIssues 0}}N/A{{else}}{{.KicsIssues}}{{end}}
{{if lt .ScaIssues 0}}N/A{{else}}{{.ScaIssues}}{{end}}
{{if .ContainersEnabled}}
{{if lt .ContainersIssuesValue 0}}N/A{{else}}{{.ContainersIssuesValue}}{{end}}
{{end}} - {{if .SCSEnabled}}
{{if lt .SCSIssuesValue 0}}N/A{{else}}{{.SCSIssuesValue}}{{end}}
{{end}} +
{{if lt .SCSIssuesValue 0}}N/A{{else}}{{.SCSIssuesValue}}{{end}}
@@ -871,9 +866,9 @@ const SummaryMarkdownCompletedTemplate = ` ### Vulnerabilities per Scan Type -| SAST | IaC Security | SCA |{{if .SCSEnabled}} SCS |{{end}}{{if .ContainersEnabled}} Containers |{{end}} -|:----------:|:----------:|:---------:|{{if .SCSEnabled}} :----------:|{{end}}{{if .ContainersEnabled}} :----------:|{{end}} -| {{if lt .SastIssues 0}}N/A{{else}}{{.SastIssues}}{{end}} | {{if lt .KicsIssues 0}}N/A{{else}}{{.KicsIssues}}{{end}} | {{if lt .ScaIssues 0}}N/A{{else}}{{.ScaIssues}}{{end}} | {{if .SCSEnabled}}{{if lt .SCSIssuesValue 0}}N/A{{else}}{{.SCSIssuesValue}}{{end}} | {{end}} {{if .ContainersEnabled}}{{if lt .ContainersIssuesValue 0}}N/A{{else}}{{.ContainersIssuesValue}}{{end}} | {{end}} +| SAST | IaC Security | SCA | SCS |{{if .ContainersEnabled}} Containers |{{end}} +|:----------:|:----------:|:---------:|:----------:|{{if .ContainersEnabled}} :----------:|{{end}} +| {{if lt .SastIssues 0}}N/A{{else}}{{.SastIssues}}{{end}} | {{if lt .KicsIssues 0}}N/A{{else}}{{.KicsIssues}}{{end}} | {{if lt .ScaIssues 0}}N/A{{else}}{{.ScaIssues}}{{end}} | {{if lt .SCSIssuesValue 0}}N/A{{else}}{{.SCSIssuesValue}}{{end}} | {{if .ContainersEnabled}}{{if lt .ContainersIssuesValue 0}}N/A{{else}}{{.ContainersIssuesValue}}{{end}} | {{end}} {{if .HasAPISecurity}} ### API Security