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 ENC 'echo' script template to prevent expansion #255

Merged
merged 3 commits into from
Feb 1, 2024

Conversation

elfchief
Copy link
Contributor

@elfchief elfchief commented Jul 1, 2021

Overview

This pull request changes functionality (bugfix)

Currently the template script for creating the 'echo' script used for
ENC data wraps the data provided by the actual ENC in cat <<-EOF,
which causes the enclosed data to be variable-expanded, escape
characters (like double backslashes) to be replaced with their
concrete representations, etc.

This breaks things horribly if you have (e.g.) JSON data with
escaped strings ("C:\\Windows"), which will be processed and
output without those escapes ("C:\Windows"), which is invalid,
and definitely not what the user intended under any circumstance.

Using the 'quoted' variant of shell heredocs (cat <<-'EOF') stops
this expansion/replacement from happening, ensuring that the output
from the echo script is identical to the output of the original ENC script.

Checklist

[x] Make sure that all of the tests pass, and fix any that don't.
[x] Make sure that there is 100%
[n/a] If you have added a new command line option, add corresponding integration test
[n/a] If you have added any new gem dependencies, verify MIT or Apache 20 license
[n/a] If you have added any new gem dependencies, check in .gem file

@elfchief
Copy link
Contributor Author

elfchief commented Jul 1, 2021

Huh. For whatever reason, the test failing here was not failing when run locally (I'm assuming this was my error in some way, because the test obviously should have failed).

I'll push a fix for the test in the morning.

Currently the template script for creating the 'echo' script used for
ENC data wraps the data provided by the actual ENC in `cat <<-EOF`,
which causes the enclosed data to be variable-expanded, escape
characters (like double backslashes) to be replaced with their
concrete representations, etc.

This breaks things horribly if you have (e.g.) JSON data with
escaped strings (`"C:\\Windows"`), which will be processed and
output without those escapes (`"C:\Windows"`), which is invalid,
and definitely not what the user intended under any circumstance.

Using the 'quoted' variant of shell heredocs (`cat <<-'EOF'`) stops
this expansion.
@jhongturney jhongturney merged commit ab6429e into github:master Feb 1, 2024
4 checks passed
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.

2 participants