-
Notifications
You must be signed in to change notification settings - Fork 28
Add support for containers scan in cloud by default (AST-00000) #1024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -312,7 +312,6 @@ func TestRunGetResultsByScanIdSarifFormat(t *testing.T) { | |
| } | ||
| func TestRunGetResultsByScanIdSarifFormatWithContainers(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "sarif") | ||
| // Remove generated sarif file | ||
| removeFileBySuffix(t, printer.FormatSarif) | ||
|
|
@@ -334,7 +333,6 @@ func TestRunGetResultsByScanIdSonarFormat(t *testing.T) { | |
|
|
||
| func TestRunGetResultsByScanIdSonarFormatWithContainers(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "sonar") | ||
| // Remove generated sonar file | ||
| removeFile(t, fileName+"_"+printer.FormatSonar, printer.FormatJSON) | ||
|
|
@@ -367,7 +365,6 @@ func TestDecodeHTMLEntitiesInResults(t *testing.T) { | |
|
|
||
| func TestRunGetResultsByScanIdJsonFormatWithContainers(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "json") | ||
|
|
||
| // Remove generated json file | ||
|
|
@@ -390,7 +387,6 @@ func TestRunGetResultsByScanIdSummaryJsonFormat(t *testing.T) { | |
|
|
||
| func TestRunGetResultsByScanIdSummaryJsonFormatWithContainers(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "summaryJSON") | ||
|
|
||
| // Remove generated json file | ||
|
|
@@ -406,7 +402,6 @@ func TestRunGetResultsByScanIdSummaryHtmlFormat(t *testing.T) { | |
|
|
||
| func TestRunGetResultsByScanIdSummaryHtmlFormatWithContainers(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "summaryHTML") | ||
|
|
||
| // Remove generated html file | ||
|
|
@@ -425,13 +420,11 @@ func TestRunGetResultsByScanIdSummaryMarkdownFormatWithContainers(t *testing.T) | |
|
|
||
| func TestRunGetResultsByScanIdSummaryConsoleFormatWithContainers(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "summaryConsole") | ||
| } | ||
|
|
||
| func TestRunGetResultsByScanIdSummaryMarkdownFormat(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "markdown") | ||
| // Remove generated md file | ||
| removeFileBySuffix(t, "md") | ||
|
|
@@ -480,7 +473,6 @@ func TestRunGetResultsByScanIdPDFFormat(t *testing.T) { | |
|
|
||
| func TestRunGetResultsByScanIdPDFFormatWithContainers(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "pdf") | ||
| _, err := os.Stat(fmt.Sprintf("%s.%s", fileName, printer.FormatPDF)) | ||
| assert.NilError(t, err, "Report file should exist for extension "+printer.FormatPDF) | ||
|
|
@@ -759,7 +751,6 @@ func TestSBOMReportXML(t *testing.T) { | |
|
|
||
| func TestSBOMReportJsonWithContainers(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "sbom") | ||
| _, err := os.Stat(fmt.Sprintf("%s.%s", fileName+"_"+printer.FormatSbom, printer.FormatJSON)) | ||
| assert.NilError(t, err, "Report file should exist for extension "+printer.FormatJSON) | ||
|
|
@@ -769,7 +760,6 @@ func TestSBOMReportJsonWithContainers(t *testing.T) { | |
|
|
||
| func TestSBOMReportXMLWithContainers(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "sbom", "--report-sbom-format", "CycloneDxXml") | ||
| _, err := os.Stat(fmt.Sprintf("%s.%s", fileName+"_"+printer.FormatSbom, printer.FormatXML)) | ||
| assert.NilError(t, err, "Report file should exist for extension "+printer.FormatXML) | ||
|
|
@@ -782,26 +772,17 @@ func TestRunGetResultsByScanIdGLFormat(t *testing.T) { | |
| // Run test for gl-sast report type | ||
| os.Remove(fmt.Sprintf("%s.%s", fileName, printer.FormatGLSast)) | ||
| } | ||
|
|
||
| func TestRunResultsShow_ContainersFFIsOn_includeContainersResult(t *testing.T) { | ||
| clearFlags() | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "json") | ||
| assertTypePresentJSON(t, params.ContainersType, 1) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's unclear what |
||
| // Remove generated json file | ||
| removeFileBySuffix(t, printer.FormatJSON) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The removal of the generated file should be done in a |
||
| } | ||
| func TestRunResultsShow_ContainersFFIsOff_excludeContainersResult(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: false} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "json") | ||
| assertTypePresentJSON(t, params.ContainersType, 0) | ||
| // Remove generated json file | ||
| removeFileBySuffix(t, printer.FormatJSON) | ||
| } | ||
|
|
||
| func TestRunResultsShow_jetbrainsIsNotSupported_excludeContainersResult(t *testing.T) { | ||
cx-alex-cohen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "json", "--agent", "jetbrains") | ||
| assertTypePresentJSON(t, params.ContainersType, 0) | ||
| // Remove generated json file | ||
|
|
@@ -810,7 +791,6 @@ func TestRunResultsShow_jetbrainsIsNotSupported_excludeContainersResult(t *testi | |
|
|
||
| func TestRunResultsShow_EclipseIsNotSupported_excludeContainersResult(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "json", "--agent", "Eclipse") | ||
| assertTypePresentJSON(t, params.ContainersType, 0) | ||
| // Remove generated json file | ||
|
|
@@ -819,7 +799,6 @@ func TestRunResultsShow_EclipseIsNotSupported_excludeContainersResult(t *testing | |
|
|
||
| func TestRunResultsShow_VsCodeIsNotSupported_excludeContainersResult(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "json", "--agent", "vs code") | ||
| assertTypePresentJSON(t, params.ContainersType, 0) | ||
| // Remove generated json file | ||
|
|
@@ -828,7 +807,6 @@ func TestRunResultsShow_VsCodeIsNotSupported_excludeContainersResult(t *testing. | |
|
|
||
| func TestRunResultsShow_VisualStudioIsNotSupported_excludeContainersResult(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: true} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "json", "--agent", "Visual Studio") | ||
| assertTypePresentJSON(t, params.ContainersType, 0) | ||
| // Remove generated json file | ||
|
|
@@ -952,11 +930,7 @@ func assertResultsPresentSummaryJSON(t *testing.T, isResultsEnabled bool, scanTy | |
| assert.Assert(t, false, "%s result summary should be present", scanType) | ||
| } | ||
| } | ||
| func TestRunGetResultsShow_ContainersFFOffAndResultsHasContainersResultsOnly_NilAssertion(t *testing.T) { | ||
| clearFlags() | ||
| mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.ContainerEngineCLIEnabled, Status: false} | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "CONTAINERS_ONLY", "--report-format", "summaryConsole") | ||
| } | ||
|
|
||
| func TestRunGetResultsByScanIdGLSastAndAScaFormat(t *testing.T) { | ||
| execCmdNilAssertion(t, "results", "show", "--scan-id", "MOCK", "--report-format", "gl-sast,gl-sca") | ||
| // Run test for gl-sast report type | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider validating the
--scan-idflag to ensure that it is not empty and has a proper format before executing the command.