-
Notifications
You must be signed in to change notification settings - Fork 567
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(iac): enrich cli json results for iac with successful items (IAC-2962) #5286
feat(iac): enrich cli json results for iac with successful items (IAC-2962) #5286
Conversation
type: IacProjectType | State.InputTypeEnum; | ||
subType: string; | ||
path: string[]; | ||
msg: string; |
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.
This msg
field actually contains the formatted path of the resource. It was included in the infrastructureAsCodeIssues
, so I kept it here as well. Lmk if you see a reason to remove it.
test/jest/unit/iac/process-results/fixtures/integrated-json-output.json
Outdated
Show resolved
Hide resolved
4b7d5c6
to
92e84f1
Compare
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.
Ok from IaC point of view 🚀
@sergiu-snyk we took a look at your PR and from what we can see the changes generally look good! We do have a question on the changes from a platform perspective. We manually compared the output of the latest stable CLI and the version from this branch and the output of the json data increased quite a bit. In our example from 28kB to 140kB. Since we have recently seen plenty of issues with OOM errors, we were wondering if you considered this aspect and looked at different scenarios to stress test the implementation. If this new data shall be available by default I would recommend to add a stress test and use a streaming json parser in I hope this make sense. Please feel free to reach out to me. |
@PeterSchafer, thank you for the time taken for a thorough review. Your comment raises valid concerns. Here are my thoughts. There are two places where we deal with JSON output, that are impacted by my change:
To stress test the implementation I used a script that generates large TF files by multiplying an AWS resource X times.
My findings after giving it another go at testing are:
What this means is that in the CLI without my changes, the JSON read would error at X=11000, while with my changes would error at X=7000. The error in question relates to a limit in JSON.parse, not to the v8 limit of reading files larger than 2GB To address this I could do one or all of the following: a. remove b. remove fields from These two measures would bring the intermediary JSON output to what it is now or even below. c. use a streaming JSON parser. Depending on how we implement this we may trigger changes in the way we process it downstream, as that would need to work on chunks instead of the whole. This seems a riskier and more complicated change, but would deal with the issue better.
|
@sergiu-snyk this is the test data we used for comparison,
|
|
56882bb
to
718ae0a
Compare
@@ -0,0 +1,313 @@ | |||
// Some of the types below specify fields constrained to a single value. Those |
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.
this is exacly the content of old json.ts
- to be removed when moving this feature to stable
@@ -0,0 +1,69 @@ | |||
import * as fs from 'fs'; |
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.
this is exactly the content of old json-old.spec.ts
- to be removed when moving this feature to stable
@PeterSchafer @andreeaneata ready for another look. All new functionality is behind the "preview" flag. In order to have the preview condition in as few places as possible, I duplicated Regarding the intermediary output from Regarding the final output size, it varies a lot. For the input set that @PeterSchafer indicated previously we still have an increase from 27 KB to 120 KB (I removed the |
"id": "aws_vpc.mainvpc", | ||
"type": "aws_vpc", | ||
"kind": "terraformconfig", | ||
"file": "no_rules_detected.json" |
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.
file for which no vulnerabilities
or passedVulnerabilities
are found
"id": "aws_vpc.mainvpc", | ||
"type": "aws_vpc", | ||
"kind": "terraformconfig", | ||
"file": "plan_no_vulns.json" |
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.
file for which no vulnerabilities
are found, but we have passedVulnerabilities
f6dcb8f
to
7bf2c2e
Compare
7bf2c2e
to
7267d36
Compare
Pull Request Submission
Please check the boxes once done.
The pull request must:
feat:
orfix:
, others might be used in rare occasions as well, if there is no need to document the changes in the release notes. The changes or fixes should be described in detail in the commit message for the changelog & release notes.Pull Request Review
All pull requests must undergo a thorough review process before being merged.
The review process of the code PR should include code review, testing, and any necessary feedback or revisions.
Pull request reviews of functionality developed in other teams only review the given documentation and test reports.
Manual testing will not be performed by the reviewing team, and is the responsibility of the author of the PR.
For Node projects: It’s important to make sure changes in
package.json
are also affectingpackage-lock.json
correctly.If a dependency is not necessary, don’t add it.
When adding a new package as a dependency, make sure that the change is absolutely necessary. We would like to refrain from adding new dependencies when possible.
Documentation PRs in gitbook are reviewed by Snyk's content team. They will also advise on the best phrasing and structuring if needed.
Pull Request Approval
Once a pull request has been reviewed and all necessary revisions have been made, it is approved for merging into
the main codebase. The merging of the code PR is performed by the code owners, the merging of the documentation PR
by our content writers.
What does this PR do?
Adds
infrastructureAsCodeSucesses
to the json output. See pitch for more info.How should this be manually tested?
npm run build:dev
node ~/snyk/cli/dist/cli iac test --org=f7e38c85-68b1-4d42-8744-2c6a0befb3f6 --json
(the org is an organisation where IAC+ is enabled)
What are the relevant tickets?
https://snyksec.atlassian.net/browse/IAC-2962
https://snyksec.atlassian.net/browse/IAC-2969
Screenshots
To keep the output reasonably small, only very important fields were included in the list of successes.
For comparison, here's the output of
infrastructureAsCodeIssues
:Additional questions