Repository navigation
Run Bandit with a fixed config so skills cannot hide findings - #835
Merged
Merged
Conversation
The Tier 1 code risk check ran `bandit -r <skill>` without `--ini` or `--ignore-nosec`. Bandit then walks the scanned tree for a `.bandit` file and applies its `skips`, `tests` and `configfile` settings, and it honours `# nosec` comments. A skill shipping `.bandit` with `skips = B602,B307` (at the root or nested, e.g. `scripts/.bandit`) or `tests = B101`, or `# nosec` on risky lines, made findings such as `subprocess.call(cmd, shell=True)` (B602) and `eval(sys.argv[1])` (B307) disappear, and the check passed. Two `.bandit` files made Bandit exit 2 instead of scanning. Pass `--ini` pointing at a packaged, empty `skillevaluator/config/ bandit.ini` and `--ignore-nosec`. With `--ini` given, Bandit does not search the target tree for `.bandit` at all, so root, nested and multiple files are ignored regardless of the working directory. A `.bandit` file found in the skill is reported as an ignored configuration warning. Document that `.bandit` files and `# nosec` comments are not honoured, and cover root, nested, duplicate, `tests` allow-list and `# nosec` variants with tests that run Bandit. Refs #830 Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
chrisknvidia
marked this pull request as ready for review
November 20, 2026 18:32
chrisknvidia
requested review from
mosheabr,
rmalani-nv and
rng1995
as code owners
November 20, 2026 18:32
This was referenced Nov 22, 2026
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
Tier 1 code risk ran
bandit -r <skill>without--inior--ignore-nosec. Bandit searches the scanned tree for a.banditfile and applies itsskips/tests/configfilesettings, and honours# noseccomments. A skill could therefore ship.banditwithskips = B602,B307(at the root or nested, e.g.scripts/.bandit) ortests = B101, or add# nosecto risky lines, and findings forsubprocess.call(cmd, shell=True)(B602) andeval(sys.argv[1])(B307) disappeared so the check passed. Two.banditfiles made Bandit exit 2 instead of scanning.Fix
--inipointing at a packaged, emptyskillevaluator/config/bandit.iniand with--ignore-nosec. With--inipresent Bandit does not walk the target for.banditat all, so root, nested and duplicate files are ignored regardless of the working directory. Even a missing INI path still disables discovery, so a broken install degrades to a Bandit warning rather than a bypass..banditfile found in the skill as an ignored-configuration warning..banditfiles and# noseccomments inside a skill are not honoured.Tests
New
TestBanditIgnoresSkillConfigintests/validators/test_security_validators.py: argv pins--iniand--ignore-nosec, the packaged INI is empty, a.banditin the skill is reported, and parametrized cases that run the real Bandit (rootskips, nestedscripts/.bandit, two.banditfiles,tests = B101,# nosec) each still report B602 and B307 and do not pass. Those five failed before the fix.tests/validators/: 5405 passed, 2 skipped locally.Related
The real-Bandit tests set
exclude_tests=Falsebecause Bandit's--excludedoes substring matching on the full path, so the defaulttests,testexclusion scans nothing when the skill's absolute path contains "test". That is tracked separately in #817 / #818.Refs #830