Skip to content

Commit 864ff70

Browse files
committed
fix: bound regex quantifiers in _PY_IMPORT_RE to prevent ReDoS
1 parent 086f3e7 commit 864ff70

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • src/treemapper/diffctx/edges/semantic

src/treemapper/diffctx/edges/semantic/python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
_SYMBOL_REF_WEIGHT = 0.95
1515
_TYPE_REF_WEIGHT = 0.60
1616

17-
_PY_IMPORT_RE = re.compile(r"(?:from\s+(\.{0,3}[\w.]{0,200})\s+import|import\s+([\w.]{1,200}))")
17+
_PY_IMPORT_RE = re.compile(r"(?:from\s{1,20}(\.{0,3}[\w.]{0,200})\s{1,20}import|import\s{1,20}([\w.]{1,200}))")
1818

1919

2020
def _is_python_file(path: Path) -> bool:

0 commit comments

Comments
 (0)