mirror of https://github.com/MISP/misp-dashboard
UI attunement - Possibility to adjust with of panels in config, immediatly change text. Bit of zmq refacto
parent
6425fc711e
commit
6c7916b5be
|
@ -6,6 +6,8 @@ rotation_wait_time = 30
|
||||||
max_img_rotation = 10
|
max_img_rotation = 10
|
||||||
hours_spanned = 48
|
hours_spanned = 48
|
||||||
zoomlevel = 15
|
zoomlevel = 15
|
||||||
|
# [1->12]
|
||||||
|
size_dashboard_left_width = 5
|
||||||
size_openStreet_pannel_perc = 55
|
size_openStreet_pannel_perc = 55
|
||||||
size_world_pannel_perc = 35
|
size_world_pannel_perc = 35
|
||||||
|
|
||||||
|
@ -26,3 +28,4 @@ port=6250
|
||||||
db=1
|
db=1
|
||||||
channelProc=CoordToProcess
|
channelProc=CoordToProcess
|
||||||
channelDisp=PicToDisplay
|
channelDisp=PicToDisplay
|
||||||
|
pathMaxMindDB=/home/sami/Downloads/GeoLite2-City_20171003/GeoLite2-City.mmdb
|
||||||
|
|
|
@ -97,6 +97,7 @@ def index():
|
||||||
]
|
]
|
||||||
return render_template('index.html',
|
return render_template('index.html',
|
||||||
pannelSize=pannelSize,
|
pannelSize=pannelSize,
|
||||||
|
size_dashboard_width=[cfg.getint('Dashboard' ,'size_dashboard_left_width'), 12-cfg.getint('Dashboard', 'size_dashboard_left_width')],
|
||||||
graph_log_refresh_rate=cfg.getint('Dashboard' ,'graph_log_refresh_rate'),
|
graph_log_refresh_rate=cfg.getint('Dashboard' ,'graph_log_refresh_rate'),
|
||||||
char_separator=cfg.get('Log', 'char_separator'),
|
char_separator=cfg.get('Log', 'char_separator'),
|
||||||
rotation_wait_time=cfg.getint('Dashboard' ,'rotation_wait_time'),
|
rotation_wait_time=cfg.getint('Dashboard' ,'rotation_wait_time'),
|
||||||
|
|
|
@ -240,18 +240,10 @@ function updateLogTable(feedName, log, zmqName) {
|
||||||
createRow(tableBody, log);
|
createRow(tableBody, log);
|
||||||
|
|
||||||
// Remove old row
|
// Remove old row
|
||||||
var logSel = document.getElementById("log_select");
|
while ($("#table_log").height() >= $("#panelLogTable").height()-26){ //26 for margin
|
||||||
//get height of pannel, find max num of item
|
tableBody.deleteRow(0);
|
||||||
var maxNumLogItem = document.getElementById('divLogTable').clientHeight/37;
|
|
||||||
maxNumLogItem -= 2; //take heading/padding/... into account
|
|
||||||
if (maxNumLogItem - parseInt(maxNumLogItem) < 0.5) { //beautifier
|
|
||||||
maxNumLogItem -= 1;
|
|
||||||
}
|
|
||||||
if (tableBody.rows.length > maxNumLogItem) {
|
|
||||||
while (tableBody.rows.length >= maxNumLogItem){
|
|
||||||
tableBody.deleteRow(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (feedName == "Keepalive") {
|
} else if (feedName == "Keepalive") {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -90,7 +90,7 @@ class MapEventManager {
|
||||||
myOpenStreetMap.flyTo([mapEvent.coord.lat, mapEvent.coord.lon], ZOOMLEVEL);
|
myOpenStreetMap.flyTo([mapEvent.coord.lat, mapEvent.coord.lon], ZOOMLEVEL);
|
||||||
mapEvent.marker.bindPopup(mapEvent.textMarker).openPopup();
|
mapEvent.marker.bindPopup(mapEvent.textMarker).openPopup();
|
||||||
|
|
||||||
$("#textMap1").fadeOut(400, function(){ $(this).text(mapEvent.text); }).fadeIn(400);
|
$("#textMap1").text(mapEvent.text);
|
||||||
if(ROTATIONWAITTIME != 0) {
|
if(ROTATIONWAITTIME != 0) {
|
||||||
this._timeoutRotate = setTimeout(function(){ mapEventManager.rotateMap(); }, ROTATIONWAITTIME);
|
this._timeoutRotate = setTimeout(function(){ mapEventManager.rotateMap(); }, ROTATIONWAITTIME);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ small {
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="col-lg-5">
|
<div class="col-lg-{{ size_dashboard_width[0] }}">
|
||||||
|
|
||||||
<div id="panelOpenMap" class="panel panel-default" style="margin-top: 15px; height: {{ pannelSize[0] }}vh;">
|
<div id="panelOpenMap" class="panel panel-default" style="margin-top: 15px; height: {{ pannelSize[0] }}vh;">
|
||||||
<div class="panel-heading bg-info" style="font-weight: bold;">
|
<div class="panel-heading bg-info" style="font-weight: bold;">
|
||||||
|
@ -168,7 +168,7 @@ small {
|
||||||
</div>
|
</div>
|
||||||
<!-- /.col-lg-6 -->
|
<!-- /.col-lg-6 -->
|
||||||
<!-- /.col-lg-6 -->
|
<!-- /.col-lg-6 -->
|
||||||
<div class="col-lg-7">
|
<div class="col-lg-{{ size_dashboard_width[1] }}">
|
||||||
|
|
||||||
<div class="panel panel-default" style="margin-top: 15px; height: {{ pannelSize[2] }}vh;">
|
<div class="panel panel-default" style="margin-top: 15px; height: {{ pannelSize[2] }}vh;">
|
||||||
<div id="panelbody" class="panel-body" style="height: 100%;">
|
<div id="panelbody" class="panel-body" style="height: 100%;">
|
||||||
|
@ -179,7 +179,7 @@ small {
|
||||||
</div>
|
</div>
|
||||||
<!-- /.panel -->
|
<!-- /.panel -->
|
||||||
|
|
||||||
<div class="panel panel-default" style="height: {{ pannelSize[3] }}vh;">
|
<div id="panelLogTable" class="panel panel-default" style="height: {{ pannelSize[3] }}vh;">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<i class="fa fa-tasks fa-fw"></i> Logs
|
<i class="fa fa-tasks fa-fw"></i> Logs
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
|
@ -188,7 +188,7 @@ small {
|
||||||
<input id="checkbox_log_critical" type="checkbox" value="critical" checked="true"> CRITICAL
|
<input id="checkbox_log_critical" type="checkbox" value="critical" checked="true"> CRITICAL
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="divLogTable" class="panel-body" style="height: 98%;">
|
<div id="divLogTable" class="panel-body" style="height: 98%; padding: 0px;">
|
||||||
<div class="row" style="height: 100%;">
|
<div class="row" style="height: 100%;">
|
||||||
<div class="col-lg-12" style="height: 100%;">
|
<div class="col-lg-12" style="height: 100%;">
|
||||||
<table class="table table-bordered table-hover table-striped" id="table_log">
|
<table class="table table-bordered table-hover table-striped" id="table_log">
|
||||||
|
|
|
@ -15,13 +15,11 @@ configfile = os.path.join(os.environ['VIRTUAL_ENV'], '../config.cfg')
|
||||||
cfg = configparser.ConfigParser()
|
cfg = configparser.ConfigParser()
|
||||||
cfg.read(configfile)
|
cfg.read(configfile)
|
||||||
|
|
||||||
zmq_url = cfg.get('RedisLog', 'zmq_url')
|
ZMQ_URL = cfg.get('RedisLog', 'zmq_url')
|
||||||
channel = cfg.get('RedisLog', 'channel')
|
CHANNEL = cfg.get('RedisLog', 'channel')
|
||||||
context = zmq.Context()
|
CHANNELDISP = cfg.get('RedisMap', 'channelDisp')
|
||||||
socket = context.socket(zmq.SUB)
|
CHANNEL_PROC = cfg.get('RedisMap', 'channelProc')
|
||||||
socket.connect(zmq_url)
|
PATH_TO_DB = cfg.get('RedisMap', 'pathMaxMindDB')
|
||||||
socket.setsockopt_string(zmq.SUBSCRIBE, '')
|
|
||||||
channelDisp = cfg.get('RedisMap', 'channelDisp')
|
|
||||||
|
|
||||||
redis_server = redis.StrictRedis(
|
redis_server = redis.StrictRedis(
|
||||||
host=cfg.get('RedisLog', 'host'),
|
host=cfg.get('RedisLog', 'host'),
|
||||||
|
@ -31,14 +29,13 @@ serv_coord = redis.StrictRedis(
|
||||||
host=cfg.get('RedisMap', 'host'),
|
host=cfg.get('RedisMap', 'host'),
|
||||||
port=cfg.getint('RedisMap', 'port'),
|
port=cfg.getint('RedisMap', 'port'),
|
||||||
db=cfg.getint('RedisMap', 'db'))
|
db=cfg.getint('RedisMap', 'db'))
|
||||||
path_to_db = "/home/sami/Downloads/GeoLite2-City_20171003/GeoLite2-City.mmdb"
|
|
||||||
reader = geoip2.database.Reader(path_to_db)
|
|
||||||
|
|
||||||
channel_proc = "CoordToProcess"
|
reader = geoip2.database.Reader(PATH_TO_DB)
|
||||||
|
|
||||||
|
|
||||||
def publish_log(zmq_name, name, content):
|
def publish_log(zmq_name, name, content):
|
||||||
to_send = { 'name': name, 'log': json.dumps(content), 'zmqName': zmq_name }
|
to_send = { 'name': name, 'log': json.dumps(content), 'zmqName': zmq_name }
|
||||||
redis_server.publish(channel, json.dumps(to_send))
|
redis_server.publish(CHANNEL, json.dumps(to_send))
|
||||||
|
|
||||||
|
|
||||||
def ip_to_coord(ip):
|
def ip_to_coord(ip):
|
||||||
|
@ -70,7 +67,7 @@ def getCoordAndPublish(zmq_name, supposed_ip, categ):
|
||||||
"cityName": rep['full_rep'].city.name,
|
"cityName": rep['full_rep'].city.name,
|
||||||
"regionCode": rep['full_rep'].country.iso_code,
|
"regionCode": rep['full_rep'].country.iso_code,
|
||||||
}
|
}
|
||||||
serv_coord.publish(channelDisp, json.dumps(to_send))
|
serv_coord.publish(CHANNELDISP, json.dumps(to_send))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print("can't resolve ip")
|
print("can't resolve ip")
|
||||||
|
|
||||||
|
@ -94,6 +91,8 @@ def handler_event(zmq_name, jsonevent):
|
||||||
#redirect to handler_attribute
|
#redirect to handler_attribute
|
||||||
if 'Attribute' in jsonevent:
|
if 'Attribute' in jsonevent:
|
||||||
attributes = jsonevent['Attribute']
|
attributes = jsonevent['Attribute']
|
||||||
|
print("+--------- EVENTS -----------+")
|
||||||
|
print(attributes)
|
||||||
if attributes is list:
|
if attributes is list:
|
||||||
for attr in attributes:
|
for attr in attributes:
|
||||||
handler_attribute(zmq_name, attr)
|
handler_attribute(zmq_name, attr)
|
||||||
|
@ -102,6 +101,7 @@ def handler_event(zmq_name, jsonevent):
|
||||||
|
|
||||||
|
|
||||||
def handler_attribute(zmq_name, jsonattr):
|
def handler_attribute(zmq_name, jsonattr):
|
||||||
|
print("+--------- ATTRIBUTE -----------+")
|
||||||
jsonattr = jsonattr['Attribute']
|
jsonattr = jsonattr['Attribute']
|
||||||
print(jsonattr)
|
print(jsonattr)
|
||||||
to_push = []
|
to_push = []
|
||||||
|
@ -128,6 +128,11 @@ def process_log(zmq_name, event):
|
||||||
|
|
||||||
|
|
||||||
def main(zmqName):
|
def main(zmqName):
|
||||||
|
context = zmq.Context()
|
||||||
|
socket = context.socket(zmq.SUB)
|
||||||
|
socket.connect(ZMQ_URL)
|
||||||
|
socket.setsockopt_string(zmq.SUBSCRIBE, '')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
content = socket.recv()
|
content = socket.recv()
|
||||||
content.replace(b'\n', b'') # remove \n...
|
content.replace(b'\n', b'') # remove \n...
|
||||||
|
@ -150,6 +155,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='A zmq subscriber. It subscribe to a ZNQ then redispatch it to the misp-dashboard')
|
parser = argparse.ArgumentParser(description='A zmq subscriber. It subscribe to a ZNQ then redispatch it to the misp-dashboard')
|
||||||
parser.add_argument('-n', '--name', required=False, dest='zmqname', help='The ZMQ feed name', default="Misp Standard ZMQ")
|
parser.add_argument('-n', '--name', required=False, dest='zmqname', help='The ZMQ feed name', default="Misp Standard ZMQ")
|
||||||
|
parser.add_argument('-u', '--url', required=False, dest='zmqurl', help='The URL to connect to', default=ZMQ_URL)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
main(args.zmqname)
|
main(args.zmqname)
|
||||||
|
|
Loading…
Reference in New Issue