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

fix: Remove scanResult from json output [MAGMA-1280] #2502

Merged
merged 5 commits into from
Jan 6, 2022

Conversation

snaftaly
Copy link
Contributor

@snaftaly snaftaly commented Dec 29, 2021

What does this PR do?

This PR removes the scanResult object from the json output.
It also refactors the code that creates the json output, therefore it's recommended to review it commit by commit.

How should this be manually tested?

Run: snyk container test node:apline

Any background context you want to provide?

In a previous PR (#2093) the scanResult object was added in order to calculate the appropriate dockerfile analysis warning message shown in the textual output.
As a result the scanResult was also shown in the json output, although it was not intended to.

What are the relevant tickets?

https://snyksec.atlassian.net/browse/MAGMA-1280

@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2021

Warnings
⚠️

Since the CLI is unifying on a standard and improved tooling, we're starting to migrate old-style imports and exports to ES6 ones.
A file you've modified is using either module.exports or require(). If you can, please update them to ES6 import syntax and export syntax.
Files found:

  • src/cli/commands/test/index.ts
  • test/fixtures/container-app-vulns/mappedResults.json
  • test/fixtures/container-app-vulns/resultJsonDataGrouped.json
  • test/fixtures/container-app-vulns/resultJsonDataNonGrouped.json
  • test/fixtures/npm/issue-grouping/multiProjectMappedResults.json

Generated by 🚫 dangerJS against 1949818

@snaftaly snaftaly force-pushed the fix/remove-scan-results-from-json branch 3 times, most recently from f4546fe to b38a9db Compare December 30, 2021 12:43
@snaftaly snaftaly changed the title fix: Remove scan results from json output fix: Remove scan results from json output [MAGMA-1280] Dec 30, 2021
@snaftaly snaftaly force-pushed the fix/remove-scan-results-from-json branch from b38a9db to 2e876eb Compare December 30, 2021 13:22
@snaftaly snaftaly changed the title fix: Remove scan results from json output [MAGMA-1280] fix: Remove scanResult from json output [MAGMA-1280] Jan 2, 2022
@snaftaly snaftaly marked this pull request as ready for review January 4, 2022 14:28
@snaftaly snaftaly requested review from a team as code owners January 4, 2022 14:28
Copy link
Contributor

@jan-stehlik jan-stehlik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @snaftaly 🚢

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Left some comments. Might be worth getting Snyk Open Source and/or Envelope reps to review as mentioned in the Slack thread (if they haven't already).

src/cli/commands/test/index.ts Outdated Show resolved Hide resolved
src/lib/formatters/test/format-test-results.ts Outdated Show resolved Hide resolved
@snaftaly snaftaly force-pushed the fix/remove-scan-results-from-json branch from 9d0db8b to 96e72bb Compare January 5, 2022 12:44
The scanResult object was added to the json output where
it should only have been added to calculate the the
dockerfile warning string.
This change removes the scanResult from the json output
as it was not supposed to be exposed.
This refactor is done to not have a special case for
array vs single result when formatting the results
for JSON output.
Note: dataToSend will now take the jsonData after formatting
rather than the data before formatting. Since the formatting
only changes the vulnerbilities and removes the unwanted
scanResult, and since the vulnerbilities are removed from
dataToSend before it is used, this change will not affect the
CLI bahvior except for removing the unwanted scanResult.
@snaftaly snaftaly force-pushed the fix/remove-scan-results-from-json branch from 96e72bb to b4bd660 Compare January 5, 2022 17:04
Renaming the object as in IaC the logic does more than mapping
the results.
Rename test fixtures used in format-test-results to align
with the variable name change.
This is done in a separate commit so it's clearer in git
history that the files were changed and then renamed rather
than deleted and created new files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants