-
Notifications
You must be signed in to change notification settings - Fork 330
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 value escaping in codeql-env.sh #477
Conversation
4a4a2ac
to
44ebca1
Compare
src/runner.ts
Outdated
@@ -249,7 +249,7 @@ program | |||
const shEnvFileContents = Object.entries(tracerConfig.env) | |||
// Some vars contain ${LIB} that we do not want to be expanded when executing this script | |||
.map( | |||
([key, value]) => `export ${key}="${value.replace(/\$/g, "\\$")}"` | |||
([key, value]) => "export " + key + "='" + value.replace(/'/g, "'\"'\"'") + "'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
([key, value]) => "export " + key + "='" + value.replace(/'/g, "'\"'\"'") + "'" | |
([key, value]) => `export ${key}='${value.replace(/'/g, "'\"'\"'")}'` |
44ebca1
to
e7e64d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's safer to use single quotes instead of escaping the $
.
I know there are consumers converting the windows output to sh (as they use bash on windows) but I don't know about users converting the sh output. |
Arrrrgh....also need to update the compile files. Let me just push a change up. |
Co-authored-by: Andrew Eisenberg <[email protected]>
11f9ba6
to
a6ebb19
Compare
Do we need a change note warning users of the different quoting? |
Based on how we are doing things now, the answer is no. And as we discussed, this might change, but I don't think we should be holding this PR up until we make any process changes. |
@hmakholm, merged this for you because you mentioned earlier that you kept having merge conflicts if you waited too long. |
Thank you! |
CodeQL itself complained (correctly) that the escaping here would fail if the value contains backslashes.
Switch to single-quoting, which is less tricky to escape.
Hmmm, how confident are we that there are not consumers that try to parse
codeql-env.sh
themselves and will break if they don't find double quotes? They should be using the JSON output instead, but still ...Merge / deployment checklist