Skip to content

Commit 7e51d31

Browse files
LukasParkeclaude
andcommitted
fix(upstream): guard ref arguments against option injection
Same hardening as go-agent#2 review nit: '--' terminator on the fallback fetch and --end-of-options on rev-parse so a manual --ref value starting with '-' cannot be parsed as an option. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent a81fec6 commit 7e51d31

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎scripts/upstream‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ else
133133
fi
134134

135135
if [ -n "$ref" ]; then
136-
if ! target_commit="$(git -C "$upstream_dir" rev-parse --quiet --verify "$ref^{commit}")"; then
137-
git -C "$upstream_dir" fetch origin "$ref"
136+
# --end-of-options / --: a ref value starting with "-" must not be parsed as
137+
# an option (CI refs always start with "@", but manual runs take anything).
138+
if ! target_commit="$(git -C "$upstream_dir" rev-parse --quiet --verify --end-of-options "$ref^{commit}")"; then
139+
git -C "$upstream_dir" fetch origin -- "$ref"
138140
target_commit="$(git -C "$upstream_dir" rev-parse FETCH_HEAD^{commit})"
139141
fi
140142
else

0 commit comments

Comments
 (0)