Skip to content

Commit 77358e7

Browse files
Copilotgreenc-FNAL
andcommitted
Add validation for language-matrix input to prevent invalid JSON
Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
1 parent 82c03bc commit 77358e7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

.github/workflows/codeql-analysis.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ jobs:
228228
# If detection was skipped, use all languages or the provided language-matrix
229229
if [ "${{ needs.pre-check.outputs.skip_detection }}" = "true" ]; then
230230
if [ "${{ github.event_name }}" = "workflow_call" ] && [ -n "${{ inputs.language-matrix }}" ]; then
231+
# Validate that language-matrix is valid JSON
232+
if ! echo '${{ inputs.language-matrix }}' | python3 -c "import sys, json; json.load(sys.stdin)" 2>/dev/null; then
233+
echo "::error::Invalid language-matrix input: must be valid JSON array"
234+
exit 1
235+
fi
231236
echo "languages=${{ inputs.language-matrix }}" >> "$GITHUB_OUTPUT"
232237
else
233238
echo 'languages=["cpp", "python", "actions"]' >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)