-
Notifications
You must be signed in to change notification settings - Fork 563
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: include file content in iac analytics CC-743 #1719
Conversation
|
test/iac-unit-tests/index.spec.ts
Outdated
expect(opts.iacDirFiles).not.toEqual( | ||
expect.objectContaining([ | ||
{ | ||
fileContent: 'FAKE_FILE_CONTENT', | ||
jsonContent: {}, | ||
}, | ||
]), | ||
); |
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.
Nit: Something about this jest syntax feels off to me, it's trying to check if something in an array contains specific keys, right? What about arraycontaining
helper here? https://jestjs.io/docs/expect#expectnotarraycontainingarray
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.
Good catch! Thanks @JackuB
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.
fixed, thanks @JackuB
07ca639
to
bb63bba
Compare
Original PR closed due to mistakenly messing up commits with a bad rebase.
What does this PR do?
We have a minor bug in our Snyk CLI that when the snyk iac test --experimental command is run with a directory instead of a single file we include the iacDirFiles on the options object. This options object is then logged as part of the analytics flow and sent to Big Query. We do not want to be storing user file content in any part of our system so this needs to be filtered out here.
This PR filters the File content and JSON output from the iacDirFiles property added to the options object in the test command and adds a smoke test and unit test to assert that the content is not present.
This is not a long term strategy for solving this issue but fixes the immediate problem that prevents users from adopting the beta. In future we'll want to decouple the file + parsed content from any metadata and ensure that the file content is only passed where needed and discarded when used. We should also look into using a whitelist for the logger to only allow specific arguments to be logged.
Where should the reviewer start?
Start at the smoke tests then the test() function and finish up with the unit tests. The unit tests are really a temporary measure I think to ensure that the iacDirFiles object is clean, we can remove the tests when the flow has been refactored.
How should this be manually tested?
Run the following and verify that the "args" property under analytics is clean of file content.
node ./dist/cli iac test -d --experimental ./test/fixtures/iac/file-logging