Skip to content

Commit

Permalink
Merge pull request #9 from markgacoka/v1.1.9
Browse files Browse the repository at this point in the history
Refactoring test scripts
  • Loading branch information
markgacoka committed Mar 6, 2022
2 parents 6d545de + f40ccaa commit 979ab44
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion r3c0n/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Version of the r3c0n package
__version__ = "1.0.7"
__version__ = "1.1.8"
15 changes: 6 additions & 9 deletions r3c0n/engines/all.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from anubis import Anubis
from hacker_target import HackerTarget
from open_threat import OpenThreat
from project_sonar import ProjectSonar
from threatcrowd import ThreatCrowd
from r3c0n.engines.anubis import Anubis
from r3c0n.engines.hacker_target import HackerTarget
from r3c0n.engines.open_threat import OpenThreat
from r3c0n.engines.project_sonar import ProjectSonar
from r3c0n.engines.threatcrowd import ThreatCrowd

class All:
def __init__(self, domain):
Expand All @@ -16,7 +16,4 @@ def subdomains(self):
subdomain_result = set.union(subdomain_result, set(OpenThreat(self.domain).subdomains()))
subdomain_result = set.union(subdomain_result, set(ProjectSonar(self.domain).subdomains()))
subdomain_result = set.union(subdomain_result, set(ThreatCrowd(self.domain).subdomains()))
return list(subdomain_result)

all = All('coda.io').subdomains()
print(all)
return list(subdomain_result)
7 changes: 5 additions & 2 deletions r3c0n/engines/open_threat.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ def openthreat_script(self, domain):

def subdomains(self):
subdomain_result = self.openthreat_script(self.domain)
subdomain_result = Clean(subdomain_result)
return subdomain_result
if isinstance(subdomain_result, list) and len(subdomain_result) > 0:
subdomain_result = Clean(subdomain_result)
return subdomain_result
else:
return []
2 changes: 1 addition & 1 deletion r3c0nutils/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def cleanup(subdomain_lst: List[str]) -> List[str]:
subdomain_yarl = yarl.URL(subdomain_full)
if subdomain_yarl.path_qs != '' or subdomain_yarl.path_qs != '/':
clean_lst[idx] = str(subdomain_yarl.origin())[7:].strip()
return list(filter(None, set(clean_lst)))
return sorted(list(filter(None, set(clean_lst))))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# The text of the README file
README = (PATH / "README.md").read_text()

VERSION="1.1.6"
VERSION="1.1.9"
DESCRIPTION="A tool for performing reconnaissance on web targets in Python."
LONG_DESCRIPTION="A tool for finding subdomain and directory information for various web targets."

Expand Down
9 changes: 5 additions & 4 deletions tests/test_cleanup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from r3c0n import Clean as clean
from r3c0nutils.formatter import Clean as clean

class TestCleanup(unittest.TestCase):
"""Test the formatting of different subdomain outputs from engines.
Expand All @@ -16,10 +16,11 @@ def test_subdomain_cleanup(self):
Test the protocol prefix in the output
"""
example_list = ['https://example.com', 'http://example.com']
result_1 = clean.cleanup(example_list[0])
result_2 = clean.cleanup(example_list[1])
example_list_2 = ['https://example.com', 'https://example2.com', 'https://example.com', 'http://example3.com']
result_1 = clean.cleanup(example_list)
result_2 = clean.cleanup(example_list_2)
self.assertEqual(result_1, ['example.com'])
self.assertEqual(result_2, ['example.com'])
self.assertEqual(result_2, ['example.com', 'example2.com', 'example3.com'])

if __name__ == '__main__':
unittest.main()

0 comments on commit 979ab44

Please sign in to comment.