-
Notifications
You must be signed in to change notification settings - Fork 534
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: Skip specific errors when parsing yaml IaC files #2003
Conversation
251e6c2
to
7ecceac
Compare
15f9ce8
to
e4de2fb
Compare
@almog27 @teodora-sandu I extracted the check as a function and gave it a descriptive name, also added an extra test. If you could have a look again 🙇 |
8a148f0
to
e20ad5a
Compare
e20ad5a
to
dc8ffa0
Compare
The new yaml parser library does some validations that we do not do in Policy Engine, so we return less results in the CLI. These are not critical errors, so we decided to skip them and return the parsed file for consistency with the Policy Engine.
dc8ffa0
to
49c184d
Compare
Expected release notes (by @ipapast) fixes: others (will not be included in Semantic-Release notes):
|
What does this PR do?
We identified a few cases that our services parse the yaml files in a different way. The node 'yaml' library is too 'strict', returning errors for validation of the YAML as well.
In this PR we focus on two specific errors: bad indentation and duplicate keys.
These two examples are not consistent with what Policy Engine returns so in this commit we intentionally skip errors for these cases, and return the parsed YAML document instead.
This will improve the consistency between the two parsers.
Where should the reviewer start?
The changes are in
file-parser.ts
andiac-parser.ts
where we check if the error is one of the two error strings.How should this be manually tested?
Run
snyk-dev iac test duplicate_keys.yaml
See that it is no longer failing but showing results (if any).
What are the relevant tickets?
CC-927
Screenshots
Before:
After:
Additional questions