Skip to content

feat(linter): Adapter for bandit#132

Merged
justinchuby merged 1 commit intojustinchuby:mainfrom
perheld:ph-bandit
Jan 21, 2026
Merged

feat(linter): Adapter for bandit#132
justinchuby merged 1 commit intojustinchuby:mainfrom
perheld:ph-bandit

Conversation

@perheld
Copy link
Copy Markdown
Contributor

@perheld perheld commented Jan 15, 2026

Comment thread examples/adapters/bandit_linter/.lintrunner.toml Fixed
Comment thread examples/adapters/bandit_linter/.lintrunner.toml Fixed
Comment thread lintrunner_adapters/adapters/bandit_linter.py Fixed
Comment thread lintrunner_adapters/adapters/bandit_linter.py Fixed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a lintrunner adapter for Bandit, a Python security linter. The adapter integrates Bandit into the lintrunner framework by parsing its JSON output and converting it to LintMessage objects.

Changes:

  • Implemented bandit_linter.py adapter with JSON output parsing and concurrent file processing
  • Added example configuration in .lintrunner.toml demonstrating usage with a config file
  • Includes proper error handling for command failures and JSON parsing

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lintrunner_adapters/adapters/bandit_linter.py New adapter that wraps Bandit security linter with JSON output parsing, concurrent execution, and severity mapping
examples/adapters/bandit_linter/.lintrunner.toml Example configuration file showing how to use the bandit adapter with lintrunner

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lintrunner_adapters/adapters/bandit_linter.py Outdated
Comment thread lintrunner_adapters/adapters/bandit_linter.py Outdated
Copy link
Copy Markdown
Owner

@justinchuby justinchuby left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for contributing! Could you fix lint?

@justinchuby
Copy link
Copy Markdown
Owner

Looks like you are planning to use docformatter and bandit in executorch. Just curious, was there a reason not to use ruff for both? I think ruff support both usages (e.g. astral-sh/ruff#1646)

@justinchuby
Copy link
Copy Markdown
Owner

justinchuby commented Jan 16, 2026

Apparently ruff was not enabled (https://github.com/pytorch/executorch/blob/main/pyproject.toml). You can follow https://github.com/pytorch/pytorch/blob/f15f59147ef0e802e819ac3a83314424cc9989e1/pyproject.toml#L134 for an example config. Also, ruff is fully supported by lintrunner-adapters.

@perheld
Copy link
Copy Markdown
Contributor Author

perheld commented Jan 16, 2026

LGTM, thanks for contributing! Could you fix lint?

Will do.

Looks like you are planning to use docformatter and bandit in executorch. Just curious, was there a reason not to use ruff for both? I think ruff support both usages (e.g. astral-sh/ruff#1646)

The project is already setup and has a mature CI with lintrunner, so just adding support for tools we have good experience with in lintrunner-adapters makes sense from my POV. And bandit is such a tool.

@perheld
Copy link
Copy Markdown
Contributor Author

perheld commented Jan 16, 2026

Apparently ruff was not enabled (https://github.com/pytorch/executorch/blob/main/pyproject.toml). You can follow https://github.com/pytorch/pytorch/blob/f15f59147ef0e802e819ac3a83314424cc9989e1/pyproject.toml#L134 for an example config. Also, ruff is fully supported by lintrunner-adapters.

That is nice to know. I will bring this with me and see what we do in the future.

@perheld
Copy link
Copy Markdown
Contributor Author

perheld commented Jan 19, 2026

@justinchuby can you start the lintrunners again?

Comment thread lintrunner_adapters/adapters/bandit_linter.py Fixed
Comment thread lintrunner_adapters/adapters/bandit_linter.py Fixed
@perheld
Copy link
Copy Markdown
Contributor Author

perheld commented Jan 19, 2026

Running lintrunner -a again locally and will push again. My bad.

@perheld
Copy link
Copy Markdown
Contributor Author

perheld commented Jan 20, 2026

@justinchuby I had to wait for internal review before pushing externally, now that is done and I have force pushed to my branch with the lints fixed. Please start the workflows when you have the opportunity.

@perheld
Copy link
Copy Markdown
Contributor Author

perheld commented Jan 21, 2026

@justinchuby please merge if you are happy with the changes.

@justinchuby justinchuby merged commit 6e845de into justinchuby:main Jan 21, 2026
25 checks passed
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.

4 participants