-
Notifications
You must be signed in to change notification settings - Fork 534
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
feat: added a new option: --no-markdown for sarif output #2630
Conversation
|
6220088
to
f3deee8
Compare
src/lib/plugins/sast/index.ts
Outdated
if (options.sarif || options.json) { | ||
if (numOfIssues > 0) { | ||
if (options['no-markdown']) { | ||
sarifTypedResult.runs?.[0].results?.forEach((result) => { | ||
result.message = omit(result.message, ['markdown']); |
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.
Apparently omit
is not great for performance... Would it be better to just use either delete
or object spread? I'm aware that this code will only be run if no-markdown
is passed.
src/lib/plugins/sast/index.ts
Outdated
if (options.sarif || options.json) { | ||
if (numOfIssues > 0) { | ||
if (options['no-markdown']) { | ||
sarifTypedResult.runs?.[0].results?.forEach((result) => { | ||
result.message = omit(result.message, ['markdown']); |
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.
Would be better not to use lodash here. You could call delete
since you're modifying in place anyway.
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.
Fine from SOS pov, but I'm not a huge fan; feels like a hack to work around a bug elsewhere?
@robcresswell something like that, all the details in the PR description. (I share the same opinion) |
help/cli-commands/code.md
Outdated
@@ -53,6 +53,10 @@ Print results in JSON format. | |||
|
|||
Return results in SARIF format. | |||
|
|||
## `--no-markdown` | |||
|
|||
Should be used when using `--sarif`. Will remove the `markdown` field from the `result.message` object. Might help if parsing `arguments` is not working properly. |
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.
Docs should be written in active voice.
Also, I'm not sure about the "Might help if" part, but up to you.
Should be used when using `--sarif`. Will remove the `markdown` field from the `result.message` object. Might help if parsing `arguments` is not working properly. | |
Removes the `markdown` field from the `result.message` object. Should be used when using `--sarif`. |
What does this PR do?
Adding a new flag to options,
--no-markdown
, which removes themarkdown
property fromresult.message
when usingsarif
output.How should this be manually tested?
snyk code test --sarif --no-markdown
Any background context you want to provide?
Slack discussion: https://snyk.slack.com/archives/C01U14WSN73/p1642928960104800
What are the relevant tickets?
This is a result of a support ticket: https://snyk.zendesk.com/agent/tickets/18450