Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/sentry/grouping/parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,18 @@ def is_valid_ip(maybe_ip_str: str) -> bool:
(::[fF]{4}:)? # Optional prefix mapping the IPv4 address which follows to IPv6 format
(
\b
(\d{1,3}\.){3} # Three sets of 1-3 digits, each followed by a literal dot
\d{1,3} # Final set of 1-3 digits
# Three numbers from 0-255, each followed by a literal dot, no leading zeros allowed
(
(
\d | # 0-9
[1-9]\d | # 10-99
1\d{2} | # 100-199
2[0-4]\d | # 200-249
25[0-5] # 250-255
)\.
){3}
# Final number from 0-255 (same pattern alternatives as above)
(\d | [1-9]\d | 1\d{2} | 2[0-4]\d | 25[0-5])
(/\d{1,2})? # Optional CIDR suffix
\b
)
Expand Down
4 changes: 2 additions & 2 deletions tests/sentry/grouping/test_parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ def test_replacement_callback_false_positive_triggers_individual_regex_fallback(
("ip - single leading colon", "Script error. :0:0", False),
("ip - single trailing colon", "12::31:", False),
("ip - too few segments", "12:31:99", True),
("ip - v4 leading zeros", "11.21.12.001", True),
("ip - v4 segment > 255", "12.31.12.908", True),
("ip - v4 leading zeros", "11.21.12.001", False),
("ip - v4 segment > 255", "12.31.12.908", False),
("ip - v4 too many segments", "11.21.12.31.12", True),
("date - colon btwn date and time", "21/Nov/2012:12:31:12", True),
]
Expand Down
Loading