Fix test #1140
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
# | |
# SPDX-License-Identifier: Apache-2.0 | |
name: "Static Analysis: Bandit Scan" | |
on: | |
push: | |
branches: | |
- "pull-request/[0-9]+" | |
- "main" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | |
cancel-in-progress: true | |
jobs: | |
analyze: | |
runs-on: ubuntu-latest | |
permissions: | |
security-events: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
- name: Install uv | |
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0 | |
- name: Get ignore codes | |
id: ignore-codes | |
# This are computed so that we can run only the `S` (bandit) | |
# checks. Passing --select to ruff overrides any config files | |
# (ruff.toml, pyproject.toml, etc), so to avoid having keep everything | |
# in sync we grab them from the TOML programmatically | |
run: | | |
set -euxo pipefail | |
echo "codes=$(uvx toml2json ./ruff.toml | jq -r '.lint.ignore | map(select(test("^S\\d+"))) | join(",")')" >> "$GITHUB_OUTPUT" | |
- name: Perform Bandit Analysis using Ruff | |
uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1 | |
with: | |
args: "check --select S --ignore ${{ steps.ignore-codes.outputs.codes }} --output-format sarif --output-file results.sarif" | |
- name: Upload SARIF file | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: results.sarif |