Repository navigation
fix: print the release version - #3023
Conversation
scripts/build-phar.php never replaced the @package_version@ placeholder (box used to), so released binaries answered `--version` with "dev". The build now substitutes it with the version passed as second argument, INSTALLER_VERSION or `git describe --tags`; the release passes the tag and its smoke test checks the binary reports it.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 81cc1b47c3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $phar->addFromString($relative, read_file($file->getPathname())); | ||
| $contents = read_file($file->getPathname()); | ||
| if ('' !== $version && 'src/InstallerCommand.php' === $relative) { | ||
| $contents = str_replace('@package_version@', $version, $contents); |
There was a problem hiding this comment.
Encode the release version before inserting it into PHP
The release workflow accepts every v* tag, but this replacement is inserted verbatim into the single-quoted InstallerCommand::VERSION literal. A valid tag such as v';function&__destruct(){file_put_contents('pwn',1);}#x closes that literal, adds a destructor, and comments out the original trailing quote; the resulting PHAR runs tag-controlled PHP when the command object is destroyed. Encode the version as a PHP string or reject tags outside a strict version pattern before replacing the placeholder.
Useful? React with 👍 / 👎.
|
|
||
| - name: Build PHAR | ||
| run: php -d phar.readonly=0 scripts/build-phar.php dist/api-platform.phar | ||
| run: php -d phar.readonly=0 scripts/build-phar.php dist/api-platform.phar "${{ github.ref_name }}" |
There was a problem hiding this comment.
Pass the tag as data instead of interpolating it into Bash
The release workflow accepts every v* tag, and a valid tag such as v$(id) is substituted into the run script before Bash parses it, so command substitution executes despite the surrounding double quotes. A tag pusher can therefore run commands on the release runners; the build job grants contents: write and exposes GITHUB_TOKEN, and the smoke-test step repeats the same interpolation. Pass the ref through an environment variable and use it as a shell argument in both steps.
Useful? React with 👍 / 👎.
Released binaries always print
API Platform dev:InstallerCommand::VERSIONis@package_version@, a placeholder box used to replace, butscripts/build-phar.phpnever substitutes it. The build now replaces it with the version given as second argument, thenINSTALLER_VERSION, thengit describe --tags(stilldevwhen none is available). The release workflow passes the tag, and its smoke test now fails if--versiondoes not print it.