-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AST-36384 add support for improved-scan-report invocation (#688)
* add support for improved-scan-report * change tests for active feature flag in tenant * update go to 1.21.9 to fix vulnerabilities * update validation of flag for options in pdf report * fix ci yaml pr number
- Loading branch information
Showing
10 changed files
with
105 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"issues":[{"engineId":"sast","type":"VULNERABILITY","primaryLocation":{"filePath":"dummy-file-name","textRange":{"startLine":10,"startColumn":9,"endColumn":10}},"secondaryLocations":[{"filePath":"dummy-file-name","textRange":{"startColumn":2,"endColumn":3}}]},{"engineId":"kics","type":"VULNERABILITY","primaryLocation":{"textRange":{"startColumn":1,"endColumn":2}},"secondaryLocations":null}]} | ||
{"issues":[{"engineId":"sast","ruleId":"1","type":"VULNERABILITY","primaryLocation":{"message":"mock-query-name-1","filePath":"dummy-file-name-1","textRange":{"startLine":10,"startColumn":10,"endColumn":30}},"secondaryLocations":[{"message":"mock-query-name-1","filePath":"dummy-file-name-1","textRange":{"startLine":11,"startColumn":3,"endColumn":13}}]},{"engineId":"sast","ruleId":"2","type":"VULNERABILITY","primaryLocation":{"message":"mock-query-name-2","filePath":"dummy-file-name-2","textRange":{"startLine":10,"startColumn":10,"endColumn":30}},"secondaryLocations":[{"message":"mock-query-name-2","filePath":"dummy-file-name-2","textRange":{"startLine":11,"startColumn":3,"endColumn":13}}]},{"engineId":"sast","ruleId":"3","type":"VULNERABILITY","primaryLocation":{"message":"mock-query-name-2","filePath":"dummy-file-name-2","textRange":{"startLine":10,"startColumn":10,"endColumn":30}},"secondaryLocations":[{"message":"mock-query-name-2","filePath":"dummy-file-name-2","textRange":{"startLine":11,"startColumn":3,"endColumn":13}},{"message":"mock-query-name-2","filePath":"dummy-file-name-2","textRange":{"startLine":12,"startColumn":3,"endColumn":13}}]},{"engineId":"sast","ruleId":"4","type":"VULNERABILITY","primaryLocation":{"message":"mock-query-name-3","filePath":"dummy-file-name-3","textRange":{"startLine":10,"startColumn":10,"endColumn":30}},"secondaryLocations":[{"message":"mock-query-name-3","filePath":"dummy-file-name-3","textRange":{"startLine":11,"startColumn":3,"endColumn":13}}]},{"engineId":"sast","ruleId":"5","type":"VULNERABILITY","primaryLocation":{"message":"mock-query-name-3","filePath":"dummy-file-name-4","textRange":{"startLine":10,"startColumn":10,"endColumn":30}},"secondaryLocations":[{"message":"mock-query-name-3","filePath":"dummy-file-name-4","textRange":{"startLine":11,"startColumn":3,"endColumn":13}}]},{"engineId":"kics","type":"VULNERABILITY","primaryLocation":{"textRange":{"endColumn":1}},"secondaryLocations":null}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import ( | |
"github.com/checkmarx/ast-cli/internal/commands/util/printer" | ||
"github.com/checkmarx/ast-cli/internal/params" | ||
"github.com/checkmarx/ast-cli/internal/wrappers" | ||
"github.com/checkmarx/ast-cli/internal/wrappers/mock" | ||
"gotest.tools/assert" | ||
) | ||
|
||
|
@@ -249,6 +250,7 @@ func TestRunGetBFLByScanIdAndQueryIdWithFormatList(t *testing.T) { | |
} | ||
|
||
func TestRunGetResultsGeneratingPdfReportWithInvalidEmail(t *testing.T) { | ||
mock.Flags = wrappers.FeatureFlagsResponseModel{{Name: wrappers.NewScanReportEnabled, Status: false}} | ||
err := execCmdNotNilAssertion(t, | ||
"results", "show", | ||
"--report-format", "pdf", | ||
|
@@ -258,6 +260,7 @@ func TestRunGetResultsGeneratingPdfReportWithInvalidEmail(t *testing.T) { | |
} | ||
|
||
func TestRunGetResultsGeneratingPdfReportWithInvalidOptions(t *testing.T) { | ||
mock.Flags = wrappers.FeatureFlagsResponseModel{{Name: wrappers.NewScanReportEnabled, Status: false}} | ||
err := execCmdNotNilAssertion(t, | ||
"results", "show", | ||
"--report-format", "pdf", | ||
|
@@ -266,7 +269,18 @@ func TestRunGetResultsGeneratingPdfReportWithInvalidOptions(t *testing.T) { | |
assert.Equal(t, err.Error(), "report option \"invalid\" unavailable", "Wrong expected error message") | ||
} | ||
|
||
func TestRunGetResultsGeneratingPdfReportWithInvalidImprovedOptions(t *testing.T) { | ||
mock.Flags = wrappers.FeatureFlagsResponseModel{{Name: wrappers.NewScanReportEnabled, Status: false}} | ||
err := execCmdNotNilAssertion(t, | ||
"results", "show", | ||
"--report-format", "pdf", | ||
"--scan-id", "MOCK", | ||
"--report-pdf-options", "scan-information") | ||
assert.Equal(t, err.Error(), "report option \"scan-information\" unavailable", "Wrong expected error message") | ||
} | ||
|
||
func TestRunGetResultsGeneratingPdfReportWithEmailAndOptions(t *testing.T) { | ||
mock.Flags = wrappers.FeatureFlagsResponseModel{{Name: wrappers.NewScanReportEnabled, Status: false}} | ||
cmd := createASTTestCommand() | ||
err := executeTestCommand(cmd, | ||
"results", "show", | ||
|
@@ -277,7 +291,32 @@ func TestRunGetResultsGeneratingPdfReportWithEmailAndOptions(t *testing.T) { | |
assert.NilError(t, err) | ||
} | ||
|
||
func TestRunGetResultsGeneratingPdfReporWithOptions(t *testing.T) { | ||
func TestRunGetResultsGeneratingPdfReportWithOptionsImproved(t *testing.T) { | ||
mock.Flags = wrappers.FeatureFlagsResponseModel{{Name: wrappers.NewScanReportEnabled, Status: true}} | ||
cmd := createASTTestCommand() | ||
err := executeTestCommand(cmd, | ||
"results", "show", | ||
"--report-format", "pdf", | ||
"--scan-id", "MOCK", | ||
"--report-pdf-email", "[email protected],[email protected]", | ||
"--report-pdf-options", "Iac-Security,Sast,Sca,scan-information") | ||
assert.NilError(t, err) | ||
} | ||
|
||
func TestRunGetResultsGeneratingPdfReportWithInvalidOptionsImproved(t *testing.T) { | ||
mock.Flags = wrappers.FeatureFlagsResponseModel{{Name: wrappers.NewScanReportEnabled, Status: true}} | ||
cmd := createASTTestCommand() | ||
err := executeTestCommand(cmd, | ||
"results", "show", | ||
"--report-format", "pdf", | ||
"--scan-id", "MOCK", | ||
"--report-pdf-email", "[email protected],[email protected]", | ||
"--report-pdf-options", "Iac-Security,Sast,Sca,ScanSummary") | ||
assert.Error(t, err, "report option \"scansummary\" unavailable") | ||
} | ||
|
||
func TestRunGetResultsGeneratingPdfReportWithOptions(t *testing.T) { | ||
mock.Flags = wrappers.FeatureFlagsResponseModel{{Name: wrappers.NewScanReportEnabled, Status: false}} | ||
cmd := createASTTestCommand() | ||
err := executeTestCommand(cmd, | ||
"results", "show", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,7 +210,7 @@ func TestResultsGeneratingPdfReportWithPdfOptions(t *testing.T) { | |
"results", "show", | ||
flag(params.ScanIDFlag), scanID, | ||
flag(params.TargetFormatFlag), "pdf", | ||
flag(params.ReportFormatPdfOptionsFlag), "Iac-Security,ScanSummary,ExecutiveSummary,ScanResults", | ||
flag(params.ReportFormatPdfOptionsFlag), "Iac-Security,scan-information", | ||
flag(params.TargetFlag), fileName, | ||
) | ||
defer func() { | ||
|
@@ -220,7 +220,6 @@ func TestResultsGeneratingPdfReportWithPdfOptions(t *testing.T) { | |
_, err := os.Stat(fmt.Sprintf("%s.%s", fileName, printer.FormatPDF)) | ||
assert.NilError(t, err, "Report file should exist: "+fileName+printer.FormatPDF) | ||
assert.Assert(t, outputBuffer != nil, "Scan must complete successfully") | ||
|
||
} | ||
|
||
func TestResultsGeneratingPdfReportAndSendToEmail(t *testing.T) { | ||
|
@@ -230,7 +229,7 @@ func TestResultsGeneratingPdfReportAndSendToEmail(t *testing.T) { | |
"results", "show", | ||
flag(params.ScanIDFlag), scanID, | ||
flag(params.TargetFormatFlag), "pdf", | ||
flag(params.ReportFormatPdfOptionsFlag), "Iac-Security,ScanSummary,ExecutiveSummary,ScanResults", | ||
flag(params.ReportFormatPdfOptionsFlag), "Iac-Security,scan-information", | ||
flag(params.ReportFormatPdfToEmailFlag), "[email protected],[email protected]", | ||
) | ||
assert.Assert(t, outputBuffer != nil, "Scan must complete successfully") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters