Skip to content

Commit

Permalink
I think this finishes wrapping elastic executions in preparation for …
Browse files Browse the repository at this point in the history
…tracing.

It also does a number of renames to make things more consistently named.
  • Loading branch information
0xdade committed Nov 6, 2019
1 parent 3496113 commit e77f74e
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 175 deletions.
5 changes: 3 additions & 2 deletions natlas-server/app/admin/routes.py
Expand Up @@ -396,6 +396,7 @@ def deleteScript(name):
@isAuthenticated
@isAdmin
def deleteScan(scan_id):
# TODO - This function redirects you to the deleted scan, which temporarily works because it's an async delete call.
delForm = forms.DeleteForm()

if delForm.validate_on_submit():
Expand Down Expand Up @@ -427,10 +428,10 @@ def deleteHost(ip):
if delForm.validate_on_submit():
deleted = current_app.elastic.delete_host(ip)
if deleted > 0:
flash("Successfully deleted host %s" % ip, "success")
flash(f"Successfully deleted {deleted - 1 if deleted > 1 else deleted} scans for {ip}", "success")
return redirect(url_for('main.browse'))
else:
flash("Couldn't delete host: %s" % ip, "danger")
flash(f"Couldn't delete host: {ip}", "danger")
else:
flash("Couldn't validate form!")
return redirect(request.referrer)
Expand Down
2 changes: 1 addition & 1 deletion natlas-server/app/api/prepare_work.py
Expand Up @@ -20,7 +20,7 @@ def get_unique_scan_id():
scan_id = ''
while scan_id == '':
rand = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16))
count, context = current_app.elastic.gethost_scan_id(rand)
count, context = current_app.elastic.get_host_by_scan_id(rand)
if count == 0:
scan_id = rand
return scan_id
Expand Down
4 changes: 2 additions & 2 deletions natlas-server/app/api/routes.py
Expand Up @@ -97,7 +97,7 @@ def submit():

# If there's no further processing to do, store the host and prepare the response
elif not newhost["is_up"] or (newhost["is_up"] and newhost["port_count"] == 0):
current_app.elastic.newhost(newhost)
current_app.elastic.new_result(newhost)
status_code = 200
response_body = json.dumps({"status": status_code, "message": "Received: " + newhost['ip']})
except NmapParserException:
Expand Down Expand Up @@ -147,7 +147,7 @@ def submit():
response_body = json.dumps({"status": status_code, "message": "More than 500 ports found, throwing data out"})
else:
status_code = 200
current_app.elastic.newhost(newhost)
current_app.elastic.new_result(newhost)
response_body = json.dumps({"status": status_code, "message": "Received %s ports for %s" % (len(newhost['ports']), newhost['ip'])})

response = Response(response=response_body, status=status_code, content_type=json_content)
Expand Down

0 comments on commit e77f74e

Please sign in to comment.