Repository navigation
Codacy: stop Bandit B105 flagging the cls_token keys - #1546
Closed
bruAristimunha wants to merge 3 commits into
Closed
bruAristimunha wants to merge 3 commits into
bruAristimunha wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The review identifies no active issues with the Bandit configuration update.
No open issues 🎉
What changed in this PR
Updates the repository’s Bandit configuration to suppress B105 false positives on foundation-model cls_token keys when Codacy’s configuration-file option is enabled.
Changes:
- Adds B105 to the skipped checks while preserving the existing B101 exclusion.
- Documents why both checks are skipped and when Codacy reads the configuration.
| File | Description |
|---|---|
bandit.yml |
Skips B105 alongside B101 and explains the exclusions. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1546 +/- ##
=======================================
Coverage 91.37% 91.38%
=======================================
Files 170 170
Lines 22123 22137 +14
=======================================
+ Hits 20214 20229 +15
+ Misses 1909 1908 -1 🚀 New features to boost your workflow:
|
# Conflicts: # docs/whats_new.rst
This was referenced Nov 5, 2026
Collaborator
Author
|
Landed on master as 7e42230. The merge API call returned a 502 mid-merge and left this PR open, but the squash commit is on master with exactly this PR's changes (bandit.yml + whats_new). Closing to match. |
bruAristimunha
added a commit
to bruAristimunha/braindecode
that referenced
this pull request
Nov 5, 2026
* Codacy: Bandit config that skips B105 (cls_token keys) and B101 (test asserts) * whats_new: Bandit config for Codacy
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.
Codacy's Bandit flags every
"cls_token": Nonekey in the foundation-modelreturn_featuresdicts as B105 hardcoded_password_string, because the key contains "token". These are model tokens, not secrets. Each one has needed a# nosec B105(11 inbraindecode/today), and new models keep tripping it (Codacy's "1 new issue" on #1540).This adds a root
bandit.yml, one of the config files Codacy reads for Bandit, that skips B105.When Codacy uses a Bandit config file, Bandit runs all its default checks, not only the patterns enabled in Codacy's UI. So the file also skips B101 (assert_used), which Codacy does not report today. Without it, the switch would surface about 3,700 pytest asserts.
bandit -r braindecode test, measured in a Voyager job:bandit.ymlAfter merging: on Codacy → braindecode → Code patterns → Bandit, turn on "Use configuration file". Codacy ignores the file until that toggle is set. The existing
# nosec B105comments can be removed in a follow-up once the toggle is confirmed.