[Chrome extension] Added support to ssl, fixed exportation and added minor and major severity

This commit is contained in:
fermin831 2018-10-24 11:38:21 +02:00
parent 7a64bb4855
commit 3a71d07f78
4 changed files with 24 additions and 19 deletions

View File

@ -248,3 +248,10 @@ button h3 {
.sev-Maintenance { .sev-Maintenance {
background: #A8A8A8; background: #A8A8A8;
} }
.sev-Minor {
background: #F099A2;
color: #333;
}
.sev-Major {
background: #C97A4A;
}

View File

@ -29,11 +29,13 @@ function main() {
if (isFetching) return; if (isFetching) return;
isFetching = true; isFetching = true;
var feedUrl = localStorage["ip_address"]+'/include/api.php?op=get&op2=events&return_type=csv&apipass='+localStorage["api_pass"]+'&user='+localStorage["user_name"]+'&pass='+localStorage["pass"]; var feedUrl = localStorage["ip_address"]+'/include/api.php?op=get&op2=events&return_type=json&apipass='+localStorage["api_pass"]+'&user='+localStorage["user_name"]+'&pass='+localStorage["pass"];
req = new XMLHttpRequest(); req = new XMLHttpRequest();
req.onload = handleResponse; req.onload = handleResponse;
req.onerror = handleError; req.onerror = handleError;
req.open("GET", feedUrl, true); req.open("GET", feedUrl, true);
req.withCredentials = true
req.send(null); req.send(null);
} }
@ -132,25 +134,23 @@ function fetchNewEvents(A,B){
function parseReplyEvents (reply) { function parseReplyEvents (reply) {
// Split the API response // Split the API response
var e_array = reply.split("\n"); var data = JSON.parse(reply)
var e_array = JSON.parse(reply).data;
// Form a properly object // Form a properly object
var fetchedEvents=new Array(); var fetchedEvents=new Array();
for(var i=0;i<e_array.length;i++){ for(var i=0;i<e_array.length;i++){
// Avoid to parse empty lines var event=e_array[i];
if (e_array[i].length == 0) continue;
var event=e_array[i].split(";");
fetchedEvents.push({ fetchedEvents.push({
'id' : event[0], 'id' : event.id_evento,
'agent_name' : event[1], 'agent_name' : event.agent_name,
'agent' : event[2], 'agent' : event.id_agent,
'date' : event[5], 'date' : event.timestamp,
'title' : event[6], 'title' : event.evento,
'module' : event[9], 'module' : event.id_agentmodule,
'type' : event[14], 'type' : event.event_type,
'source' : event[17], 'source' : event.source,
'severity' : event[28], 'severity' : event.criticity_name,
'visited' : false 'visited' : false
}); });
} }

View File

@ -1,17 +1,14 @@
console.log("hola");
var url = window.location.href; var url = window.location.href;
var re = /\?event=(\d+)/; var re = /\?event=(\d+)/;
console.log("hola");
if(re.exec(url)) { if(re.exec(url)) {
if(!isNaN(RegExp.$1)) { if(!isNaN(RegExp.$1)) {
var eventId = RegExp.$1; var eventId = RegExp.$1;
document.write(chrome.extension.getBackgroundPage().getNotification(eventId)); document.write(chrome.extension.getBackgroundPage().getNotification(eventId));
} }
} }
console.log("hola");
window.onload = function () { window.onload = function () {
setTimeout(function() { setTimeout(function() {
window.close(); window.close();
}, 10000); }, 10000);
} }
console.log("hola");

View File

@ -23,6 +23,7 @@
"tabs", "tabs",
"notifications", "notifications",
"http://*/*", "http://*/*",
"https://*/*",
"background" "background"
], ],
"default_locale": "en" "default_locale": "en"