From 238fd7daaaed94588794bfef820dda6d5577be5f Mon Sep 17 00:00:00 2001 From: filippolauria Date: Mon, 7 Mar 2022 12:13:57 +0100 Subject: [PATCH 1/2] Improved Zone Transfer and PTR tests --- tests/test_dnshelper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_dnshelper.py b/tests/test_dnshelper.py index 2de48742..46c42f39 100644 --- a/tests/test_dnshelper.py +++ b/tests/test_dnshelper.py @@ -4,7 +4,7 @@ # Unit test for DNSRecon's dnshelper library # Author: Filippo Lauria (@filippolauria) # -# Copyright (C) 2021 Carlos Perez +# Copyright (C) 2022 Carlos Perez # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -75,11 +75,11 @@ def test_get_srv(self): assert record[0] == 'SRV' def test_zone_transfer(self): - helper = DnsHelper('zonetransfer.me') + helper = DnsHelper('megacorpone.com') records = helper.zone_transfer() - assert len(records) == 135 + assert len(records) == 30 def test_get_ptr(self): helper = DnsHelper('megacorpone.com') records = helper.get_ptr('51.79.37.18') - assert len(records) == 1 and 'megacorpone.com' in records[0][1] + assert len(records) == 1 and records[0][1].endswith('megacorpone.com') From 36609c84592c0503fc3b1643d9d57c5b16e89da1 Mon Sep 17 00:00:00 2001 From: filippolauria Date: Mon, 7 Mar 2022 12:35:31 +0100 Subject: [PATCH 2/2] Addressed CodeQL incomplete URL substring sanitization complain --- tests/test_dnshelper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_dnshelper.py b/tests/test_dnshelper.py index 46c42f39..32bd56fd 100644 --- a/tests/test_dnshelper.py +++ b/tests/test_dnshelper.py @@ -21,6 +21,7 @@ from dnsrecon.lib.dnshelper import DnsHelper from netaddr import IPAddress +from re import match class Test_Lib_dnshelper(): @@ -82,4 +83,4 @@ def test_zone_transfer(self): def test_get_ptr(self): helper = DnsHelper('megacorpone.com') records = helper.get_ptr('51.79.37.18') - assert len(records) == 1 and records[0][1].endswith('megacorpone.com') + assert len(records) == 1 and match(r'^.+\.megacorpone\.com$', records[0][1])