mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-26 15:57:16 +00:00
chg: [api] rename endpoints
This commit is contained in:
parent
65eb084e41
commit
054df7c495
2 changed files with 31 additions and 28 deletions
|
@ -222,7 +222,7 @@ def get_item(request_dict):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_item_content_encoded_text(request_dict):
|
def api_get_item_content_base64_utf8(request_dict):
|
||||||
item_id = request_dict.get('id', None)
|
item_id = request_dict.get('id', None)
|
||||||
if not request_dict:
|
if not request_dict:
|
||||||
return {'status': 'error', 'reason': 'Malformed JSON'}, 400
|
return {'status': 'error', 'reason': 'Malformed JSON'}, 400
|
||||||
|
@ -236,22 +236,23 @@ def get_item_content_encoded_text(request_dict):
|
||||||
return {'status': 'success', 'content': item_content}, 200
|
return {'status': 'success', 'content': item_content}, 200
|
||||||
|
|
||||||
|
|
||||||
def get_item_sources():
|
def api_get_items_sources():
|
||||||
item_content = {'sources': get_all_sources()}
|
item_content = {'sources': get_all_sources()}
|
||||||
return item_content, 200
|
return item_content, 200
|
||||||
|
|
||||||
def check_item_source(request_dict):
|
# def check_item_source(request_dict):
|
||||||
source = request_dict.get('source', None)
|
# source = request_dict.get('source', None)
|
||||||
if not request_dict:
|
# if not request_dict:
|
||||||
return {'status': 'error', 'reason': 'Malformed JSON'}, 400
|
# return {'status': 'error', 'reason': 'Malformed JSON'}, 400
|
||||||
if not source:
|
# if not source:
|
||||||
return {'status': 'error', 'reason': 'Mandatory parameter(s) not provided'}, 400
|
# return {'status': 'error', 'reason': 'Mandatory parameter(s) not provided'}, 400
|
||||||
|
#
|
||||||
|
# all_sources = item_basic.get_all_items_sources()
|
||||||
|
#
|
||||||
|
# if source not in all_sources:
|
||||||
|
# return {'status': 'error', 'reason': 'Invalid source', 'provide': source}, 400
|
||||||
|
# return {'status': 'success', 'reason': 'Valid source', 'provide': source}, 200
|
||||||
|
|
||||||
all_sources = item_basic.get_all_items_sources()
|
|
||||||
|
|
||||||
if source not in all_sources:
|
|
||||||
return {'status': 'error', 'reason': 'Invalid source', 'provide': source}, 400
|
|
||||||
return {'status': 'success', 'reason': 'Valid source', 'provide': source}, 200
|
|
||||||
###
|
###
|
||||||
### correlation
|
### correlation
|
||||||
###
|
###
|
||||||
|
|
|
@ -29,7 +29,7 @@ sys.path.append(os.path.join(os.environ['AIL_BIN'], 'import'))
|
||||||
import importer
|
import importer
|
||||||
|
|
||||||
|
|
||||||
from flask import Flask, render_template, jsonify, request, Blueprint, redirect, url_for, Response
|
from flask import Flask, render_template, jsonify, request, Blueprint, redirect, url_for, Response, escape
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
@ -72,7 +72,7 @@ def verify_user_role(role, token):
|
||||||
# User without API
|
# User without API
|
||||||
if role == 'user_no_api':
|
if role == 'user_no_api':
|
||||||
return False
|
return False
|
||||||
|
|
||||||
user_id = get_user_from_token(token)
|
user_id = get_user_from_token(token)
|
||||||
if user_id:
|
if user_id:
|
||||||
if is_in_role(user_id, role):
|
if is_in_role(user_id, role):
|
||||||
|
@ -313,32 +313,33 @@ def get_item_content():
|
||||||
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
||||||
|
|
||||||
|
|
||||||
@restApi.route("api/v1/get/item/content/encoded/text", methods=['POST'])
|
@restApi.route("api/v1/get/item/content/utf8/base64", methods=['POST'])
|
||||||
@token_required('read_only')
|
@token_required('read_only')
|
||||||
def get_item_content_encoded_text():
|
def get_item_content_encoded_text():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
item_id = data.get('id', None)
|
item_id = data.get('id', None)
|
||||||
req_data = {'id': item_id}
|
req_data = {'id': item_id}
|
||||||
res = Item.get_item_content_encoded_text(req_data)
|
res = Item.api_get_item_content_base64_utf8(req_data)
|
||||||
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
||||||
|
|
||||||
|
|
||||||
@restApi.route("api/v1/get/item/sources", methods=['GET'])
|
@restApi.route("api/v1/get/items/sources", methods=['GET'])
|
||||||
@token_required('read_only')
|
@token_required('read_only')
|
||||||
def get_item_sources():
|
def get_item_sources():
|
||||||
res = Item.get_item_sources()
|
res = Item.api_get_items_sources()
|
||||||
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@restApi.route("api/v1/get/item/source/check", methods=['POST'])
|
# @restApi.route("api/v1/get/item/source/check", methods=['POST'])
|
||||||
@token_required('read_only')
|
# @token_required('read_only')
|
||||||
def get_check_item_source():
|
# def get_check_item_source():
|
||||||
data = request.get_json()
|
# data = request.get_json()
|
||||||
source = data.get('source', None)
|
# source = data.get('source', None)
|
||||||
req_data = {'source': source}
|
# req_data = {'source': source}
|
||||||
res = Item.check_item_source(req_data)
|
# res = Item.check_item_source(req_data)
|
||||||
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
# return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
||||||
|
|
||||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
# # # # # # # # # # # # # # TAGS # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # TAGS # # # # # # # # # # # # # # # # #
|
||||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
@ -395,11 +396,11 @@ def get_tracker_term_item():
|
||||||
def get_default_yara_rule_content():
|
def get_default_yara_rule_content():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
rule_name = data.get('rule_name', None)
|
rule_name = data.get('rule_name', None)
|
||||||
|
rule_name = escape(rule_name)
|
||||||
req_data = {'rule_name': rule_name}
|
req_data = {'rule_name': rule_name}
|
||||||
res = Tracker.get_yara_rule_content_restapi(req_data)
|
res = Tracker.get_yara_rule_content_restapi(req_data)
|
||||||
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
||||||
|
|
||||||
|
|
||||||
@restApi.route("api/v1/get/tracker/metadata", methods=['POST'])
|
@restApi.route("api/v1/get/tracker/metadata", methods=['POST'])
|
||||||
@token_required('read_only')
|
@token_required('read_only')
|
||||||
def get_tracker_metadata_api():
|
def get_tracker_metadata_api():
|
||||||
|
@ -408,6 +409,7 @@ def get_tracker_metadata_api():
|
||||||
req_data = {'tracker_uuid': tracker_uuid}
|
req_data = {'tracker_uuid': tracker_uuid}
|
||||||
res = Tracker.get_tracker_metadata_api(req_data)
|
res = Tracker.get_tracker_metadata_api(req_data)
|
||||||
return Response(json.dumps(res[0], indent=2, sort_keys=False), mimetype='application/json'), res[1]
|
return Response(json.dumps(res[0], indent=2, sort_keys=False), mimetype='application/json'), res[1]
|
||||||
|
|
||||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
# # # # # # # # # # # # CRYPTOCURRENCY # # # # # # # # # # # # # #
|
# # # # # # # # # # # # CRYPTOCURRENCY # # # # # # # # # # # # # #
|
||||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
|
Loading…
Reference in a new issue