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: include file content in iac analytics CC-743 #1719

Merged
merged 1 commit into from
Mar 15, 2021

Conversation

rontalx
Copy link
Contributor

@rontalx rontalx commented Mar 14, 2021

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

@rontalx rontalx requested a review from a team as a code owner March 14, 2021 08:39
@rontalx rontalx requested a review from a team March 14, 2021 08:39
@rontalx rontalx requested a review from a team as a code owner March 14, 2021 08:39
@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2021

Warnings
⚠️

Looks like you added a new Tap test. Consider making it a Jest test instead. See files like test/*.spec.ts for examples. Files found:

  • test/fixtures/iac/file-logging/file_content_logging.yaml
Messages
📖 You are modifying something in test/smoke directory, yet you are not on the branch starting with smoke/. You can prefix your branch with smoke/ and Smoke tests will trigger for this PR.

Generated by 🚫 dangerJS against bb63bba

Comment on lines 55 to 62
expect(opts.iacDirFiles).not.toEqual(
expect.objectContaining([
{
fileContent: 'FAKE_FILE_CONTENT',
jsonContent: {},
},
]),
);
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! Thanks @JackuB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks @JackuB

@rontalx rontalx requested a review from aron March 15, 2021 15:20
@rontalx rontalx force-pushed the fix/file-content-in-iac-analytics branch from 07ca639 to bb63bba Compare March 15, 2021 15:45
@github-actions
Copy link
Contributor

github-actions bot commented Mar 15, 2021

Expected release notes (by @rontalx)

fixes:
include file content in iac analytics (bb63bba)

  • I hereby acknowledge these release notes are 🥙 AWESOME 🥙

@rontalx rontalx merged commit 183f676 into master Mar 15, 2021
@rontalx rontalx deleted the fix/file-content-in-iac-analytics branch March 15, 2021 16:33
@ipapast ipapast changed the title fix: include file content in iac analytics fix: include file content in iac analytics CC-743 Mar 15, 2021
This was referenced Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants