ci: validate release tags before writing them to $GITHUB_ENV - #1443
ci: validate release tags before writing them to $GITHUB_ENV#1443dwin-gharibi wants to merge 1 commit into
Conversation
Signed-off-by: Dwin Gharibi <dwin.gharibi@email.kntu.ac.ir>
Review of #1443 —
|
Closes #1442.
Motivation
Both release scripts echo parsed tags verbatim into
$GITHUB_ENVand$GITHUB_OUTPUT. A value containing anewline writes extra lines, which the runner parses as further
KEY=VALUEpairs — so whoever controls thepin file can set arbitrary environment variables (
LD_PRELOAD,NODE_OPTIONS,PATH, …) for everysubsequent step in the job.
read-kernel-metadata.shapplied no format validation at all;read-release-assets.shchecked only a prefix,leaving the rest of the value unconstrained.
What this changes
Validation is added in the Python half of each script, before anything is printed — so the check covers both
the
evalpath and the--exportpath, and a bad value fails the script instead of being sanitised intosomething surprising.
scripts/read-kernel-metadata.sh—bm.source_tagandpvm.source_tagmust match[A-Za-z0-9._+-]+.scripts/read-release-assets.sh— the same charset check is applied to all four pins, in addition tothe existing
kernel-release-/guest-image-prefix checks (which are kept).The error names the offending key and quotes the value, and says why the constraint exists.
[A-Za-z0-9._+-]is the character set git tags and release names actually use; it excludes newline, CR,=and shell metacharacters by construction, so there is no separate newline check to get wrong.
No comment changes.
Testing
Crafted inputs are rejected and nothing is written:
Valid inputs still work:
And the real committed pin file passes, which is the check that matters for not breaking the release
workflows:
There is no committed
kernel-metadata.jsonin the tree (it is produced by the kernel release workflow), sothat script was exercised with a synthesised valid file.
CI gates: these scripts are not covered by
fmt-checkorunit-test-check. They are consumed byrelease-one-click.ymlandrelease-docker-images.yml, whose inputs are the files verified above.Risk / rollout
A release would now fail rather than silently proceed if a pin file contained an unexpected character.
That is the intent, and the current pins pass. If any real tag ever needs a character outside
[A-Za-z0-9._+-], the regex is the single place to widen it.