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

attempt to fix once and for all the issue with json validation introduced with version 4.0.13 #384

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jkimalane
Copy link

Attempt to fix once and for all the issue with json validation introduced with version 4.0.13

Change introduced with version 4.0.13 breaks loading of perfectly valid json data into the Chef vault.

Description

Amended methods printable?(string) and validate_json(json) so that json string which contains whitespaces or \n or \r escape sequences are marked as valid.

Perfectly valid json object (read from a file) now validates without triggering an exception or displaying a warning message.

{
"dummy": "aaaa\naaaa\n"
}

Related Issue

#379

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

@jkimalane jkimalane requested review from a team as code owners December 2, 2021 15:59
@schrd
Copy link

schrd commented Dec 15, 2022

Who is reviewing pull requests in this project? We are affected by the same problem. @nikhil2611

@splatteredbits
Copy link

@jkimalane Any chance you can also remove the value from the warning message? Vault is supposed to protect secrets, so they shouldn't be printed to the output.

@splatteredbits
Copy link

@jkimalane Also, this PR needs a developer certificate of origin.

# this returns false for whitespace escape sequences as well, e.g. \n\t
def printable?(string)
/[^[:print:]]|[[:space:]]/.match(string)
/[[:print:]]|[\n\r]/.match?(string)
Copy link

@decoyjoe decoyjoe Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't right either, it only ensures there's at least one printable character.

I think the regex just needs to check for any non-printable characters like this:

not /[^[:print:]]/.match?(string)

@decoyjoe
Copy link

New attempt at fixing this in #416.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants