litellm/.github/workflows/codeql.yml
yuneng-jiang dc0a852de9
ci: fit the pull request gate into five minutes (#52660)
* ci(unit): upload per-test durations as JUnit XML from each shard

Each unit shard now writes junit.xml and uploads it, so per-test timings can drive shard balancing and the choice of PR core tests.

* ci: fit the pull request gate into five minutes

Lint no longer compiles Rust. The basedpyright env skips installing the
project (same per-rule counts as main's published artifact, 93220) and runs
with four threads, and the python job installs only the dev tools. Import
safety and the OpenAPI gate move to a lint-runtime job in the unit workflow
that reuses the one shared bridge build.

The unit workflow drops coverage, schedules core shards with worksteal so
one big file no longer runs alone at the end, splits the router tests across
two 16-core shards, adds the frequent out-of-core catchers, and adds a
changed-tests job that runs the PR's changed unit tests plus the tests
mirroring its changed source files. The bridge build skips the gateway
wheel on core-mode pull requests, and merge smoke builds the bridge once
instead of once per job on a cache miss.

rust-test, rust-wheel, image-scan and CodeQL move to the integration
cadence, with a rust-tests label to run the Rust jobs on a pull request.
CodSpeed runs on main only.

* ci: build the Rust bridge on a 16-core runner (temporary cache-miss probe)

* ci: reuse the Rust bridge on cost-map-only pull requests

The bridge embeds the cost map, so a pull request that only edits the cost
map JSON used to rebuild Rust in both unit and smoke, about 7 minutes end to
end. The bridge cache key now splits the Rust inputs from the cost map, and a
cost-map-only pull request falls back to a bridge built from the same Rust
inputs with an older embedded map. cost-map-guard still loads the new JSON
through the Rust catalog, and main rebuilds the bridge on every cost map
change.

Unit's bridge job runs on a 16-core runner, which cut a measured cache miss
from 3.5 to 2.0 minutes for pull requests that do change Rust.

* ci: build smoke's Rust bridge on a 16-core runner
2026-11-18 14:41:04 -08:00

87 lines
3.3 KiB
YAML

name: "CodeQL"
on:
schedule:
- cron: "5 8-20/3 * * 1-6"
timezone: America/Los_Angeles
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
analyze:
if: github.event_name != 'schedule' || github.repository == 'BerriAI/litellm'
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
security-events: write
packages: read
actions: read
contents: read
strategy:
fail-fast: false
matrix:
include:
- language: actions
build-mode: none
- language: javascript-typescript
build-mode: none
- language: python
build-mode: none
steps:
- name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
persist-credentials: false
- name: Initialize CodeQL
uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
config-file: ./.github/codeql/codeql-config.yml
queries: +security-extended
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
with:
category: "/language:${{ matrix.language }}"
output: sarif-results
upload: failure-only
# py/weak-sensitive-data-hashing (CWE-328) fires on the OCI signing call at
# litellm/llms/oci/common_utils.py, which hashes the HTTP request body to
# produce the x-content-sha256 header required by the OCI HTTP signing spec —
# a content-integrity hash, not a password or secret hash. SHA-256 is mandated
# by Oracle for this header; see
# https://docs.oracle.com/en-us/iaas/Content/API/Concepts/signingrequests.htm
# The `usedforsecurity=False` flag on the hashlib.sha256 call already declares
# non-security intent, but CodeQL's taint flow still re-fires when callers
# further up the stack are modified. The suppression is scoped to this one
# file/rule pair via SARIF post-filtering so every other callsite of
# py/weak-sensitive-data-hashing in the repository continues to be analyzed.
# The same query fires on the HIBP k-anonymity lookup in
# litellm/proxy/auth/password_policy.py, where the password's SHA-1 is only
# a lookup key into the haveibeenpwned range API (the protocol mandates
# SHA-1) and the digest itself never leaves the proxy beyond its first 5
# characters.
- name: Filter SARIF (OCI sha256, HIBP sha1)
if: matrix.language == 'python'
uses: advanced-security/filter-sarif@2da736ff05ef065cb2894ac6892e47b5eac2c3c0 # v1.1
with:
patterns: |
-litellm/llms/oci/common_utils.py:py/weak-sensitive-data-hashing
-litellm/proxy/auth/password_policy.py:py/weak-sensitive-data-hashing
input: sarif-results/python.sarif
output: sarif-results/python.sarif
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
with:
sarif_file: sarif-results
category: "/language:${{ matrix.language }}"