Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mouday committed May 30, 2023
1 parent 1a57f5d commit 8b08b35
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 3 deletions.
99 changes: 99 additions & 0 deletions docs/domain-expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
www.jd.com
www.qq.com
www.360.com
www.vip.com
www.baidu.com
www.toutiao.com
www.taobao.com
www.xiaomi.com
www.apple.com
www.bilibili.tv
www.baidu.com
www.python.org
www.pconline.com.cn
www.xiaomi.cn
www.csdn.net
www.gov.xyz
expired.badssl.com
hsts.badssl.com
self-signed.badssl.com
sha256.badssl.com
tls-v1-2.badssl.com:1012
untrusted-root.badssl.com
wrong.host.badssl.com
www.mysite.com
expired.badssl.com
wrong.host.badssl.com
self-signed.badssl.com
untrusted-root.badssl.com
revoked.badssl.com
pinning-test.badssl.com
no-common-name.badssl.com
no-subject.badssl.com
incomplete-chain.badssl.com
sha256.badssl.com
sha384.badssl.com
sha512.badssl.com
1000-sans.badssl.com
10000-sans.badssl.com
ecc256.badssl.com
ecc384.badssl.com
rsa2048.badssl.com
rsa4096.badssl.com
rsa8192.badssl.com
extended-validation.badssl.com
badssl.com
client.badssl.com
client-cert-missing.badssl.com
mixed-script.badssl.com
very.badssl.com
mixed.badssl.com
mixed-favicon.badssl.com
mixed-form.badssl.com
http.badssl.com
http-textarea.badssl.com
http-password.badssl.com
http-login.badssl.com
http-dynamic-login.badssl.com
http-credit-card.badssl.com
cbc.badssl.com
rc4-md5.badssl.com
rc4.badssl.com
3des.badssl.com
null.badssl.com
mozilla-old.badssl.com
mozilla-intermediate.badssl.com
mozilla-modern.badssl.com
dh480.badssl.com
dh512.badssl.com
dh1024.badssl.com
dh2048.badssl.com
dh-small-subgroup.badssl.com
dh-composite.badssl.com
static-rsa.badssl.com
tls-v1-0.badssl.com:1010
tls-v1-1.badssl.com:1011
tls-v1-2.badssl.com:1012
no-sct.badssl.com
hsts.badssl.com
upgrade.badssl.com
preloaded-hsts.badssl.com
subdomain.preloaded-hsts.badssl.com
https-everywhere.badssl.com
spoofed-favicon.badssl.com
lock-title.badssl.com
long-extended-subdomain-name-containing-many-letters-and-dashes.badssl.com
longextendedsubdomainnamewithoutdashesinordertotestwordwrapping.badssl.com
superfish.badssl.com
edellroot.badssl.com
dsdtestprovider.badssl.com
preact-cli.badssl.com
webpack-dev-server.badssl.com
captive-portal.badssl.com
mitm-software.badssl.com
sha1-2016.badssl.com
sha1-2017.badssl.com
sha1-intermediate.badssl.com
invalid-expected-sct.badssl.com
testsafebrowsing.appspot.com
www.米梵家居.com
3 changes: 2 additions & 1 deletion docs/domain.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sha256.badssl.com
tls-v1-2.badssl.com:1012
untrusted-root.badssl.com
wrong.host.badssl.com
www.mysite.com
http://www.mysite.com
https://expired.badssl.com/
https://wrong.host.badssl.com/
https://self-signed.badssl.com/
Expand Down Expand Up @@ -96,3 +96,4 @@ https://sha1-2017.badssl.com/
https://sha1-intermediate.badssl.com/
https://invalid-expected-sct.badssl.com/
https://testsafebrowsing.appspot.com/
www.米梵家居.com
7 changes: 5 additions & 2 deletions domain_admin/utils/domain_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ def parse_domain(domain):
:param domain:
:return:
"""
ret = re.match('.*?/?/?([a-zA-Z\\.0-9_:-]+)/?.*?', domain)
# print(domain)

ret = re.match('((http(s)?:)?//)?(?P<domain>[\\w\\._:-]+)/?.*?', domain)
if ret:
return ret.groups()[0]
# print(ret.groups())
return ret.groupdict().get("domain")
else:
return None

Expand Down
18 changes: 18 additions & 0 deletions tests/utils/test_domain_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,21 @@ def test_extract_domain():
lst = domain_util.parse_domain_from_file(filename)
for line in lst:
print(domain_util.extract_domain(line))


def test_parse_domain_from_txt_file():
"""
测试域名解析函数
:return:
"""
domain_filename = '../../docs/domain.txt'
domain_expect_filename = '../../docs/domain-expect.txt'

expect_domains = None
with open(domain_expect_filename, 'r') as f:
expect_domains = [row.strip() for row in f.readlines()]

if os.path.exists(domain_filename):
lst = domain_util.parse_domain_from_txt_file(domain_filename)
for index, row in enumerate(lst):
assert row['domain'] == expect_domains[index]

0 comments on commit 8b08b35

Please sign in to comment.