Skip to content

Commit 5ea6602

Browse files
security: harden regex escaping and variable expansion
Additional security hardening for release skill: 1. Escape VERSION in sed regex: - Added regex metacharacter escaping for VERSION variable - Prevents unintended pattern matching if VERSION contains special characters like . + * ( ) [ ] etc. - Creates ESCAPED_VERSION before use in sed pattern 2. Properly quote PRERELEASE variable: - Replaced parameter expansion with explicit if/else - Ensures PRERELEASE is always properly quoted - Prevents word splitting or glob expansion issues These changes address the medium-severity issues identified in the security review. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 344abd6 commit 5ea6602

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

.claude/skills/release/skill.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ flutter packages pub publish || error "Publishing failed"
5252
success "Published to pub.dev!"
5353

5454
# Extract CHANGELOG
55-
CHANGELOG_CONTENT=$(sed -n "/^## ${VERSION}\$/,/^## [0-9]/p" CHANGELOG.md | sed '1d;$d')
55+
# Escape VERSION for use in sed regex (prevent regex metacharacter interpretation)
56+
ESCAPED_VERSION=$(printf '%s\n' "$VERSION" | sed 's/[.[\*^$()+?{|]/\\&/g')
57+
CHANGELOG_CONTENT=$(sed -n "/^## ${ESCAPED_VERSION}\$/,/^## [0-9]/p" CHANGELOG.md | sed '1d;$d')
5658
[[ -z "$CHANGELOG_CONTENT" ]] && CHANGELOG_CONTENT="Release $VERSION\n\nSee CHANGELOG.md for details."
5759

5860
RELEASE_NOTES="## $VERSION
@@ -61,12 +63,20 @@ $CHANGELOG_CONTENT"
6163

6264
# Create GitHub release
6365
info "Creating GitHub draft release..."
64-
GH_RELEASE_URL=$(gh release create "v${VERSION}" \
65-
--title "Release v${VERSION}" \
66-
--notes "$RELEASE_NOTES" \
67-
--target master \
68-
--draft \
69-
${PRERELEASE:+$PRERELEASE})
66+
if [[ -n "$PRERELEASE" ]]; then
67+
GH_RELEASE_URL=$(gh release create "v${VERSION}" \
68+
--title "Release v${VERSION}" \
69+
--notes "$RELEASE_NOTES" \
70+
--target master \
71+
--draft \
72+
"$PRERELEASE")
73+
else
74+
GH_RELEASE_URL=$(gh release create "v${VERSION}" \
75+
--title "Release v${VERSION}" \
76+
--notes "$RELEASE_NOTES" \
77+
--target master \
78+
--draft)
79+
fi
7080

7181
success "GitHub draft release created!"
7282

0 commit comments

Comments
 (0)