Skip to content

Commit a95aac8

Browse files
committed
Use "git check-ref-format" for release tags
Uses "git check-ref-format" for defense-in-depth check of input tags (values). Resolves review comments for PR #279.
1 parent 9637978 commit a95aac8

6 files changed

Lines changed: 24 additions & 9 deletions

File tree

.github/workflows/release-codeql.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ jobs:
5454
echo "::error::Version '${RAW_VERSION}' does not match ^vMAJOR.MINOR.PATCH(-PRERELEASE)?$"
5555
exit 1
5656
fi
57+
if ! git check-ref-format "refs/tags/${RAW_VERSION}" >/dev/null 2>&1; then
58+
echo "::error::Version '${RAW_VERSION}' is not a valid git tag ref name"
59+
exit 1
60+
fi
5761
echo "version=${RAW_VERSION}" >> "$GITHUB_OUTPUT"
5862
echo "release_name=${RAW_VERSION#v}" >> "$GITHUB_OUTPUT"
5963

.github/workflows/release-npm.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ jobs:
5151
echo "::error::Version '${RAW_VERSION}' does not match ^vMAJOR.MINOR.PATCH(-PRERELEASE)?$"
5252
exit 1
5353
fi
54+
if ! git check-ref-format "refs/tags/${RAW_VERSION}" >/dev/null 2>&1; then
55+
echo "::error::Version '${RAW_VERSION}' is not a valid git tag ref name"
56+
exit 1
57+
fi
5458
echo "version=${RAW_VERSION}" >> "$GITHUB_OUTPUT"
5559
echo "release_name=${RAW_VERSION#v}" >> "$GITHUB_OUTPUT"
5660

.github/workflows/release-tag.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ jobs:
5151
env:
5252
RAW_VERSION: ${{ inputs.version }}
5353
run: |
54-
# Strict version format: vMAJOR.MINOR.PATCH with optional
55-
# prerelease suffix made of alphanumerics, dots, and hyphens.
56-
# This keeps the resolved outputs free of shell-metacharacters
57-
# so they are safe to interpolate in later run: blocks.
5854
if [[ ! "${RAW_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?$ ]]; then
5955
echo "::error::Version '${RAW_VERSION}' does not match ^vMAJOR.MINOR.PATCH(-PRERELEASE)?$"
6056
exit 1
6157
fi
58+
if ! git check-ref-format "refs/tags/${RAW_VERSION}" >/dev/null 2>&1; then
59+
echo "::error::Version '${RAW_VERSION}' is not a valid git tag ref name"
60+
exit 1
61+
fi
6262
echo "version=${RAW_VERSION}" >> "$GITHUB_OUTPUT"
6363
echo "release_name=${RAW_VERSION#v}" >> "$GITHUB_OUTPUT"
6464

.github/workflows/release-vsix.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ jobs:
5252
echo "::error::Version '${RAW_VERSION}' does not match ^vMAJOR.MINOR.PATCH(-PRERELEASE)?$"
5353
exit 1
5454
fi
55+
if ! git check-ref-format "refs/tags/${RAW_VERSION}" >/dev/null 2>&1; then
56+
echo "::error::Version '${RAW_VERSION}' is not a valid git tag ref name"
57+
exit 1
58+
fi
5559
echo "version=${RAW_VERSION}" >> "$GITHUB_OUTPUT"
5660
echo "release_name=${RAW_VERSION#v}" >> "$GITHUB_OUTPUT"
5761

.github/workflows/release.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,17 @@ jobs:
7272
VERSION="${REF_NAME}"
7373
fi
7474
75-
# Strict version format: vMAJOR.MINOR.PATCH with optional
76-
# prerelease suffix made of alphanumerics, dots, and hyphens.
77-
# This keeps the resolved outputs free of shell-metacharacters
78-
# so they are safe to interpolate in later run: blocks.
75+
# Validate the resolved version: strict regex first, then
76+
# git check-ref-format so values like 'v1.2.3-..' (regex-valid but
77+
# rejected by git) are caught here instead of in actions/checkout.
7978
if [[ ! "${VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?$ ]]; then
8079
echo "::error::Version '${VERSION}' does not match ^vMAJOR.MINOR.PATCH(-PRERELEASE)?$"
8180
exit 1
8281
fi
82+
if ! git check-ref-format "refs/tags/${VERSION}" >/dev/null 2>&1; then
83+
echo "::error::Version '${VERSION}' is not a valid git tag ref name"
84+
exit 1
85+
fi
8386
8487
# Resolve publish flags (default true for tag pushes)
8588
if [ "${EVENT_NAME}" == "workflow_dispatch" ]; then

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ _Changes on `main` since the latest tagged release that have not yet been includ
3131
- The `setup-codeql-environment` composite action now sets up Rust (default `1.80.0`, configurable via `rust-version`) when `rust` is in the `languages` input, including a dedicated cache for `~/.cargo`/`~/.rustup` and a Cargo dependency-file detector. **Rust is opt-in only** — it is intentionally NOT included in the default `languages` value (`csharp,go,java,javascript,python,ruby`) because the Rust toolchain (rustc + cargo + rust-src) is a several-hundred-megabyte download. Callers that need Rust support must pass an explicit `languages:` override that includes `rust` (e.g. `languages: ${{ matrix.language }}` from a per-language matrix entry). ([#279](https://github.com/advanced-security/codeql-development-mcp-server/pull/279))
3232
- The `setup-codeql-environment` composite action now matches the `languages` input with comma-bounded tokens (`contains(format(',{0},', inputs.languages), ',java,')`) instead of bare substring `contains()`. This fixes a latent bug where the JavaScript matrix entry triggered the Java setup steps because `contains('javascript', 'java')` was true. ([#279](https://github.com/advanced-security/codeql-development-mcp-server/pull/279))
3333
- `query-unit-tests.yml` matrix entries now pass `languages: ${{ matrix.language }}` to the composite action so each language matrix entry installs only its own runtime instead of the full default set, and `runs-on` is pinned to `ubuntu-24.04`. ([#279](https://github.com/advanced-security/codeql-development-mcp-server/pull/279))
34-
- All release workflow `version` inputs (in `release.yml`, `release-tag.yml`, `release-npm.yml`, `release-vsix.yml`, `release-codeql.yml`) now document the actual accepted format (`^vMAJOR.MINOR.PATCH(-PRERELEASE)?$` where `PRERELEASE` may contain alphanumerics, dots, and hyphens) and are validated against that regex via an `env:` intermediate variable. ([#279](https://github.com/advanced-security/codeql-development-mcp-server/pull/279))
34+
- All release workflow `version` inputs (in `release.yml`, `release-tag.yml`, `release-npm.yml`, `release-vsix.yml`, `release-codeql.yml`) now document the actual accepted format (`^vMAJOR.MINOR.PATCH(-PRERELEASE)?$` where `PRERELEASE` may contain alphanumerics, dots, and hyphens) and are validated against that regex via an `env:` intermediate variable. Validation also runs `git check-ref-format "refs/tags/${VERSION}"` so values that pass the regex but are rejected by git as a tag ref (e.g. `v1.2.3-..`, `v1.2.3-foo.`, `v1.2.3-foo.lock`, `v1.2.3-a..b`) are caught up front instead of failing later in `actions/checkout`. ([#279](https://github.com/advanced-security/codeql-development-mcp-server/pull/279))
3535

3636
### Fixed
3737

0 commit comments

Comments
 (0)