fix: secret referencing string matching#271
Merged
Conversation
- Modified regex patterns to improve handling of cross-application environment variables and local references, ensuring compatibility with various syntax formats. - Introduced checks to ignore Railway-style syntax, enhancing flexibility in environment variable parsing.
- Replaced local variable references for cross-environment and local reference patterns with constants for improved clarity and maintainability. - This change enhances the readability of the code and ensures consistent usage of the defined patterns throughout the module.
- Introduced new tests to ensure that Railway-style ${{...}} and GitHub Actions ${{ secrets.X }} syntax are preserved during secret resolution.
- Added tests for mixed references and secret values containing Railway syntax to validate correct behavior in various scenarios.
- These enhancements improve the robustness of the secret resolution functionality by preventing unintended alterations to specific syntax formats.
Deploying phase-cli-install-script with
|
| Latest commit: |
f9a7eff
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://03f1dc61.phase-cli-install-script.pages.dev |
| Branch Preview URL: | https://fix--secret-referencing-matc.phase-cli-install-script.pages.dev |
rohan-chaturvedi
approved these changes
Dec 30, 2025
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.
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: