Skip to content

Commit

Permalink
Merge pull request #496 from blacklanternsecurity/async-optimize
Browse files Browse the repository at this point in the history
Explicitly cleanup http client
  • Loading branch information
liquidsec authored Sep 30, 2024
2 parents e979645 + f727437 commit 9c4b115
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions baddns/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def infomsg(self, msg):
else:
log.debug(msg)

async def cleanup(self):
pass


def get_all_modules(*args, **kwargs):
return [m for m in BadDNS_base.__subclasses__()]
1 change: 1 addition & 0 deletions baddns/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ async def execute_module(ModuleClass, target, custom_nameservers, signatures, si
for finding in findings:
print(finding.to_dict())

await module_instance.cleanup()
return findings


Expand Down
5 changes: 5 additions & 0 deletions baddns/lib/httpmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ async def dispatchHttp(self):
else:
setattr(self, f"{protocol}_denyredirects_results", result)
idx += 1

async def close(self):
"""Clean up the http_client when done."""
await self.http_client.aclose()
log.debug("HTTP client closed successfully.")
5 changes: 5 additions & 0 deletions baddns/modules/cname.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,8 @@ def analyze(self):
)

return findings

async def cleanup(self):
if self.target_httpmanager:
await self.target_httpmanager.close()
log.debug("HTTP Manager cleaned up successfully.")
5 changes: 5 additions & 0 deletions baddns/modules/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,8 @@ def analyze(self):
if self.cname_findings_direct:
findings.extend(self._convert_findings(self.cname_findings_direct))
return findings

async def cleanup(self):
if self.target_httpmanager:
await self.target_httpmanager.close()
log.debug("HTTP Manager cleaned up successfully.")
5 changes: 5 additions & 0 deletions baddns/modules/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ def analyze(self):
if self.cname_findings:
findings.extend(self._convert_findings(self.cname_findings))
return findings

async def cleanup(self):
if self.target_httpmanager:
await self.target_httpmanager.close()
log.debug("HTTP Manager cleaned up successfully.")

0 comments on commit 9c4b115

Please sign in to comment.