Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/added defused xml #2027

Open
wants to merge 4 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bbot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ async def _main():
return
# ensure arguments (-c config options etc.) are valid
options = preset.args.parsed
# ensure if verbose (-v) is used with -t else throw help
if options.verbose and not options.targets:
print("Error: Missing target. Use bbot -t [TARGET] -v [OTHER OPTIONS]")
sys.exit(1)

# ensure if debug (-d) flag is used without -t flag
if options.debug and not options.targets:
print("Error: Missing target. Use bbot -t [TARGET] -d [OTHER OPTIONS]")
sys.exit(1)

# print help if no arguments
if len(sys.argv) == 1:
Expand Down
5 changes: 4 additions & 1 deletion bbot/core/helpers/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ def cache_get(self, key, text=True, cache_hrs=24 * 7):
else:
open_kwargs["mode"] = "rb"
log.debug(f'Using cached content for "{key}"')
return open(filename, **open_kwargs).read()
# Using a block to ensure the file is closed automatically
with open(filename, **open_kwargs) as f:
return f.read()
else:
log.debug(f'Cached content for "{key}" is older than {cache_hrs:,} hours')
return None


def cache_put(self, key, content):
Expand Down
2 changes: 1 addition & 1 deletion bbot/core/helpers/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ def extract_params_xml(xml_data, compare_mode="getparam"):
>>> extract_params_xml('<root><child1><child2>value</child2></child1></root>')
{('root', None), ('child1', None), ('child2', 'value')}
"""
import xml.etree.ElementTree as ET
import defusedxml.ElementTree as ET

try:
root = ET.fromstring(xml_data)
Expand Down
2 changes: 1 addition & 1 deletion bbot/modules/bucket_file_enum.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from bbot.modules.base import BaseModule
import xml.etree.ElementTree as ET
import defusedxml.ElementTree as ET


class bucket_file_enum(BaseModule):
Expand Down
Loading
Loading