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: allow escape characters in json parsing [CFG-1322] #2526

Merged
merged 1 commit into from Jan 11, 2022

Conversation

teodora-sandu
Copy link
Contributor

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:

  1. npm run build
  2. npm link

In this branch:

  1. npm run build
  2. Create a file test.json containing:
{
      "DescribePackagesFilterValue":{
        "type":"string",
        "pattern":"^[0-9a-zA-Z\\*\\.\\\\/\\?-]*$"
      }
}
  1. Run snyk iac test test.json - see an error
  2. Run snyk-dev iac test test.json - see no errors

Any 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
Screenshot 2022-01-06 at 13 38 21

Screenshot 2022-01-06 at 12 09 22

snyk-dev iac test test.json
Screenshot 2022-01-06 at 13 38 24

Screenshot 2022-01-06 at 12 11 57

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2022

Warnings
⚠️ You've modified files in src/ directory, but haven't updated anything in test folder. Is there something that could be tested?

Generated by 🚫 dangerJS against 3814c67

@teodora-sandu teodora-sandu force-pushed the fix/json-parsing-escape branch 2 times, most recently from cbeb86b to af27a1e Compare January 10, 2022 16:41
@teodora-sandu teodora-sandu marked this pull request as ready for review January 10, 2022 16:45
@teodora-sandu teodora-sandu requested review from a team as code owners January 10, 2022 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants