Skip to content

Commit 54e65ce

Browse files
committed
Python: Add consistency tests
for all the projects that went out of disk as a result of ReDoS
1 parent c08f94e commit 54e65ce

File tree

1 file changed

+53
-0
lines changed
  • python/ql/test/library-tests/regexparser

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,55 @@
11
import re
2+
3+
# minimal example constructed by @erik-krogh
24
baz = re.compile(r'\+0')
5+
6+
# examples from LGTM.com
7+
re.compile(r'.*\+0x(?P<offset>[0-9a-f]+)$')
8+
re.compile(r"^\<.*\+0x.*\>$")
9+
re.search(r'^(https?://.*/).+\-0+\.ts$', res, re.MULTILINE)
10+
re.compile('\s+\+0x[0-9a-f]+\s*(.*)')
11+
re.compile("(.*)\+0x([a-f0-9]*)")
12+
LOG_PATTERN = {
13+
'vumi': re.compile(
14+
r'(?P<date>[\d\-\:\s]+)\+0000 .* '
15+
r'Inbound: <Message payload="(?P<message>.*)">'),
16+
'smpp_inbound': re.compile(
17+
r'(?P<date>[\d\-\:\s]+)\+0000 .* '
18+
r'PUBLISHING INBOUND: (?P<message>.*)'),
19+
'smpp_outbound': re.compile(
20+
r'(?P<date>[\d\-\:\s]+)\+0000 .* '
21+
r'Consumed outgoing message <Message payload="(?P<message>.*)">'),
22+
'dispatcher_inbound_message': re.compile(
23+
r'(?P<date>[\d\-\:\s]+)\+0000 Processed inbound message for [a-zA-Z0-9_]+: (?P<message>.*)'),
24+
'dispatcher_outbound_message': re.compile(
25+
r'(?P<date>[\d\-\:\s]+)\+0000 Processed outbound message for [a-zA-Z0-9_]+: (?P<message>.*)'),
26+
'dispatcher_event': re.compile(
27+
r'(?P<date>[\d\-\:\s]+)\+0000 Processed event message for [a-zA-Z0-9_]+: (?P<message>.*)'),
28+
}
29+
re.compile(
30+
'(.*)(?P<frame>\#[0-9]+ 0x[0-9a-f]{8,16}) '
31+
'(?P<lib>[^+]+)\+0x(?P<address>[0-9a-f]{8,16})'
32+
'(?P<symbol_present>)(?P<symbol_name>)')
33+
RE_LINE = re.compile(
34+
r'(?P<vhost>[^ ]+) '
35+
r'(?P<ipaddr>[^ ]+) '
36+
r'(?P<ident>[^ ]+) '
37+
r'(?P<userid>[^ ]+) '
38+
r'\[(?P<datetime>[^\]]+) \+0000\] '
39+
r'"(?P<verb>[^ ]+) /(?P<tool>[^ /?]+)(?P<path>[^ ]*) HTTP/[^"]+" '
40+
r'(?P<status>\d+) '
41+
r'(?P<bytes>\d+) '
42+
r'"(?P<referer>[^"]*)" '
43+
r'"(?P<ua>[^"]*)"'
44+
r'(?P<extra>.*)'
45+
)
46+
re.compile('(?P<frame>\#[0-9]+ 0x[0-9a-f]{8,8}) '
47+
'(?P<lib>[^+]+)\+0x(?P<addr>[0-9a-f]{8,8})')
48+
re.compile(
49+
'(.*)(?P<frame>\#[0-9]+ 0x[0-9a-f]{8,16}) '
50+
'(?P<lib>[^+]+)\+0x(?P<address>[0-9a-f]{8,16})'
51+
'(?P<symbol_present>)(?P<symbol_name>)')
52+
re.match(r'^@@ -1.* \+0,0 @@', self.hdr)
53+
re.compile('(.*)(?P<frame>\#[0-9]+ 0x[0-9a-f]{8,16}) '
54+
'(?P<lib>[^+]+)\+0x(?P<address>[0-9a-f]{8,16})'
55+
'(?P<symbol_present>)(?P<symbol_name>)')

0 commit comments

Comments
 (0)