fix: secret referencing string matching #271
Open
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.
Updated the CLIs secret referencing regex pattern matching logic to handle other alternative referencing syntax for platforms like Railway.
RAILWAY_REF="${{RAILWAY_REF}}"Before this change the CLI would handle it correctly from the users standpoint. But the actual implementation had a flaw which would partially match the secret and look it up, if not found return the original value as is (which is a reason why initially this was thought to be an non issue).High level explanation
SECRET_REF_REGEXcaptures${{RAILWAY_REF}}['{RAILWAY_REF']← with leading{![]← correctly ignored${RAILWAY_REF}['RAILWAY_REF']['RAILWAY_REF']${{RAILWAY_REF}(up to the first}){RAILWAY_REFas the "secret key" (including the leading{){RAILWAY_REF${{RAILWAY_REF}as the unresolved placeholder${{RAILWAY_REF}with${{RAILWAY_REF}${{RAILWAY_REF}}is preservedThe fragility:
If someone ever created a secret literally named
{RAILWAY_REF(with the brace), the current code would incorrectly substitute it:Changes made: