File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
<!-- Include any especially major or disruptive changes here -->
8
8
9
+ This release is a milestone: it fixes Black's first CVE security vulnerability. If you
10
+ run Black on untrusted input, or if you habitually put thousands of leading tab
11
+ characters in your docstrings, you are strongly encouraged to upgrade immediately to fix
12
+ [ CVE-2024 -21503] ( https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-21503 ) .
13
+
14
+ This release also fixes a bug in Black's AST safety check that allowed Black to make
15
+ incorrect changes to certain f-strings that are valid in Python 3.12 and higher.
16
+
9
17
### Stable style
10
18
11
19
<!-- Changes that affect Black's stable style -->
36
44
37
45
### Performance
38
46
39
- <!-- Changes that improve Black's performance. -->
47
+ - Fix catastrophic performance on docstrings that contain large numbers of leading tab
48
+ characters. This fixes
49
+ [ CVE-2024 -21503] ( https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-21503 ) .
50
+ (#4278 )
40
51
41
52
### Output
42
53
Original file line number Diff line number Diff line change 48
48
from black .output import color_diff , diff
49
49
from black .parsing import ASTSafetyError
50
50
from black .report import Report
51
+ from black .strings import lines_with_leading_tabs_expanded
51
52
52
53
# Import other test classes
53
54
from tests .util import (
@@ -2041,6 +2042,17 @@ def test_line_ranges_in_pyproject_toml(self) -> None:
2041
2042
b"Cannot use line-ranges in the pyproject.toml file." in result .stderr_bytes
2042
2043
)
2043
2044
2045
+ def test_lines_with_leading_tabs_expanded (self ) -> None :
2046
+ # See CVE-2024-21503. Mostly test that this completes in a reasonable
2047
+ # time.
2048
+ payload = "\t " * 10_000
2049
+ assert lines_with_leading_tabs_expanded (payload ) == [payload ]
2050
+
2051
+ tab = " " * 8
2052
+ assert lines_with_leading_tabs_expanded ("\t x" ) == [f"{ tab } x" ]
2053
+ assert lines_with_leading_tabs_expanded ("\t \t x" ) == [f"{ tab } { tab } x" ]
2054
+ assert lines_with_leading_tabs_expanded ("\t x\n y" ) == [f"{ tab } x" , " y" ]
2055
+
2044
2056
2045
2057
class TestCaching :
2046
2058
def test_get_cache_dir (
You can’t perform that action at this time.
0 commit comments