-
Notifications
You must be signed in to change notification settings - Fork 16
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
json-parser: recognize SARIF format for semgrep output #162
Conversation
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.
Could you tell me how to create this stdout, thanks!
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.
My attempt was very tricky - I don't find from anywhere the helpers on generating files like this.
What I did was to use the plugin semgrep
to scan a source rpm, so I get a .sarif
file and a .js
(json) file. I then tweak the sarif file as stdin and the scan-results-all.js
as stdout. I did some investigation and guess that's how these text files were feeded by other plugins(snyk, gitleaks for example). If I understand it correctly, it's used by csgrep
(used in the filter_hook
) to test if after processing the output is as expected.
By tweaking the sarif file, I mean the original scan may contain tens of thousands of lines, thus I need to remove some redundant lines, for example I randomly chose a gzip
source build, there're 700+ semgrep rules claimings with approx 70k+ lines, we definitely don't want to include all of them. Other tweaks includes for example to alter some of the lines produced, for example the unintended suspicous temporary dir prefix in the rules path. I think the process is quite time consuming without a guide. Also I doubt if there's a better way of doing this.
cc @kdudka
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.
@hanchuntao There is a script to sync the expected output of tests: https://github.com/csutils/csdiff/blob/main/tests/csgrep/sync.sh
@rhyw OSH-57 should be referred to as |
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.
LGTM
37e616a
to
0a73880
Compare
Thanks. Commit message / PR description updated. |
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.
@rhyw Looks good. Thanks for the update!
Related: https://issues.redhat.com/browse/OSH-57
Closes: #162