Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c43912

Browse files
XIANJUN ZHUJustin Eyster
authored andcommitted
Support more db2 patterns (Yelp#293)
1 parent 985232f commit 8c43912

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

detect_secrets/plugins/db2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Db2Detector(RegexBasedDetector):
6161
# catch any character except newline and quotations, we exclude these
6262
# because the regex will erronously match them when present at the end of the password
6363
# db2 password requirements vary by version so we cast a broad net
64-
password = r'([^\r\n"\']+)'
64+
password = r'([^ ;,\r\n"\']+)'
6565
denylist = (
6666
re.compile(
6767
r'{begin}{opt_quote}{opt_db}{opt_dash_undrscr}{password_keyword}{opt_quote}{opt_space}'

tests/plugins/db2_test.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,44 @@ class TestGheDetector(object):
3939
'database=test;hostname=host.test.com;'
4040
'port=1;protocol=tcpip;uid=testid;pwd=secret', True,
4141
),
42+
(
43+
'secret',
44+
'database=test;hostname=host.test.com;'
45+
'port=1;protocol=tcpip;uid=testid;pwd=secret;', True,
46+
),
47+
(
48+
'secret',
49+
'database=test;hostname=host.test.com;'
50+
'port=1;protocol=tcpip;pwd=secret;uid=testid;', True,
51+
),
52+
(
53+
'secret',
54+
'database=test,hostname=host.test.com,'
55+
'port=1,protocol=tcpip,pwd=secret,uid=testid', True,
56+
),
57+
(
58+
'secret',
59+
'database=test,hostname=host.test.com,'
60+
'port=1,protocol=tcpip,uid=testid,pwd=secret', True,
61+
),
62+
(
63+
'secret',
64+
'user=testid,\npassword=secret,\ndatabase=test,\n'
65+
'hostname=host.test.com,\nport=1', True,
66+
),
67+
(
68+
'secret',
69+
'user=testid\npassword=secret\ndatabase=test\n'
70+
'hostname=host.test.com\nport=1', True,
71+
),
72+
(
73+
'secret',
74+
'jdbc:db2://hostname.test.com:1/test:user=testid;password=secret;', True,
75+
),
76+
(
77+
'secret',
78+
'jdbc:db2://hostname.test.com:1/test user=testid password=secret', True,
79+
),
4280
('$omespeci@!ch@r$', 'dbpwd=$omespeci@!ch@r$', True),
4381
('astring', 'db2_password = "astring"', True),
4482
('Iusedb2!', '"password": "Iusedb2!"', True),

0 commit comments

Comments
 (0)