From ad1af56850678156661736e4e92e7d211a7754c4 Mon Sep 17 00:00:00 2001 From: Dor Harpaz Date: Thu, 19 Nov 2026 17:42:40 +0200 Subject: [PATCH 1/2] scan the dependencies for vulnerabilities with trivy The requirements files are unpinned, so pip resolves them first (`--dry-run`, metadata only), and Trivy scans the pinned list. Runs weekly, on PRs that change the requirements, and on demand; one scan per classiq extra. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/Security-dependencies.yml | 86 +++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/Security-dependencies.yml diff --git a/.github/workflows/Security-dependencies.yml b/.github/workflows/Security-dependencies.yml new file mode 100644 index 000000000..6e2421046 --- /dev/null +++ b/.github/workflows/Security-dependencies.yml @@ -0,0 +1,86 @@ +name: "Security (dependencies)" + +# Scans every dependency (direct and transitive) for known vulnerabilities, using Trivy (https://trivy.dev). +# The requirements files are unpinned, which Trivy can't resolve, so we let pip pin them first. + +on: + # PRs (including forks) that change the dependencies + pull_request: + branches: + - main + paths: + - "requirements*.txt" + - .github/workflows/Security-dependencies.yml + + # New vulnerabilities are published all the time + schedule: + - cron: "00 05 * * 6" # Saturday, 05:00 UTC + + workflow_dispatch: + +permissions: + contents: read + +defaults: + run: + shell: bash + +jobs: + scan: + runs-on: ubuntu-latest + timeout-minutes: 15 + + # The notebooks install classiq's extras (`!pip install "classiq[chemistry]"`), which pin some packages + # to other versions, so each extra gets its own scan. + strategy: + fail-fast: false + matrix: + classiq: + - classiq + - classiq[chemistry] + - classiq[qml] + - classiq[qsp] + # all the extras (there's no `classiq[all]`) + - classiq[analyzer-sdk,chemistry,cudaq,qml,qsp] + + env: + CLASSIQ: ${{ matrix.classiq }} + # Trivy reads pinned dependencies only from a file named exactly `requirements.txt` + PINNED_DIR: ${{ runner.temp }}/pinned + + steps: + - name: Checkout repository + uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Set up Python + uses: actions/setup-python@v7 + with: + python-version-file: .github/.python-version + + # `--dry-run` downloads only the packages' metadata, so it's much faster than installing them. + # The result is what a user gets from PyPI, which is what we want to scan (e.g., torch with CUDA). + - name: Pin dependencies + run: | + # The latest pip takes ~20s here; an older one (25.2) downloaded whole packages and took over 10 minutes + python -m pip install -U pip + + mkdir -p "$PINNED_DIR" + python -m pip install --dry-run --ignore-installed --quiet --report - \ + -r requirements.txt -r requirements_tests.txt -r requirements_notebooks.txt "$CLASSIQ" \ + | jq -r '.install[] | "\(.metadata.name)==\(.metadata.version)"' \ + > "$PINNED_DIR/requirements.txt" + cat "$PINNED_DIR/requirements.txt" + + # Fails only on HIGH/CRITICAL vulnerabilities that already have a fixed version (i.e., we can act on them) + # Trivy 0.76.2 was released on 2026-11-05 + - name: Scan dependencies + run: > + docker run --rm --volume "$PINNED_DIR:/src:ro" --workdir /src + aquasec/trivy:0.76.2 fs . + --scanners vuln + --severity HIGH,CRITICAL + --ignore-unfixed + --quiet + --exit-code 1 From 0e752cbfd86daf890cebd223841973c31a28856a Mon Sep 17 00:00:00 2001 From: Dor Harpaz Date: Thu, 19 Nov 2026 18:00:48 +0200 Subject: [PATCH 2/2] runner.temp isn't available in a job's env Co-Authored-By: Claude Opus 5.5 --- .github/workflows/Security-dependencies.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Security-dependencies.yml b/.github/workflows/Security-dependencies.yml index 6e2421046..04d00efd5 100644 --- a/.github/workflows/Security-dependencies.yml +++ b/.github/workflows/Security-dependencies.yml @@ -46,7 +46,7 @@ jobs: env: CLASSIQ: ${{ matrix.classiq }} # Trivy reads pinned dependencies only from a file named exactly `requirements.txt` - PINNED_DIR: ${{ runner.temp }}/pinned + PINNED_DIR: pinned steps: - name: Checkout repository @@ -77,7 +77,7 @@ jobs: # Trivy 0.76.2 was released on 2026-11-05 - name: Scan dependencies run: > - docker run --rm --volume "$PINNED_DIR:/src:ro" --workdir /src + docker run --rm --volume "$PWD/$PINNED_DIR:/src:ro" --workdir /src aquasec/trivy:0.76.2 fs . --scanners vuln --severity HIGH,CRITICAL