Skip to content

Run Bandit with a fixed config so skills cannot hide findings - #835

Merged
chrisknvidia merged 2 commits into
mainfrom
fix/tier1-bandit-skill-config
Nov 20, 2026
Merged

chrisknvidia merged 2 commits into
mainfrom
fix/tier1-bandit-skill-config

Conversation

@chrisknvidia

Copy link
Copy Markdown
Collaborator

Summary

Tier 1 code risk ran bandit -r <skill> without --ini or --ignore-nosec. Bandit searches the scanned tree for a .bandit file and applies its skips / tests / configfile settings, and honours # nosec comments. A skill could therefore ship .bandit with skips = B602,B307 (at the root or nested, e.g. scripts/.bandit) or tests = B101, or add # nosec to risky lines, and findings for subprocess.call(cmd, shell=True) (B602) and eval(sys.argv[1]) (B307) disappeared so the check passed. Two .bandit files made Bandit exit 2 instead of scanning.

Fix

  • Run Bandit with --ini pointing at a packaged, empty skillevaluator/config/bandit.ini and with --ignore-nosec. With --ini present Bandit does not walk the target for .bandit at 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.
  • Report any .bandit file found in the skill as an ignored-configuration warning.
  • Document in the Tier 1 reference that .bandit files and # nosec comments inside a skill are not honoured.
  • CHANGELOG entry under Unreleased / Fixed.

Tests

New TestBanditIgnoresSkillConfig in tests/validators/test_security_validators.py: argv pins --ini and --ignore-nosec, the packaged INI is empty, a .bandit in the skill is reported, and parametrized cases that run the real Bandit (root skips, nested scripts/.bandit, two .bandit files, 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=False because Bandit's --exclude does substring matching on the full path, so the default tests,test exclusion scans nothing when the skill's absolute path contains "test". That is tracked separately in #817 / #818.

Refs #830

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
chrisknvidia marked this pull request as ready for review November 20, 2026 18:32
@chrisknvidia
chrisknvidia merged commit 9667134 into main Nov 20, 2026
27 checks passed
@chrisknvidia
chrisknvidia deleted the fix/tier1-bandit-skill-config branch November 20, 2026 18:33

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant