Checkmarx/ast-cli

[REQ]Is there a way to pull SAST results from CLI

Closed this issue · 6 comments

MAP4H commented

Currently i'm trying to export only SAST results from CLI into json format.

When i use ./cx results command i saw in the documentation that only when generating a PDF report i can specify SAST results, but not for .json formats.

Is there a way i can get only SAST results for .json format in CLI?

We have Checkmarx one.

Regards

Internal Jira issue: AST-29883

MAP4H commented

@MAP4H have you tried --report-format json

(https://checkmarx.com/resource/documents/en/34965-68640-results.html#UUID-2e5e64d2-bf90-43b3-e86f-e12632b27303_N6493038a4a066)

My problem is not the format, by default i get .json format file, what i need is to get only the SAST result, but i don't see any filter to perform this action for a json format

This is what says in the documentation:

--report-pdf-options (Default: All Sections)
Specify the sections that will be included in the pdf format report.

This flag can only be used when --report-format is set as pdf.

Available sections are: Sast, Sca, Iac-Security, Api-Security, ScanSummary, ExecutiveSummary, and ScanResults.

ScanResults includes results for all scanners (IaC-Security, Sast and Sca).

@MAP4H can you filter the json results to only look at SAST engine results?

@MAP4H I am using as scripted pipeline approach to run scans. This may not pertain to your approach. However, I send my output to a temporary output file, and I can then parse it for key patterns with regex.

sh(returnStatus: true, script: "CX1CMDSCRIPT > output.txt")
def output = readFile('output.txt').trim()
def scanidValue= sh(returnStdout: true, script: '''grep -Po "(^|\s)Scan ID:\s\K[^,]+" output.txt''')

Hi @logan5735

I understand that you run ast-cli in a pipeline and you want to update the just the sast results. I suggest you add these options to your scan create command:

./cx scan create --report-format json --output-name myreport.json
cat myreport.json | jq '.results[] | select(.type == "sast")'

Thanks.