From 03830568e8422609287af016284cec0a1923f88a Mon Sep 17 00:00:00 2001 From: Olivier Cervello Date: Thu, 4 Apr 2024 17:55:46 -0400 Subject: [PATCH] fix: redis docs, nmap issue, mongodb debug (#231) --- secator/cli.py | 3 ++- secator/hooks/mongodb.py | 11 +++++------ secator/tasks/nmap.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/secator/cli.py b/secator/cli.py index e19bc780..653fe771 100644 --- a/secator/cli.py +++ b/secator/cli.py @@ -393,8 +393,9 @@ def install_redis(): cmd=f'{sys.executable} -m pip install secator[redis]', title='redis addon', next_steps=[ - '[dim]\[optional][/] Run "docker run --name redis -p 5432:5432 -d redis" to run a local Redis instance.', + '[dim]\[optional][/] Run "docker run --name redis -p 6379:6379 -d redis" to run a local Redis instance.', 'Set the "CELERY_BROKER_URL=redis://" environment variable pointing to your Redis instance.', + 'Set the "CELERY_RESULT_BACKEND=redis://" environment variable pointing to your Redis instance.', 'Run "secator worker" to run a worker.', 'Run "secator x httpx testphp.vulnweb.com" to run a test task.' ] diff --git a/secator/hooks/mongodb.py b/secator/hooks/mongodb.py index d8e53cf6..cde4e67a 100644 --- a/secator/hooks/mongodb.py +++ b/secator/hooks/mongodb.py @@ -28,14 +28,16 @@ def update_runner(self): type = self.config.type collection = f'{type}s' update = self.toDict() + debug_obj = {'type': 'runner', 'name': self.name, 'status': self.status} chunk = update.get('chunk') _id = self.context.get(f'{type}_chunk_id') if chunk else self.context.get(f'{type}_id') + debug('update', sub='hooks.mongodb', id=_id, obj=update, obj_after=True, level=4) start_time = time.time() if _id: delta = start_time - self.last_updated if self.last_updated else MONGODB_UPDATE_FREQUENCY if self.last_updated and delta < MONGODB_UPDATE_FREQUENCY and self.status == 'RUNNING': debug(f'skipped ({delta:>.2f}s < {MONGODB_UPDATE_FREQUENCY}s)', - sub='hooks.mongodb', id=_id, obj={self.name: self.status}, obj_after=False, level=3) + sub='hooks.mongodb', id=_id, obj=debug_obj, obj_after=False, level=3) return db = client.main start_time = time.time() @@ -43,8 +45,7 @@ def update_runner(self): end_time = time.time() elapsed = end_time - start_time debug( - f'[dim gold4]updated in {elapsed:.4f}s[/]', - sub='hooks.mongodb', id=_id, obj={self.name: self.status}, obj_after=False, level=2) + f'[dim gold4]updated in {elapsed:.4f}s[/]', sub='hooks.mongodb', id=_id, obj=debug_obj, obj_after=False, level=2) self.last_updated = start_time else: # sync update and save result to runner object runner = db[collection].insert_one(update) @@ -55,9 +56,7 @@ def update_runner(self): self.context[f'{type}_id'] = _id end_time = time.time() elapsed = end_time - start_time - debug( - f'created in {elapsed:.4f}s', - sub='hooks.mongodb', id=_id, obj={self.name: self.status}, obj_after=False, level=2) + debug(f'created in {elapsed:.4f}s', sub='hooks.mongodb', id=_id, obj=debug_obj, obj_after=False, level=2) def update_finding(self, item): diff --git a/secator/tasks/nmap.py b/secator/tasks/nmap.py index b1b54549..fb949aa1 100644 --- a/secator/tasks/nmap.py +++ b/secator/tasks/nmap.py @@ -31,7 +31,7 @@ class nmap(VulnMulti): PORTS: {'type': str, 'help': 'Ports to scan', 'short': 'p'}, SCRIPT: {'type': str, 'default': 'vulners', 'help': 'NSE scripts'}, # 'tcp_connect': {'type': bool, 'short': 'sT', 'default': False, 'help': 'TCP Connect scan'}, - 'tcp_syn_stealth': {'type': bool, 'short': 'sS', 'default': False, 'help': 'TCP SYN Stealth'}, + 'tcp_syn_stealth': {'is_flag': True, 'short': 'sS', 'default': False, 'help': 'TCP SYN Stealth'}, 'output_path': {'type': str, 'short': 'oX', 'default': None, 'help': 'Output XML file path'} } opt_key_map = {