diff --git a/.github/workflows/sdk-smoke.yml b/.github/workflows/sdk-smoke.yml index a36b486..24b1276 100644 --- a/.github/workflows/sdk-smoke.yml +++ b/.github/workflows/sdk-smoke.yml @@ -56,37 +56,56 @@ jobs: # Resolve the version to test: repository_dispatch payload > workflow_dispatch # input > pinned default. + # The dispatch payload is attacker-influencable, so it is passed through + # `env:` and dereferenced as a shell variable. Interpolating `${{ }}` + # directly into `run:` would splice it into the script text itself. - name: Resolve SDK version id: sdk_ver + env: + PAYLOAD_VERSION: ${{ github.event.client_payload.version }} + INPUT_VERSION: ${{ inputs.sdk_version }} + PINNED_VERSION: ${{ env.SDK_VERSION }} run: | - VERSION="${{ github.event.client_payload.version }}" + VERSION="$PAYLOAD_VERSION" if [ -z "$VERSION" ]; then - VERSION="${{ inputs.sdk_version }}" + VERSION="$INPUT_VERSION" fi if [ -z "$VERSION" ]; then - VERSION="${{ env.SDK_VERSION }}" + VERSION="$PINNED_VERSION" fi + case "$VERSION" in + ''|*[!A-Za-z0-9.+-]*) + echo "Refusing unexpected SDK version string: $VERSION" + exit 1 + ;; + esac echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "Testing @percolatorct/sdk@$VERSION" # Install dependencies from the *existing* lockfile first so all other # packages (hono, vitest, @solana/web3.js …) are present, then override - # only the SDK dep to the target npm version. --no-frozen-lockfile is - # intentional: we are mutating one dep, not reproducing a build. + # only the SDK dep to the target npm version. - name: Install dependencies (frozen lockfile for non-SDK packages) run: pnpm install --frozen-lockfile + # `pnpm add` rewrites the lockfile by design and does NOT accept + # --no-frozen-lockfile (that flag belongs to `pnpm install`). Passing it + # made pnpm 10 abort with `Unknown option: 'frozen-lockfile'`, failing + # this job on every nightly run before a single test executed. - name: Override SDK dep with published npm version + env: + TARGET_VER: ${{ steps.sdk_ver.outputs.version }} run: | - pnpm add "@percolatorct/sdk@${{ steps.sdk_ver.outputs.version }}" \ - --no-frozen-lockfile + pnpm add "@percolatorct/sdk@${TARGET_VER}" - name: Verify installed SDK version + env: + TARGET_VER: ${{ steps.sdk_ver.outputs.version }} run: | INSTALLED=$(node -e "console.log(require('./node_modules/@percolatorct/sdk/package.json').version)") echo "Installed: $INSTALLED" - if [ "$INSTALLED" != "${{ steps.sdk_ver.outputs.version }}" ]; then - echo "Version mismatch: expected ${{ steps.sdk_ver.outputs.version }}, got $INSTALLED" + if [ "$INSTALLED" != "$TARGET_VER" ]; then + echo "Version mismatch: expected $TARGET_VER, got $INSTALLED" exit 1 fi @@ -95,10 +114,13 @@ jobs: - name: Report result if: always() + env: + JOB_STATUS: ${{ job.status }} + TARGET_VER: ${{ steps.sdk_ver.outputs.version }} run: | - if [ "${{ job.status }}" = "success" ]; then - echo "@percolatorct/sdk@${{ steps.sdk_ver.outputs.version }} smoke PASSED" + if [ "$JOB_STATUS" = "success" ]; then + echo "@percolatorct/sdk@${TARGET_VER} smoke PASSED" else - echo "@percolatorct/sdk@${{ steps.sdk_ver.outputs.version }} smoke FAILED" + echo "@percolatorct/sdk@${TARGET_VER} smoke FAILED" exit 1 fi