Skip to content

Fix Code Injection issues #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/codeql-packs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ jobs:
- name: "Build and Publish CodeQL Packs"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKS: ${{ matrix.packs }}
run: |
PACK_PATH="${{ matrix.packs }}/qlpack.yml"
PACK_PATH="${PACKS}/qlpack.yml"
CURRENT_VERSION=$(grep version $PACK_PATH | awk '{print $2}')
PACK_FULLNAME=$(cat $PACK_PATH | grep "name:" | awk '{print $2}')
PACK_NAME=$(echo $PACK_FULLNAME | awk -F '/' '{print $2}')
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/python-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ jobs:
steps:
- name: Set matrix
id: set-matrix
env:
VERSIONS: ${{ inputs.versions }}
run: |
versions="${{ inputs.versions }}"
echo "Version Input :: $versions"
matrix=$(echo "$versions" | tr "," "\n" | awk '{print "\""$1"\""}' | paste -sd "," -)
set -e
echo "Version Input :: $VERSIONS"
matrix=$(echo "$VERSIONS" | tr "," "\n" | awk '{print "\""$1"\""}' | paste -sd "," -)
Copy link
Preview

Copilot AI Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, unvalidated $VERSIONS input is interpolated directly into shell commands, which risks code injection. Add explicit input validation or restrict accepted formats to a safe whitelist.

Copilot uses AI. Check for mistakes.

echo "matrix :: [$matrix]"
echo "matrix=[$matrix]" >> "$GITHUB_OUTPUT"

Expand Down Expand Up @@ -71,9 +73,10 @@ jobs:
fi

- name: Run linting
env:
TOOL: ${{ inputs.tool }}
run: |
set -e
TOOL="${{ inputs.tool }}"
if [[ "$TOOL" == "ruff" ]]; then
pip install ruff
ruff check
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/python-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ jobs:
steps:
- name: Set matrix
id: set-matrix
env:
VERSIONS: ${{ inputs.versions }}
run: |
versions="${{ inputs.versions }}"
echo "Version Input :: $versions"
matrix=$(echo "$versions" | tr "," "\n" | awk '{print "\""$1"\""}' | paste -sd "," -)
set -e
echo "Version Input :: $VERSIONS"
Copy link
Preview

Copilot AI Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shell interpolation of $VERSIONS without validation can allow unintended commands or malformed input to break the matrix setup. Consider validating or sanitizing the input (e.g., enforcing a semver pattern) before using it in the shell pipeline.

Suggested change
echo "Version Input :: $VERSIONS"
echo "Version Input :: $VERSIONS"
if [[ ! "$VERSIONS" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?(,[0-9]+\.[0-9]+(\.[0-9]+)?)*$ ]]; then
echo "Error: Invalid versions input. Must be a comma-separated list of semver versions (e.g., '3.9,3.10,3.11')."
exit 1
fi

Copilot uses AI. Check for mistakes.

matrix=$(echo "$VERSIONS" | tr "," "\n" | awk '{print "\""$1"\""}' | paste -sd "," -)
echo "matrix :: [$matrix]"
echo "matrix=[$matrix]" >> "$GITHUB_OUTPUT"

Expand Down
Loading