Skip to content
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

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

Closed
MAP4H opened this issue Sep 18, 2023 · 6 comments
Closed

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

MAP4H opened this issue Sep 18, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@MAP4H
Copy link

MAP4H commented Sep 18, 2023

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

@MAP4H MAP4H added the enhancement New feature or request label Sep 18, 2023
@github-actions
Copy link

Internal Jira issue: AST-29883

@jbrotsos
Copy link
Contributor

@MAP4H
Copy link
Author

MAP4H commented Sep 22, 2023

@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).

@jbrotsos
Copy link
Contributor

jbrotsos commented Sep 28, 2023

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

@logan5735
Copy link

@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''')

@pedrompflopes
Copy link
Collaborator

pedrompflopes commented Oct 11, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants