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

Add --json-file-output=<file> option to directly save JSON output to file #1059

Closed
wants to merge 1 commit into from

Conversation

maxjeffos
Copy link
Contributor

@maxjeffos maxjeffos commented Mar 31, 2020

  • Ready for review
  • Follows CONTRIBUTING rules
  • Reviewed by Snyk internal team

What does this PR do?

This allows a user to directly save JSON format output to a file as specified by the --json-file-output=<file> parameter, regardless of whether they are using the human-readable or json output. The primary use-case of this is to enable users (and Snyk CI plugins) to simultaneously get the human readable output while saving a JSON format output to a file for other purposes (for example, generating a report).

Where should the reviewer start?

Please take a look at the code and advise as to testing best-practices. I will then include appropriate tests for this PR.

How should this be manually tested?

Say you want to save the JSON output to a file called "snyk-output.json" in the current directory. You could then run snyk test --json-file-output=snyk-output.json which should do a normal snyk test and generate the human-readable output to stdout but at the same time save the JSON format output to snyk-output.json.

Any background context you want to provide?

We need this for https://github.com/snyk/snyk/issues/1027 and https://github.com/snyk/snyk-azure-pipelines-task/issues/30 as well as for another CI plugin we're currently working on.

What are the relevant tickets?

Screenshots

Additional questions

@maxjeffos maxjeffos added the 🚧 WIP Work In Progress label Mar 31, 2020
@maxjeffos maxjeffos requested review from lili2311 and a team March 31, 2020 23:32
@maxjeffos maxjeffos force-pushed the feat/save-json-output-to-file branch from 6e811bd to a7cf035 Compare April 2, 2020 00:56
@snyk snyk deleted a comment from snyksec Apr 2, 2020
Copy link
Contributor

@gitphill gitphill 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, can we add some testing for this? looks like we'll have to update some existing tests too

Copy link
Contributor

@gitphill gitphill left a comment

Choose a reason for hiding this comment

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

close in favour of #1107?

@maxjeffos
Copy link
Contributor Author

close in favour of #1107?

Yes... closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚧 WIP Work In Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants