fix: allow escape characters in json parsing [CFG-1322] #2526
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR fixes the bug in https://snyksec.atlassian.net/browse/CFG-1322 by making sure if the parsed file is JSON we don't fail upon finding
\\/
.How should this be manually tested?
In snyk/cloud-config-parser#39:
npm run build
npm link
In this branch:
npm run build
test.json
containing:snyk iac test test.json
- see an errorsnyk-dev iac test test.json
- see no errorsAny background context you want to provide?
A while ago we combined the parsing for JSON and YAML to both use the YAML parser, since they are more or less the same. We know from https://snyksec.atlassian.net/browse/CFG-364, however, that
\\/
is not valid YAML - and we added this check that throws an error when a YAML/JSON file contains\\/
. Now, we're improving this logic so that if the content is JSON, we don't throw an error.What are the relevant tickets?
https://snyksec.atlassian.net/browse/CFG-1322
Screenshots
snyk iac test test.json
snyk-dev iac test test.json