fix(security): safe export parsing in provision.sh (#3075, #3071)#3084
Open
fix(security): safe export parsing in provision.sh (#3075, #3071)#3084
Conversation
Replace sed-based extraction with POSIX parameter expansion for
cloud_headless_env export parsing in provision.sh:
- Use ${var#pattern}/${var%%pattern}/${var%pattern} instead of sed
subshells — no external processes, fully bash 3.2 compatible
- Tighten case filter: require proper export VAR="VALUE" form
(was: export *=* which was too permissive)
- Add explicit name validation (must match [A-Za-z_][A-Za-z0-9_]*)
- Fix backslash detection: *\\* catches single backslash
(was: *'\\'* which only matched double backslash)
Agent: code-health
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This was referenced Mar 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why: The export parsing in provision.sh had a backslash detection bug and used sed subshells that could be replaced with safer POSIX parameter expansion for better bash 3.2 compatibility.
Changes
${var#pattern},${var%%pattern},${var%pattern}instead of twosed -nsubshell calls per line. No external processes needed, fully bash 3.2 compatible.export *=*(too permissive) toexport [A-Za-z_]*="*"(requires properexport VAR="VALUE"form).[A-Za-z_][A-Za-z0-9_]*via case + grep check.*'\\'*which only matched double backslash (\\) due to single-quote literal semantics. Changed to*\\*which correctly matches any single backslash.Verification
bash -nsyntax check passes[[, noBASH_REMATCH, no=~)Fixes #3075
Fixes #3071
-- refactor/code-health