-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace bandit with ruff #6961
Replace bandit with ruff #6961
Conversation
I'm very much in favor of (a) this specific change and (b) in general standardizing these tools, to avoid surprises like freedomofpress/securedrop-client#1668. But you knew that already. :-) |
GitPython is a development-only dependency of Bandit, which will be obsoleted by #6961. In the meantime: - CVE-2023-40590 (Safety 60789) affects Windows, which we don't support. - CVE-2023-41040 (Safety 60841) is not exploitable for our use of GitPython via Bandit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending the il8n stuff mentioned in the PR - yay ruff, thanks @legoktm :)
ruff has reimplemented the bandit rules[1], so we can use that as a better-integrated tool with the rest of our stack. We enable all the bandit rules and selectively disable some across the codebase and some in just tests where they don't make sense (e.g. flagging use of `assert` or using insecure crypto). For bonus points we can get rid of the GitPython dependency, which has a history of (non-exploitable in our context) security issues. [1] Per astral-sh/ruff#1646 they've implemented nearly all of them, and the remaining ones aren't that important IMO.
This should be ready to go now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! (plays taps for bandit)
- CI checks out
- make check-ruff passes locally
- with some
#noqa
s dropped, the check alerts as expected.
With heavy inspiration from freedomofpress/securedrop#6961
Status
Ready for review,
depends on #6954 (I did not fix the bandit issues in i18n_tool.py)Description of Changes
ruff has reimplemented the bandit rules[1], so we can use that as a better-integrated tool with the rest of our stack. We enable all the bandit rules and selectively disable some across the codebase and some in just tests where they don't make sense (e.g. flagging use of
assert
or using insecure crypto).For bonus points we can get rid of the GitPython dependency, which has a history of (non-exploitable in our context) security issues.
[1] Per astral-sh/ruff#1646 they've implemented nearly all of them, and the remaining ones aren't that important IMO.
Testing
How should the reviewer test this PR?
make check-ruff
passes locallyDeployment
Any special considerations for deployment? No
Checklist
make lint
) and tests (make test
) pass in the development container