Skip to content

Commit 059fbf6

Browse files
committed
Workflows: use env vars to prevent injections
1 parent 305085a commit 059fbf6

3 files changed

Lines changed: 44 additions & 31 deletions

File tree

.github/workflows/build-all.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -603,12 +603,16 @@ jobs:
603603
- name: Define properties
604604
shell: bash
605605
run: |
606-
VERSION="${{ github.event.inputs.version || '0.0.0.0' }}"
606+
VERSION="$VERSION"
607607
BRANCH="${GITHUB_REF#refs/heads/}"
608608
COMMIT="${GITHUB_SHA}"
609609
RELEASE_NOTES="${{github.server_url}}/${{github.repository}}/releases"
610-
${{ github.event.inputs.release }} && RELEASE_NOTES+="/tag/${{ github.event.inputs.branch }}"
610+
$RELEASE && RELEASE_NOTES+="/tag/$BRANCH"
611611
echo "NUSPEC_PROPERTIES=version=$VERSION;branch=$BRANCH;commit=$COMMIT;releaseNotes=$RELEASE_NOTES" >> "$GITHUB_ENV"
612+
env:
613+
VERSION: ${{ github.event.inputs.version || '0.0.0.0' }}
614+
RELEASE: ${{ github.event.inputs.release }}
615+
BRANCH: ${{ github.event.inputs.branch }}
612616
- name: Pack
613617
shell: bash
614618
run: |
@@ -651,7 +655,7 @@ jobs:
651655
652656
PLATFORM=\$1
653657
SOURCE_DIR=\$2
654-
VERSION="${{ github.event.inputs.version }}"
658+
VERSION="$VERSION"
655659
656660
# rename "include/" into "include/pdfium/"
657661
shopt -s extglob
@@ -661,6 +665,8 @@ jobs:
661665
python conda/build.py pdfium-binaries \$PLATFORM \$VERSION --about-file conda/about.json --source-dir \$SOURCE_DIR --output-dir conda/out
662666
END
663667
chmod +x conda-build.sh
668+
env:
669+
VERSION: ${{ github.event.inputs.version }}
664670
- name: Build for linux-64
665671
run: ./conda-build.sh linux-64 pdfium-linux-x64
666672
- name: Build for linux-aarch64
@@ -745,18 +751,22 @@ jobs:
745751
echo "::endgroup::"
746752
done
747753
- name: Write release body
748-
run: echo 'This version was built with branch `${{ github.event.inputs.branch }}` of PDFium' > RELEASE.md
754+
run: echo 'This version was built with branch `$BRANCH` of PDFium' > RELEASE.md
755+
env:
756+
BRANCH: ${{ github.event.inputs.branch }}
749757
- name: Get changes
750758
continue-on-error: true
751759
run: |
752-
CURRENT_REV=${{ github.event.inputs.branch }}
760+
CURRENT_REV=$BRANCH
753761
PREVIOUS_REV=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r ".tag_name")
754-
git clone -b "${{ github.event.inputs.branch }}" https://pdfium.googlesource.com/pdfium.git
762+
git clone -b "$BRANCH" https://pdfium.googlesource.com/pdfium.git
755763
cat <<END >> RELEASE.md
756764
### Changes
757765
Commits between \`$PREVIOUS_REV\` and \`$CURRENT_REV\`:
758766
END
759767
git -C "pdfium" log origin/${PREVIOUS_REV}.. --pretty=format:'* [%s](https://pdfium.googlesource.com/pdfium/+/%H)' >> RELEASE.md
768+
env:
769+
BRANCH: ${{ github.event.inputs.branch }}
760770
- name: Generate artifacts checksums
761771
id: hash
762772
run: echo "hashes=$(sha256sum pdfium-*.tgz | base64 -w0)" >> "$GITHUB_OUTPUT"

.github/workflows/build.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,34 +51,32 @@ jobs:
5151
outputs:
5252
artifact: ${{ steps.init.outputs.artifact }}
5353
runs-on: ${{ (inputs.target_os == 'ios' || inputs.target_os == 'mac') && 'macos-14' || inputs.target_os == 'win' && 'windows-2022' || 'ubuntu-24.04' }}
54+
env:
55+
PDFium_BRANCH: $BRANCH
56+
PDFium_IS_DEBUG: ${{ inputs.is_debug }}
57+
PDFium_TARGET_CPU: ${{ inputs.target_cpu }}
58+
PDFium_TARGET_OS: ${{ inputs.target_os }}
59+
PDFium_TARGET_ENVIRONMENT: ${{ inputs.target_environment }}
60+
PDFium_ENABLE_V8: ${{ inputs.enable_v8 }}
61+
PDFium_VERSION: ${{ inputs.version }}
62+
EMSDK_VERSION: ${{ inputs.emsdk_version }}
63+
MUSL_URL: ${{ secrets.MUSL_URL }}
5464
steps:
5565
- name: Initialize
5666
id: init
5767
shell: bash
5868
run: |
5969
ARTIFACT="pdfium"
60-
[ "${{inputs.enable_v8}}" == "true" ] && ARTIFACT="$ARTIFACT-v8"
61-
[ "${{inputs.target_os}}" != "emscripten" ] && ARTIFACT="$ARTIFACT-${{inputs.target_os}}"
62-
[ "${{inputs.target_environment}}" != "" ] && ARTIFACT="$ARTIFACT-${{inputs.target_environment}}"
63-
ARTIFACT="$ARTIFACT-${{inputs.target_cpu}}"
70+
[ "$PDFium_ENABLE_V8" == "true" ] && ARTIFACT="$ARTIFACT-v8"
71+
[ "$PDFium_TARGET_OS" != "emscripten" ] && ARTIFACT="$ARTIFACT-$PDFium_TARGET_OS"
72+
[ "$PDFium_TARGET_ENVIRONMENT" != "" ] && ARTIFACT="$ARTIFACT-$PDFium_TARGET_ENVIRONMENT"
73+
ARTIFACT="$ARTIFACT-$PDFium_TARGET_CPU"
6474
[ "${{inputs.is_debug}}" == "true" ] && ARTIFACT="$ARTIFACT-debug"
6575
echo "artifact=$ARTIFACT" >> $GITHUB_OUTPUT
6676
- name: Checkout this repo
6777
uses: actions/checkout@v4
6878
- name: Set environment variables
69-
run: |
70-
cat >>$GITHUB_ENV <<END
71-
PDFium_BRANCH=${{ inputs.branch }}
72-
PDFium_IS_DEBUG=${{ inputs.is_debug }}
73-
PDFium_TARGET_CPU=${{ inputs.target_cpu }}
74-
PDFium_TARGET_OS=${{ inputs.target_os }}
75-
PDFium_TARGET_ENVIRONMENT=${{ inputs.target_environment }}
76-
PDFium_ENABLE_V8=${{ inputs.enable_v8 }}
77-
PDFium_VERSION=${{ inputs.version }}
78-
EMSDK_VERSION=${{ inputs.emsdk_version }}
79-
MUSL_URL=${{ secrets.MUSL_URL }}
80-
END
81-
steps/00-environment.sh
79+
run: steps/00-environment.sh
8280
shell: bash
8381
- name: Install (1/2)
8482
run: steps/01-install.sh

.github/workflows/mac-univ.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ on:
1414
description: "The name of the artifact"
1515
value: ${{ jobs.build.outputs.artifact }}
1616

17-
1817
jobs:
1918
build:
2019
runs-on: macos-latest
2120
outputs:
2221
artifact: ${{ steps.init.outputs.artifact }}
22+
env:
23+
ARTIFACT_X64: ${{ inputs.artifact_x64 }}
24+
ARTIFACT_ARM64: ${{ inputs.artifact_arm64 }}
2325
steps:
2426
- name: Initialize
2527
id: init
2628
run: |
27-
echo "artifact=${{inputs.artifact_x64}}" | sed "s/x64/univ/g" >> $GITHUB_OUTPUT
29+
echo "artifact=$ARTIFACT_X64" | sed "s/x64/univ/g" >> $GITHUB_OUTPUT
2830
- name: Download ${{ inputs.artifact_x64 }}
2931
uses: actions/download-artifact@v4
3032
with:
@@ -37,13 +39,16 @@ jobs:
3739
path: ${{ inputs.artifact_arm64 }}
3840
- name: Create universal library
3941
run: |
40-
cp -r ${{ inputs.artifact_arm64 }} ${{ steps.init.outputs.artifact }}
41-
sed -i '' '/target_cpu/d' ${{ steps.init.outputs.artifact }}/args.gn
42-
rm ${{ steps.init.outputs.artifact }}/lib/libpdfium.dylib
42+
cp -r $ARTIFACT_ARM64 $OUTPUT_DIR
43+
sed -i '' '/target_cpu/d' $OUTPUT_DIR/args.gn
44+
rm $OUTPUT_DIR/lib/libpdfium.dylib
4345
lipo -create \
44-
${{ inputs.artifact_arm64 }}/lib/libpdfium.dylib \
45-
${{ inputs.artifact_x64 }}/lib/libpdfium.dylib \
46-
-output ${{ steps.init.outputs.artifact }}/lib/libpdfium.dylib
46+
$ARTIFACT_ARM64/lib/libpdfium.dylib \
47+
$ARTIFACT_X64/lib/libpdfium.dylib \
48+
-output $OUTPUT_DIR/lib/libpdfium.dylib
49+
env:
50+
OUTPUT_DIR: ${{ steps.init.outputs.artifact }}
51+
4752
- name: Upload artifact
4853
uses: actions/upload-artifact@v4
4954
with:

0 commit comments

Comments
 (0)