Skip to content

Commit cc1cf03

Browse files
author
github-actions
committed
fix conflicts
2 parents 9973d01 + 920b329 commit cc1cf03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2376
-1851
lines changed

bbot/core/helpers/async_helpers.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import time
12
import uuid
23
import random
34
import asyncio
45
import logging
56
import functools
6-
from datetime import datetime
7-
from .misc import human_timedelta
7+
from contextlib import suppress
88
from cachetools import keys, LRUCache
99
from contextlib import asynccontextmanager
1010

@@ -63,26 +63,27 @@ def lock(self):
6363
self._lock = asyncio.Lock()
6464
return self._lock
6565

66-
def count(self, task_name, n=1, _log=True):
66+
def count(self, task_name, n=1, asyncio_task=None, _log=True):
6767
if callable(task_name):
6868
task_name = f"{task_name.__qualname__}()"
69-
return self.Task(self, task_name, n=n, _log=_log)
69+
return self.Task(self, task_name, n=n, _log=_log, asyncio_task=asyncio_task)
7070

7171
class Task:
72-
def __init__(self, manager, task_name, n=1, _log=True):
72+
def __init__(self, manager, task_name, n=1, _log=True, asyncio_task=None):
7373
self.manager = manager
7474
self.task_name = task_name
7575
self.task_id = None
7676
self.start_time = None
7777
self.log = _log
7878
self.n = n
79+
self._asyncio_task = asyncio_task
7980

8081
async def __aenter__(self):
8182
self.task_id = uuid.uuid4()
8283
# if self.log:
8384
# log.trace(f"Starting task {self.task_name} ({self.task_id})")
8485
async with self.manager.lock:
85-
self.start_time = datetime.now()
86+
self.start_time = time.time()
8687
self.manager.tasks[self.task_id] = self
8788
return self
8889

@@ -92,9 +93,29 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
9293
# if self.log:
9394
# log.trace(f"Finished task {self.task_name} ({self.task_id})")
9495

96+
@property
97+
def asyncio_task(self):
98+
if self._asyncio_task is None:
99+
raise AttributeError("No asyncio task associated with this task")
100+
return self._asyncio_task
101+
102+
@property
103+
def function_name(self):
104+
with suppress(AttributeError):
105+
return self.asyncio_task.get_coro().__name__
106+
return ""
107+
108+
async def cancel(self):
109+
self.asyncio_task.cancel()
110+
with suppress(asyncio.CancelledError):
111+
await self.asyncio_task
112+
113+
@property
114+
def running_for(self):
115+
return time.time() - self.start_time
116+
95117
def __str__(self):
96-
running_for = human_timedelta(datetime.now() - self.start_time)
97-
return f"{self.task_name} running for {running_for}"
118+
return f"{self.task_name} running for {self.running_for:.1f}s"
98119

99120

100121
def get_event_loop():

bbot/core/helpers/depsinstaller/installer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ async def install_module(self, module):
196196
deps_common = preloaded["deps"]["common"]
197197
if deps_common:
198198
for dep_common in deps_common:
199-
if self.setup_status.get(dep_common, False) is True:
199+
if self.setup_status.get(dep_common, False) is True and self.deps_behavior != "force_install":
200200
log.debug(
201201
f'Skipping installation of dependency "{dep_common}" for module "{module}" since it is already installed'
202202
)

bbot/core/helpers/misc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ def make_netloc(host, port=None):
13091309
return f"{host}:{port}"
13101310

13111311

1312-
def which(*executables):
1312+
def which(*executables, path=None):
13131313
"""Finds the full path of the first available executable from a list of executables.
13141314
13151315
Args:
@@ -1325,7 +1325,7 @@ def which(*executables):
13251325
import shutil
13261326

13271327
for e in executables:
1328-
location = shutil.which(e)
1328+
location = shutil.which(e, path=path)
13291329
if location:
13301330
return location
13311331

bbot/core/helpers/names_generator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"delicious",
5151
"demented",
5252
"demonic",
53+
"demonstrative",
5354
"depraved",
5455
"depressed",
5556
"deranged",
@@ -201,8 +202,10 @@
201202
"reckless",
202203
"reductive",
203204
"ripped",
205+
"ruthless",
204206
"sadistic",
205207
"satanic",
208+
"saucy",
206209
"savvy",
207210
"scheming",
208211
"schizophrenic",

bbot/core/shared_deps.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,24 @@
108108
"when": "ansible_facts['os_family'] == 'Debian'",
109109
"ignore_errors": True,
110110
},
111+
{
112+
"name": "Get latest Chromium version (Darwin x86_64)",
113+
"uri": {
114+
"url": "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Mac%2FLAST_CHANGE?alt=media",
115+
"return_content": True,
116+
},
117+
"register": "chromium_version_darwin_x86_64",
118+
"when": "ansible_facts['os_family'] == 'Darwin' and ansible_facts['architecture'] == 'x86_64'",
119+
},
120+
{
121+
"name": "Get latest Chromium version (Darwin arm64)",
122+
"uri": {
123+
"url": "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Mac_Arm%2FLAST_CHANGE?alt=media",
124+
"return_content": True,
125+
},
126+
"register": "chromium_version_darwin_arm64",
127+
"when": "ansible_facts['os_family'] == 'Darwin' and ansible_facts['architecture'] == 'arm64'",
128+
},
111129
{
112130
"name": "Download Chromium (Debian)",
113131
"unarchive": {
@@ -119,6 +137,26 @@
119137
"when": "ansible_facts['os_family'] == 'Debian'",
120138
"ignore_errors": True,
121139
},
140+
{
141+
"name": "Download Chromium (Darwin x86_64)",
142+
"unarchive": {
143+
"src": "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Mac%2F{{ chromium_version_darwin_x86_64.content }}%2Fchrome-mac.zip?alt=media",
144+
"remote_src": True,
145+
"dest": "#{BBOT_TOOLS}",
146+
"creates": "#{BBOT_TOOLS}/chrome-mac",
147+
},
148+
"when": "ansible_facts['os_family'] == 'Darwin' and ansible_facts['architecture'] == 'x86_64'",
149+
},
150+
{
151+
"name": "Download Chromium (Darwin arm64)",
152+
"unarchive": {
153+
"src": "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Mac_Arm%2F{{ chromium_version_darwin_arm64.content }}%2Fchrome-mac.zip?alt=media",
154+
"remote_src": True,
155+
"dest": "#{BBOT_TOOLS}",
156+
"creates": "#{BBOT_TOOLS}/chrome-mac",
157+
},
158+
"when": "ansible_facts['os_family'] == 'Darwin' and ansible_facts['architecture'] == 'arm64'",
159+
},
122160
# Because Ubuntu is a special snowflake, we have to bend over backwards to fix the chrome sandbox
123161
# see https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
124162
{

bbot/defaults.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ deps:
142142
# Load BBOT modules from these custom paths
143143
module_dirs: []
144144

145+
# maximum runtime in seconds for each module's handle_event() is 60 minutes
146+
# when the timeout is reached, the offending handle_event() will be cancelled and the module will move on to the next event
147+
module_handle_event_timeout: 3600
148+
# handle_batch() default timeout is 2 hours
149+
module_handle_batch_timeout: 7200
150+
145151
# Infer certain events from others, e.g. IPs from IP ranges, DNS_NAMEs from URLs, etc.
146152
speculate: True
147153
# Passively search event data for URLs, hostnames, emails, etc.

bbot/modules/apkpure.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ class apkpure(BaseModule):
1313
"author": "@domwhewell-sage",
1414
}
1515
options = {"output_folder": ""}
16-
options_desc = {"output_folder": "Folder to download apk's to"}
16+
options_desc = {
17+
"output_folder": "Folder to download APKs to. If not specified, downloaded APKs will be deleted when the scan completes, to minimize disk usage."
18+
}
1719

1820
async def setup(self):
19-
output_folder = self.config.get("output_folder")
21+
output_folder = self.config.get("output_folder", "")
2022
if output_folder:
2123
self.output_dir = Path(output_folder) / "apk_files"
2224
else:
23-
self.output_dir = self.scan.home / "apk_files"
25+
self.output_dir = self.helpers.temp_dir / "apk_files"
2426
self.helpers.mkdir(self.output_dir)
2527
return await super().setup()
2628

0 commit comments

Comments
 (0)