Skip to content

Commit

Permalink
fix: redis docs, nmap issue, mongodb debug (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocervell committed Apr 4, 2024
1 parent 04254f1 commit 0383056
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion secator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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://<url>" environment variable pointing to your Redis instance.',
'Set the "CELERY_RESULT_BACKEND=redis://<url>" 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.'
]
Expand Down
11 changes: 5 additions & 6 deletions secator/hooks/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,24 @@ 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()
db[collection].update_one({'_id': ObjectId(_id)}, {'$set': update})
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)
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion secator/tasks/nmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 0383056

Please sign in to comment.