Skip to content

Commit 0b8d330

Browse files
committed
.github: allow upstream caller to run pre build script
Allow a workflow caller to run pre-build scripts though a workflow call variable. This is potentially dangerous as code can be injected here. If for example a malicious actor wants to run there C2 code in the context of someone else they could perhaps inject it here. I assume this is protected by the same mecahism as the workflow files themself. I.e. github users untrusted to the Infix org won't be able to trigger workflows before being explicitly allowed to do so. This patch also adds a checkout secret. This allows upstream callers to fetch there own spin / fork though the infix workflows, if they provide a checkout token with the correct permissions to do so. Signed-off-by: Richard Alpe <[email protected]>
1 parent 4b3ee0f commit 0b8d330

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

.github/workflows/build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ on:
3636
required: false
3737
type: boolean
3838
default: true
39+
pre_build_script:
40+
required: false
41+
type: string
42+
default: ''
43+
description: 'Optional script to run after checkout (for spin customization)'
44+
secrets:
45+
CHECKOUT_TOKEN:
46+
required: false
47+
description: 'Token for cross-repository access'
3948

4049
env:
4150
NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.name || inputs.name }}
@@ -77,6 +86,16 @@ jobs:
7786
clean: true
7887
fetch-depth: 0
7988
submodules: recursive
89+
token: ${{ secrets.CHECKOUT_TOKEN || github.token }}
90+
91+
- name: Run pre-build script
92+
if: ${{ inputs.pre_build_script != '' }}
93+
run: |
94+
cat > ./pre-build.sh << 'EOF'
95+
${{ inputs.pre_build_script }}
96+
EOF
97+
chmod +x ./pre-build.sh
98+
bash ./pre-build.sh
8099
81100
- name: Set Build Variables
82101
id: vars

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ on:
2929
required: false
3030
type: string
3131
default: 'test'
32+
secrets:
33+
CHECKOUT_TOKEN:
34+
required: false
35+
description: 'Token for cross-repository access'
3236

3337
env:
3438
TARGET: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target || inputs.target }}
@@ -59,6 +63,7 @@ jobs:
5963
clean: true
6064
fetch-depth: 0
6165
submodules: recursive
66+
token: ${{ secrets.CHECKOUT_TOKEN || github.token }}
6267

6368
- name: Set Build Variables
6469
id: vars

buildroot

Submodule buildroot updated 226 files

0 commit comments

Comments
 (0)