Skip to content

Commit 3c667be

Browse files
authored
Merge pull request #80 from MetaMask/cursor/security-code-scanner-fix-c3bb
chore: harden GitHub Actions against shell injection vulnerabilities
2 parents 5c56227 + 0726d55 commit 3c667be

File tree

3 files changed

+41
-31
lines changed

3 files changed

+41
-31
lines changed

.github/workflows/webhook.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,7 @@ on:
88
jobs:
99
run-security-scan:
1010
permissions:
11-
actions: write
12-
checks: write
13-
contents: write
14-
deployments: write
15-
id-token: write
16-
issues: write
17-
discussions: write
18-
packages: write
19-
pages: write
20-
pull-requests: write
21-
repository-projects: write
22-
security-events: write
23-
statuses: write
11+
contents: read
2412
runs-on: ubuntu-latest
2513
steps:
2614
- name: echo stuff

packages/codeql-action/action.yaml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,25 @@ runs:
3131
using: 'composite'
3232
steps:
3333
- name: Debug CodeQL Action Inputs
34+
env:
35+
INPUT_REPO: ${{ inputs.repo }}
36+
INPUT_LANGUAGE: ${{ inputs.language }}
37+
INPUT_BUILD_MODE: ${{ inputs.build_mode }}
38+
INPUT_BUILD_COMMAND: ${{ inputs.build_command }}
39+
INPUT_VERSION: ${{ inputs.version }}
40+
INPUT_DISTRIBUTION: ${{ inputs.distribution }}
41+
INPUT_PATHS_IGNORED: ${{ inputs.paths_ignored }}
42+
INPUT_RULES_EXCLUDED: ${{ inputs.rules_excluded }}
3443
run: |
3544
echo "=================== CODEQL ACTION INPUT DEBUG ==================="
36-
echo "Repository: ${{ inputs.repo }}"
37-
echo "Language: ${{ inputs.language }}"
38-
echo "Build mode: ${{ inputs.build_mode }}"
39-
echo "Build command: ${{ inputs.build_command }}"
40-
echo "Version: ${{ inputs.version }}"
41-
echo "Distribution: ${{ inputs.distribution }}"
42-
echo "Paths ignored: ${{ inputs.paths_ignored }}"
43-
echo "Rules excluded: ${{ inputs.rules_excluded }}"
45+
echo "Repository: $INPUT_REPO"
46+
echo "Language: $INPUT_LANGUAGE"
47+
echo "Build mode: $INPUT_BUILD_MODE"
48+
echo "Build command: $INPUT_BUILD_COMMAND"
49+
echo "Version: $INPUT_VERSION"
50+
echo "Distribution: $INPUT_DISTRIBUTION"
51+
echo "Paths ignored: $INPUT_PATHS_IGNORED"
52+
echo "Rules excluded: $INPUT_RULES_EXCLUDED"
4453
echo "=================================================================="
4554
shell: bash
4655

@@ -75,17 +84,24 @@ runs:
7584
RULES_EXCLUDED: ${{ inputs.rules_excluded}}
7685

7786
- name: Debug Config Generation Outputs
87+
env:
88+
CONFIG_LANGUAGES: ${{ steps.generate-config.outputs.languages }}
89+
CONFIG_BUILD_MODE: ${{ steps.generate-config.outputs.build_mode }}
90+
CONFIG_BUILD_COMMAND: ${{ steps.generate-config.outputs.build_command }}
91+
CONFIG_VERSION: ${{ steps.generate-config.outputs.version }}
92+
CONFIG_DISTRIBUTION: ${{ steps.generate-config.outputs.distribution }}
93+
WORKSPACE: ${{ github.workspace }}
7894
run: |
7995
echo "================= CONFIG GENERATION OUTPUTS ================="
80-
echo "Languages: ${{ steps.generate-config.outputs.languages }}"
81-
echo "Build mode: ${{ steps.generate-config.outputs.build_mode }}"
82-
echo "Build command: ${{ steps.generate-config.outputs.build_command }}"
83-
echo "Version: ${{ steps.generate-config.outputs.version }}"
84-
echo "Distribution: ${{ steps.generate-config.outputs.distribution }}"
96+
echo "Languages: $CONFIG_LANGUAGES"
97+
echo "Build mode: $CONFIG_BUILD_MODE"
98+
echo "Build command: $CONFIG_BUILD_COMMAND"
99+
echo "Version: $CONFIG_VERSION"
100+
echo "Distribution: $CONFIG_DISTRIBUTION"
85101
echo "=============================================================="
86102
echo ""
87103
echo "================= GENERATED CODEQL CONFIG FILE ================="
88-
cat ${{ github.workspace }}/codeql-config-generated.yml
104+
cat "$WORKSPACE/codeql-config-generated.yml"
89105
echo "=================================================================="
90106
shell: bash
91107

@@ -114,10 +130,14 @@ runs:
114130

115131
- name: Build code
116132
if: ${{ steps.generate-config.outputs.build_mode == 'manual' && steps.generate-config.outputs.build_command != '' }}
133+
env:
134+
BUILD_COMMAND: ${{ steps.generate-config.outputs.build_command }}
135+
WORKSPACE: ${{ github.workspace }}
136+
REPO: ${{ inputs.repo }}
117137
run: |
118-
echo "Building code with command: ${{ steps.generate-config.outputs.build_command }}"
119-
cd ${{ github.workspace }}/${{ inputs.repo }}
120-
${{ steps.generate-config.outputs.build_command }}
138+
echo "Building code with command: $BUILD_COMMAND"
139+
cd "$WORKSPACE/$REPO"
140+
eval "$BUILD_COMMAND"
121141
shell: bash
122142

123143
- name: Run CodeQL Analysis

packages/semgrep-action/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ runs:
1616
shell: bash
1717

1818
- name: Generate .semgrepignore
19+
env:
20+
PATHS_IGNORED: ${{ inputs.paths_ignored }}
1921
run: |
2022
echo ".security-scanner/" > .semgrepignore
21-
echo "${{ inputs.paths_ignored }}" >> .semgrepignore
23+
echo "$PATHS_IGNORED" >> .semgrepignore
2224
cat .semgrepignore
2325
shell: bash
2426

0 commit comments

Comments
 (0)