diff --git a/app/backend/src/App.vue b/app/backend/src/App.vue index d556d5b..9f6d491 100644 --- a/app/backend/src/App.vue +++ b/app/backend/src/App.vue @@ -42,6 +42,9 @@ + diff --git a/app/backend/src/router/index.js b/app/backend/src/router/index.js index e554d1d..32bd83a 100644 --- a/app/backend/src/router/index.js +++ b/app/backend/src/router/index.js @@ -40,6 +40,12 @@ const routes = [ component: () => import('../views/iocs-misp.vue'), props: true }, + { + path: '/iocs/opencti', + name: 'iocs-opencti', + component: () => import('../views/iocs-opencti.vue'), + props: true + }, { path: '/iocs/search', name: 'iocs-search', diff --git a/app/backend/src/views/iocs-opencti.vue b/app/backend/src/views/iocs-opencti.vue new file mode 100644 index 0000000..4914598 --- /dev/null +++ b/app/backend/src/views/iocs-opencti.vue @@ -0,0 +1,170 @@ + + diff --git a/server/backend/app/blueprints/octi.py b/server/backend/app/blueprints/octi.py new file mode 100644 index 0000000..36f1bc4 --- /dev/null +++ b/server/backend/app/blueprints/octi.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from flask import Blueprint, jsonify, Response, request +from app.decorators import require_header_token, require_get_token +from app.classes.octi import OCTI + +import json + +octi_bp = Blueprint("octi", __name__) +octi = OCTI() + + +@octi_bp.route('/add', methods=['POST']) +@require_header_token +def add_instance(): + """ + Parse and add a OpenCTI instance to the database. + :return: status of the operation in JSON + """ + data = json.loads(request.data) + res = octi.add_instance(data["data"]["instance"]) + return jsonify(res) + + +@octi_bp.route('/delete/', methods=['GET']) +@require_header_token +def delete_instance(octi_id): + """ + Delete a OpenCTI instance by its id to the database. + :return: status of the operation in JSON + """ + res = octi.delete_instance(octi_id) + return jsonify(res) + + +@octi_bp.route('/get_all', methods=['GET']) +@require_header_token +def get_all(): + """ + Retreive a list of all OpenCTI instances. + :return: list of OpenCTI instances in JSON. + """ + res = octi.get_instances() + return jsonify({"results": [i for i in res]}) diff --git a/server/backend/main.py b/server/backend/main.py index eedf327..4f6bf07 100644 --- a/server/backend/main.py +++ b/server/backend/main.py @@ -7,6 +7,7 @@ from app.blueprints.ioc import ioc_bp from app.blueprints.whitelist import whitelist_bp from app.blueprints.config import config_bp from app.blueprints.misp import misp_bp +from app.blueprints.octi import octi_bp import datetime import secrets import jwt @@ -58,6 +59,7 @@ app.register_blueprint(ioc_bp, url_prefix='/api/ioc') app.register_blueprint(whitelist_bp, url_prefix='/api/whitelist') app.register_blueprint(config_bp, url_prefix='/api/config') app.register_blueprint(misp_bp, url_prefix='/api/misp') +app.register_blueprint(octi_bp, url_prefix='/api/octi') if __name__ == '__main__': ssl_cert = "{}/{}".format(path[0], 'cert.pem')