mirror of https://github.com/MISP/misp-modules
chg: [website] use ui-priority
parent
50d6e60074
commit
a2721c967b
|
@ -2,3 +2,6 @@
|
|||
path = misp_modules/lib/misp-objects
|
||||
url = https://github.com/MISP/misp-objects.git
|
||||
branch = main
|
||||
[submodule "website/data/misp-objects"]
|
||||
path = website/data/misp-objects
|
||||
url = https://github.com/MISP/misp-objects
|
||||
|
|
|
@ -3,7 +3,7 @@ import json
|
|||
from queue import Queue
|
||||
from threading import Thread
|
||||
from uuid import uuid4
|
||||
from .utils.utils import query_post_query, query_get_module
|
||||
from .utils.utils import query_post_query, query_get_module, get_object
|
||||
from . import home_core as HomeModel
|
||||
import uuid
|
||||
from . import db
|
||||
|
@ -131,6 +131,20 @@ class Session_class:
|
|||
else:
|
||||
send_to = {"module": work[1], self.input_query: self.query, "config": loc_config}
|
||||
res = query_post_query(send_to)
|
||||
|
||||
## Sort attr in object by ui-priority
|
||||
if "results" in res:
|
||||
if "Object" in res["results"]:
|
||||
for obj in res["results"]["Object"]:
|
||||
loc_obj = get_object(obj["name"])
|
||||
if loc_obj:
|
||||
for attr in obj["Attribute"]:
|
||||
attr["ui-priority"] = loc_obj["attributes"][attr["object_relation"]]["ui-priority"]
|
||||
|
||||
# After adding 'ui-priority'
|
||||
obj["Attribute"].sort(key=lambda x: x["ui-priority"], reverse=True)
|
||||
|
||||
|
||||
# print(res)
|
||||
if "error" in res:
|
||||
self.nb_errors += 1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# import os
|
||||
import os
|
||||
import uuid
|
||||
import json
|
||||
import requests
|
||||
|
@ -37,6 +37,15 @@ def isUUID(uid):
|
|||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
def get_object(obj_name):
|
||||
loc_path = os.path.join(os.getcwd(), "data", "misp-objects", "objects")
|
||||
if os.path.isdir(loc_path):
|
||||
with open(os.path.join(loc_path, obj_name, "definition.json"), "r") as read_json:
|
||||
loc_json = json.load(read_json)
|
||||
return loc_json
|
||||
return False
|
||||
|
||||
|
||||
|
||||
# def form_to_dict(form):
|
||||
|
|
|
@ -8,5 +8,7 @@ source env/bin/activate
|
|||
|
||||
pip install -r requirements.txt
|
||||
|
||||
git submodule init && git submodule update
|
||||
|
||||
python app.py -i
|
||||
deactivate
|
||||
|
|
Loading…
Reference in New Issue