PyCQA / PyCQA/bandit

Find catastrophic `re` expressions

Open
#589 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
8.3k
Forks
836
Avg merge
5d 3h
Merged PRs (30d)
1

Description

Is your feature request related to a problem? Please describe.
Some re expressions might cause DoS. See: https://www.regular-expressions.info/catastrophic.html

Describe the solution you'd like
I would like to have a linting rule for this. If bandit sees a regex that might cause DoS, it should raise an error.

Describe alternatives you've considered
I have considered using dlint, it has this feature: https://github.com/dlint-py/dlint/blob/master/dlint/redos/detect.py

But, it has a lot of duplicating rules from bandit. And I don't want to mix them.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with dlint/redos/detect.py, the existing implementation named in the issue, and inspect Bandit’s rule structure. Determine how catastrophic regex detection should fit as a Bandit linting rule without duplicating unrelated dlint rules. Done means the rule identifies regex expressions that might cause DoS and raises an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
security, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.