Skip to content

Commit bb79da7

Browse files
committed
ci: compute codes so that we do not have to remember to keep things in sync
1 parent bafc61f commit bb79da7

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/bandit.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,18 @@ jobs:
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
24+
- name: Get ignore codes
25+
id: ignore-codes
26+
# This are computed so that we can run only the `S` (bandit)
27+
# checks. Passing --select to ruff overrides any config files
28+
# (ruff.toml, pyproject.toml, etc), so to avoid having keep everything
29+
# in sync we grab them from the TOML programmatically
30+
run: |
31+
echo "codes=$(yj -tj < ./ruff.toml | jq '[.lint.ignore[] | select(test("^S\\d+"))] | join(",")' -r)" >> "$GITHUB_OUTPUT"
2432
- name: Perform Bandit Analysis using Ruff
2533
uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1
2634
with:
27-
args: "--select S --ignore S101,S311,S404 --config ruff.toml --output-format sarif --output-file results.sarif"
35+
args: "--select S --ignore ${{ steps.ignore-codes.outputs.codes }} --output-format sarif --output-file results.sarif"
2836
- name: Upload SARIF file
2937
uses: github/codeql-action/upload-sarif@v3
3038
with:

0 commit comments

Comments
 (0)