Skip to content

Commit

Permalink
Merge pull request #35 from fireeye/elazar-changes
Browse files Browse the repository at this point in the history
Elazar changes
  • Loading branch information
B0fH authored Nov 2, 2020
2 parents aec0c48 + 4252c68 commit a69f651
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To install HXTool:
4. Access the web user interface via a browser: https://127.0.0.1:8080 (tested with Google Chrome and Mozilla Firefox)

### Dependencies ###
Python 2.7.14+ or 3.x
Python 3.6 or greater (Python 2.x is deprecated, and while it may still work, it will no longer be supported.)
Python Flask library
Python Requests library
Python Pycryptodome library
Expand Down
27 changes: 17 additions & 10 deletions hxtool_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,11 +1110,12 @@ def hxtool_api_stacking_new(hx_api_object):
if stack_type:
with open(combine_app_path('scripts', stack_type['script']), 'r') as f:
script_xml = f.read()
hostset_id = int(request.form['stackhostset'])
bulk_download_eid = submit_bulk_job(hx_api_object, script_xml, hostset_id = hostset_id, task_profile = "stacking", comment = "HXTool Stacking Job: {}".format(stack_type['name']))
ret = hxtool_global.hxtool_db.stackJobCreate(session['ht_profileid'], bulk_download_eid, request.form['stack_type'])
app.logger.info(format_activity_log(msg="stacking", action="new", hostsetid=hostset_id, type=request.form['stack_type'], user=session['ht_user'], controller=session['hx_ip']))
return(app.response_class(response=json.dumps("OK"), status=200, mimetype='application/json'))
f.close()
hostset_id = int(request.form['stackhostset'])
bulk_download_eid = submit_bulk_job(hx_api_object, script_xml, hostset_id = hostset_id, task_profile = "stacking", comment = "HXTool Stacking Job: {}".format(stack_type['name']))
ret = hxtool_global.hxtool_db.stackJobCreate(session['ht_profileid'], bulk_download_eid, request.form['stack_type'])
app.logger.info(format_activity_log(msg="stacking", action="new", hostsetid=hostset_id, type=request.form['stack_type'], user=session['ht_user'], controller=session['hx_ip']))
return(app.response_class(response=json.dumps("OK"), status=200, mimetype='application/json'))

@ht_api.route('/api/v{0}/stacking/remove'.format(HXTOOL_API_VERSION), methods=['GET'])
@valid_session_required
Expand All @@ -1126,9 +1127,12 @@ def hxtool_api_stacking_remove(hx_api_object):
if bulk_download_job and 'bulk_acquisition_id' in bulk_download_job:
(ret, response_code, response_data) = hx_api_object.restDeleteJob('acqs/bulk', bulk_download_job['bulk_acquisition_id'])
hxtool_global.hxtool_db.bulkDownloadDelete(bulk_download_job.doc_id)
(r, rcode) = create_api_response(ret, response_code, response_data)
else:
(r, rcode) = create_api_response()

hxtool_global.hxtool_db.stackJobDelete(stack_job.doc_id)
(r, rcode) = create_api_response(ret, response_code, response_data)

app.logger.info(format_activity_log(msg="stacking", action="remove", id=request.args.get('id'), user=session['ht_user'], controller=session['hx_ip']))
return(app.response_class(response=json.dumps(r), status=rcode, mimetype='application/json'))

Expand All @@ -1140,12 +1144,15 @@ def hxtool_api_stacking_stop(hx_api_object):
bulk_download_job = hxtool_global.hxtool_db.bulkDownloadGet(bulk_download_eid = stack_job['bulk_download_eid'])
if bulk_download_job and 'bulk_acquisition_id' in bulk_download_job:
(ret, response_code, response_data) = hx_api_object.restCancelJob('acqs/bulk', bulk_download_job['bulk_acquisition_id'])
hxtool_global.hxtool_db.stackJobStop(stack_job_eid = stack_job.doc_id)
hxtool_global.hxtool_db.bulkDownloadUpdate(bulk_download_job.doc_id, stopped = True)

(r, rcode) = create_api_response(ret, response_code, response_data)
app.logger.info(format_activity_log(msg="stacking", action="stop", id=request.args.get('id'), user=session['ht_user'], controller=session['hx_ip']))
return(app.response_class(response=json.dumps(r), status=rcode, mimetype='application/json'))
else:
(r, rcode) = create_api_response()

hxtool_global.hxtool_db.stackJobStop(stack_job_eid = stack_job.doc_id)

app.logger.info(format_activity_log(msg="stacking", action="stop", id=request.args.get('id'), user=session['ht_user'], controller=session['hx_ip']))
return(app.response_class(response=json.dumps(r), status=rcode, mimetype='application/json'))



Expand Down

0 comments on commit a69f651

Please sign in to comment.