Skip to content

Commit

Permalink
Move HackerTarget URL to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
EONRaider committed Jan 25, 2023
1 parent 242131e commit adef087
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions reconlib/hackertarget/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class HackerTarget(Enum):
"""Enumeration of API endpoints made available by HackerTarget"""

URL = urlparse("https://api.hackertarget.com")
HOSTSEARCH = "hostsearch"
DNSLOOKUP = "dnslookup"
REVERSEDNS = "reversedns"
Expand All @@ -22,12 +23,10 @@ def __init__(
target: str,
*,
user_agent: str = None,
hackertarget_url: str = "https://api.hackertarget.com",
encoding: str = "utf_8",
):
super().__init__(target)
self.user_agent = user_agent
self.hackertarget_url = urlparse(hackertarget_url)
self.encoding = encoding
self.found_ip_addrs = defaultdict(set)
self.found_domains = defaultdict(set)
Expand All @@ -46,8 +45,8 @@ def get_query_url(self, endpoint: HackerTarget, params: dict = None) -> str:
"""
return urlunparse(
(
self.hackertarget_url.scheme,
self.hackertarget_url.netloc,
HackerTarget.URL.value.scheme,
HackerTarget.URL.value.netloc,
f"{endpoint.value}/",
"",
urlencode(params) if params else "",
Expand Down

0 comments on commit adef087

Please sign in to comment.