ci: add Bandit SAST security scanning#2466
Merged
louiseschmidtgen merged 2 commits intomainfrom Mar 31, 2026
Merged
Conversation
Signed-off-by: louiseschmidtgen <louise.schmidtgen@canonical.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Bandit static security analysis to the repo’s Python CI pipeline, per security-team recommendation, to catch common Python security issues during linting.
Changes:
- Add Bandit as a pinned dependency in CI/dev requirements and introduce
toxenvironments to run it. - Add a Bandit scan step to the
python-lintGitHub Actions job. - Add a root
pyproject.tomlwith Bandit configuration (excluding.tox).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
tests/integration/tox.ini |
Adds a bandit tox env to scan integration test Python code. |
tests/integration/requirements-dev.txt |
Pins bandit==1.7.10 for integration tox environments. |
pyproject.toml |
Adds Bandit configuration (exclude .tox). |
ci/tox.ini |
Adds bandit tox env (and includes it in env_list). |
ci/requirements-ci.txt |
Pins bandit==1.7.10 for CI tox environments. |
.github/workflows/lint_and_integration.yaml |
Runs Bandit in CI as part of the python-lint job. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: louiseschmidtgen <louise.schmidtgen@canonical.com>
HomayoonAlimohammadi
approved these changes
Mar 31, 2026
Contributor
HomayoonAlimohammadi
left a comment
There was a problem hiding this comment.
LGTM, thanks a lot @louiseschmidtgen!
louiseschmidtgen
added a commit
to canonical/calico-rocks
that referenced
this pull request
Apr 8, 2026
- Add Semgrep SAST workflow with p/python and p/github-actions rulesets - Add Bandit security scan workflow (HIGH severity blocks, -lll) - Pin pip dependencies with hash verification (OSSF Scorecard compliance) - Add pyproject.toml with bandit configuration All tools run as advisory-only; results uploaded to GitHub Security tab via SARIF. Ref: canonical/k8s-snap#2468 (semgrep) Ref: canonical/k8s-snap#2466 (bandit) Ref: canonical/k8s-snap#2492 (dep-pinning)
louiseschmidtgen
added a commit
to canonical/cinder-csi-operator
that referenced
this pull request
Apr 8, 2026
- Add Semgrep SAST workflow with p/python and p/github-actions rulesets - Add Bandit security scan workflow (HIGH severity blocks, -lll) - Pin pip dependencies with hash verification (OSSF Scorecard compliance) - Add bandit configuration to pyproject.toml All tools run as advisory-only; results uploaded to GitHub Security tab via SARIF. Ref: canonical/k8s-snap#2468 (semgrep) Ref: canonical/k8s-snap#2466 (bandit) Ref: canonical/k8s-snap#2492 (dep-pinning)
louiseschmidtgen
added a commit
to charmed-kubernetes/jenkins
that referenced
this pull request
Apr 8, 2026
- Add Semgrep SAST workflow with p/python and p/github-actions rulesets - Add Bandit security scan workflow (HIGH severity blocks, -lll) with weekly schedule - Pin pip dependencies with hash verification (OSSF Scorecard compliance) - Add pyproject.toml with bandit configuration Semgrep results uploaded to GitHub Security tab via SARIF. Bandit runs as pass/fail check in CI logs. Ref: canonical/k8s-snap#2468 (semgrep) Ref: canonical/k8s-snap#2466 (bandit) Ref: canonical/k8s-snap#2492 (dep-pinning)
bschimke95
pushed a commit
to canonical/calico-rocks
that referenced
this pull request
Apr 9, 2026
* ci: add SAST workflows (semgrep + bandit) with dep-pinned installs - Add Semgrep SAST workflow with p/python and p/github-actions rulesets - Add Bandit security scan workflow (HIGH severity blocks, -lll) - Pin pip dependencies with hash verification (OSSF Scorecard compliance) - Add pyproject.toml with bandit configuration All tools run as advisory-only; results uploaded to GitHub Security tab via SARIF. Ref: canonical/k8s-snap#2468 (semgrep) Ref: canonical/k8s-snap#2466 (bandit) Ref: canonical/k8s-snap#2492 (dep-pinning) * fix: update codeql-action to v4, fix bandit format - Update github/codeql-action/upload-sarif from v3 to v4 - Remove unsupported SARIF output from bandit (1.7.10 lacks --format sarif) - Bandit now runs as pass/fail check (blocks on HIGH severity) * ci: add weekly schedule trigger to bandit workflow
This was referenced Apr 9, 2026
Merged
Merged
Open
Open
Open
Merged
ci: add SAST workflows (semgrep + bandit) with dep-pinned installs
canonical/csi-driver-nfs-rocks#13
Open
This was referenced Apr 9, 2026
Open
ci: add SAST workflows (semgrep + bandit) with dep-pinned installs
charmed-kubernetes/layer-canal#86
Open
ci: add SAST workflows (semgrep + bandit) with dep-pinned installs
charmed-kubernetes/layer-etcd#220
Open
Open
bschimke95
pushed a commit
to charmed-kubernetes/jenkins
that referenced
this pull request
Apr 9, 2026
…1673) - Add Semgrep SAST workflow with p/python and p/github-actions rulesets - Add Bandit security scan workflow (HIGH severity blocks, -lll) with weekly schedule - Pin pip dependencies with hash verification (OSSF Scorecard compliance) - Add pyproject.toml with bandit configuration Semgrep results uploaded to GitHub Security tab via SARIF. Bandit runs as pass/fail check in CI logs. Ref: canonical/k8s-snap#2468 (semgrep) Ref: canonical/k8s-snap#2466 (bandit) Ref: canonical/k8s-snap#2492 (dep-pinning)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add Bandit as a Python SAST (Static Application Security Testing) tool to CI, as recommended by the security team.
Bandit scans the following directories for security issues:
tests/integration/ci/build-scripts/docs/tools/Behavior
-lllflag). If Bandit finds any HIGH severity issue, thepython-lintjob will fail.-lllto see all severity levels.Current scan results
No HIGH severity issues exist — CI will pass cleanly.
Changes
bandit==1.7.10totests/integration/requirements-dev.txtandci/requirements-ci.txtbandittox environments intests/integration/tox.iniandci/tox.inipython-lintjob in.github/workflows/lint_and_integration.yamlpyproject.tomlwith[tool.bandit]configuration (exclude.toxdirs)Follow-up