You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prevent script injection in PR workflow (#340)
Move github.event references to env vars and expand validation to check
all github.event.* usage in run steps
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
if [[ "${{ github.event.pull_request.user.login }}" == "aws-application-signals-bot" ]]; then
34
+
if [[ "${{ env.USER }}" == "aws-application-signals-bot" ]]; then
31
35
echo "Skipping check: PR from aws-application-signals-bot"
32
36
exit 0
33
37
fi
34
38
35
-
if [[ "${{ github.event.pull_request.user.login }}" == "dependabot[bot]" ]]; then
39
+
if [[ "${{ env.USER }}" == "dependabot[bot]" ]]; then
36
40
echo "Skipping check: PR from dependabot"
37
41
exit 0
38
42
fi
39
43
40
44
# Check for skip changelog label
41
-
if echo '${{ toJSON(github.event.pull_request.labels.*.name) }}' | jq -r '.[]' | grep -q "skip changelog"; then
45
+
if echo '${{ env.LABELS }}' | jq -r '.[]' | grep -q "skip changelog"; then
42
46
echo "Skipping check: skip changelog label found"
43
47
exit 0
44
48
fi
@@ -71,7 +75,7 @@ jobs:
71
75
72
76
echo "No versioned actions found in changed files"
73
77
74
-
- name: Check for github.event.inputs in run steps
78
+
- name: Check for github.event in run steps
75
79
if: always()
76
80
run: |
77
81
# Get changed GitHub workflow/action files
@@ -81,20 +85,20 @@ jobs:
81
85
VIOLATIONS=""
82
86
for file in $CHANGED_FILES; do
83
87
# Extract all 'run' step values excluding this validation step
84
-
RUN_STEPS=$(yq eval '.. | select(has("run") and has("name") and .name != "Check for github.event.inputs in run steps") | .run' "$file" 2>/dev/null || echo "")
85
-
if echo "$RUN_STEPS" | grep -q "github\.event\.inputs\."; then
86
-
VIOLATIONS="$VIOLATIONS$file: Contains github.event.inputs.* in run step\n"
88
+
RUN_STEPS=$(yq eval '.. | select(has("run") and has("name") and .name != "Check for github.event in run steps") | .run' "$file" 2>/dev/null || echo "")
89
+
if echo "$RUN_STEPS" | grep -q "github\.event\."; then
90
+
VIOLATIONS="$VIOLATIONS$file: Contains github.event.* in run step\n"
87
91
fi
88
92
done
89
93
90
94
if [ -n "$VIOLATIONS" ]; then
91
-
echo -e "Found github.event.inputs.* usage in run steps. This can lead to script injection vulnerabilities:"
95
+
echo -e "Found github.event.* usage in run steps. This can lead to script injection vulnerabilities:"
92
96
echo -e "$VIOLATIONS"
93
97
exit 1
94
98
fi
95
99
fi
96
100
97
-
echo "No github.event.inputs usage found in run steps"
0 commit comments