-
Notifications
You must be signed in to change notification settings - Fork 551
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: TF Language Support - dereference variables in CWD while parsing [CFG-1496] #2752
Conversation
6d46867
to
b8c56a4
Compare
f9608aa
to
e791e19
Compare
8eff457
to
25dde23
Compare
fd25561
to
8ed7675
Compare
I can't reply to your comment but in regards to
I'm guessing you mean we'll have two folders, |
yes, I was thinking something like that, but you're right the paths should be different already. |
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.
Looks great, I unfortunately can't run my CLI locally, but your screenshots show it's working.
If you could fix the acceptance tests to validate that and I'll approve when we get back in the morning. 🙌
The parseTerraformFiles
function could also be covered with a unit test as it's exported and has some if flows.
65933ee
to
00db51b
Compare
f1e6a4e
to
10b668f
Compare
10b668f
to
133cf03
Compare
What does this PR do?
This PR introduces a new parsing flow for Terraform files, which supports dereferencing variables. This flow is behind the
iacTerraformVarSupport
feature flag and currently only supports scanning Terraform files in the current directory.Scanning nested directories is out of scope for this PR.
Where should the reviewer start?
The changes are split in commits:
release-scripts]/
are to update the version of thesnyk/snyk-iac-parsers
library to the latest, https://github.com/snyk/snyk-iac-parsers/releases/tag/v0.2.0parseTerraformFiles
function will take in the Terraform files, send them to thesnyk-iac-parsers
library, and modify them into the desired outputiacTerraformVarSupport
feature flag is enabled or notsrc/cli/commands/test/iac-local-execution/file-loader.ts
we modify the directory reader to take in an optionalvalidFileTypes
, which specifies what kind of files are validiacTerraformVarSupport
feature flag is enabled, thus allowing us to parse Terraform files separately with ourparseTerraformFiles
functionHow should this be manually tested?
npm run build
snykiac test variables/
snyk-dev iac test variables/
and see that there are extra misconfigurationsAny background context you want to provide?
This PR is the first in a line of PRs to enhance Terraform Language Support, as part of this feature. We have delivered a new Terraform parser in https://github.com/snyk/snyk-iac-parsers, which supports extracting variables and dereferencing them inline wherever they're references. The files referencing these variables get converted into JSON, which is used to run our Rego rules (internal or custom) and discover misconfigurations.
What are the relevant tickets?
https://snyksec.atlassian.net/browse/CFG-1498
Screenshots
Before:
After: