From 57eb02b6ba38d0be38179db3dc73f6293ede54e4 Mon Sep 17 00:00:00 2001 From: Luka Jeran Date: Fri, 9 Aug 2024 23:07:29 +0200 Subject: [PATCH] Harden github workflow against injection --- .github/workflows/publish.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index a408ed63..bf97becf 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -41,8 +41,13 @@ jobs: run: pnpm build - name: Extract package from tag id: extract-tag + env: + # There's no support for escaping this for use in a shell command. + # GitHub's recommendation is to pass it through the environment. + # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable + REF_NAME: ${{ github.ref_name }} run: | - echo "NPM_PACKAGE=$(echo ${{ github.ref_name }} | grep -oE '(clients/js|contracts|integrations/(hardhat|wagmi-v2|viem-v2))')" >> $GITHUB_OUTPUT + echo "NPM_PACKAGE=$(echo $REF_NAME | grep -oE '(clients/js|contracts|integrations/(hardhat|wagmi-v2|viem-v2))')" >> $GITHUB_OUTPUT - name: Publish ${{ github.ref_name }} to NPM uses: JS-DevTools/npm-publish@v3 with: