Skip to content
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

Merged
merged 1 commit into from
Oct 12, 2023
Merged

Replace bandit with ruff #6961

merged 1 commit into from
Oct 12, 2023

Conversation

legoktm
Copy link
Member

@legoktm legoktm commented Sep 29, 2023

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?

  • CI passes
  • make check-ruff passes locally

Deployment

Any special considerations for deployment? No

Checklist

  • Linting (make lint) and tests (make test) pass in the development container

@legoktm legoktm requested a review from a team as a code owner September 29, 2023 22:52
@rocodes rocodes self-assigned this Oct 2, 2023
@cfm
Copy link
Member

cfm commented Oct 2, 2023

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. :-)

cfm added a commit that referenced this pull request Oct 2, 2023
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.
rocodes
rocodes previously approved these changes Oct 3, 2023
Copy link
Contributor

@rocodes rocodes left a 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.
@legoktm
Copy link
Member Author

legoktm commented Oct 12, 2023

This should be ready to go now!

Copy link
Contributor

@zenmonkeykstop zenmonkeykstop left a 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 #noqas dropped, the check alerts as expected.

@zenmonkeykstop zenmonkeykstop merged commit 3add350 into develop Oct 12, 2023
@zenmonkeykstop zenmonkeykstop deleted the ruff-bandit branch October 12, 2023 17:35
eloquence added a commit to freedomofpress/securedrop-builder that referenced this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants