-
Notifications
You must be signed in to change notification settings - Fork 565
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: yaml support for iac wasm bundles [CFG-1271] #2467
Conversation
b0ca454
to
4f01006
Compare
I tracked this down to an issue in the npm-opa-wasm package. Looks like something changed in the WASM API between Node 10 and 12. So when we look at the part of the opa-wasm package that checks the ABI version: In Node 12+ we see the If we patch the code to remove the |
For whoever picks it up next - the last 2 (or even 3) commits can be reverted. Aron has actually had the PR merged with the fix already open-policy-agent/npm-opa-wasm#108, so when this is a new release in that repo, revert these commits and include the new version in the package.json here. |
Co-authored-by: Teodora Sandu <teodora.sandu@snyk.io>
01f1b6b
to
ce9fbe4
Compare
This has now been updated to use the latest opa-wasm release with Node 10 support. All tests are now passing but I wasn't able to remove the mock-fs workaround. Our fixture still doesn't have the correct @ipapast would you mind re-reviewing on behalf of @snyk/group-infrastructure-as-code? |
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 tested by generating a new bundle with the snyk-iac-rules tool and then running a scan with the CLI using node versions (16, 14, 12, 10).
> ./snyk-iac-rules build rules
Generated bundle: bundle.tar.gz
The following brings up 15 issues as expected:
> snyk-dev iac test --rules=../bundle.tar.gz rules/HELLO/fixtures/sg.tf
Attaching screenshots for the buggy version of node10 as well.
What does this PR do?
This PR bumps @open-policy-agent/opa-wasm to 1.6.0 to include support for the
yaml.unmarshal()
function in Rego and support for Node 10. This allows thesnyk iac
command to support additional policies that unmarshall YAML content within Terraform configuration.Where should the reviewer start?
package.json is the primary change here but the implementation of
yaml.unmarshal()
is here: open-policy-agent/npm-opa-wasm#100This also removes the use of the
mock-fs
package in the file-scanner.spec.ts test as the opa-wasm package will useconsole.error
to write out a warning to stderr when loading the wasm fixture and this somehow causesmock-fs
to throw the following error bringing the test suite down:Rather than debug this weird behavior we've decided to just mock out the function that loads the fixtures directly in the test suite.
How should this be manually tested?
rules.zip
Download the above zip file containing a custom rules bundle and unzip:
With the
snyk-iac-rules
tool build a custom bundle:Then test the fixture with the latest snyk cli:
You should see 15 issues found vs. 14 when run with current snyk.
What are the relevant tickets?
CFG-1271