| |
| |
| |
| |
| |
| |
| import { Meteor } from 'meteor/meteor'; |
| import { _ } from 'meteor/underscore'; |
|
|
|
|
| if (Meteor.isServer) { |
|
|
| |
| Meteor.methods({ |
| 'saySomething': saySomething, |
| 'loadKibanaDashboards': loadKibanaDashboards, |
| 'blockip': blockIP, |
| 'blockfqdn': blockFQDN, |
| 'watchitem': watchItem, |
| 'ipwhois': ipwhois, |
| 'ipdshield': ipdshield, |
| 'ipsearch': ipsearch, |
| 'verisstats': verisstats, |
| 'getplugins': getplugins, |
| 'getserversetting': getserversetting |
| }); |
|
|
| function saySomething() { |
| |
| console.log("something is said"); |
| } |
|
|
| function loadKibanaDashboards() { |
| console.log('Loading Kibana dashboards... ' + mozdef.rootAPI + '/kibanadashboards'); |
| var dashboardsRequest = HTTP.get(mozdef.rootAPI + '/kibanadashboards'); |
|
|
| if (dashboardsRequest.statusCode==200 && dashboardsRequest.data) { |
| |
| console.log("Updating kibana dashboards..."); |
| kibanadashboards.remove({}); |
| dashboardsRequest.data.forEach(function(dashboard, index, arr) { |
| kibanadashboards.insert(dashboard); |
| }); |
| |
| } else { |
| console.log("Could not retrieve kibana dashboards... check settings"); |
| console.log(mozdef.rootAPI + '/kibanadashboards'); |
| console.log("returned a " + dashboardsRequest.statusCode); |
| console.log(dashboardsRequest.data); |
| } |
| } |
| function watchItem(formobj) { |
| var watchItemRequest = HTTP.post(mozdef.rootAPI + '/watchitem', {data: formobj}); |
|
|
| if (watchItemRequest.statusCode==200) { |
| console.log(JSON.stringify(formobj) + ' successfully sent to ' + mozdef.rootAPI); |
| return true; |
| } else { |
| console.log("Could not send to "+ mozdef.rootAPI + '/watchitem ' + JSON.stringify(formobj) ); |
| return watchItemRequest; |
| } |
| } |
|
|
| function blockIP(formobj) { |
| var blockIPRequest = HTTP.post(mozdef.rootAPI + '/blockip', {data: formobj}); |
|
|
| if (blockIPRequest.statusCode==200) { |
| console.log(JSON.stringify(formobj) + ' successfully sent to ' + mozdef.rootAPI); |
| return true; |
| } else { |
| console.log("Could not send to "+ mozdef.rootAPI + '/blockip ' + JSON.stringify(formobj) ); |
| return blockIPRequest; |
| } |
| } |
|
|
| function blockFQDN(formobj) { |
| try{ |
| var blockFQDNRequest = HTTP.post(mozdef.rootAPI + '/blockfqdn', {data: formobj}); |
|
|
| if (blockFQDNRequest.statusCode==200) { |
| console.log(JSON.stringify(formobj) + ' successfully sent to ' + mozdef.rootAPI); |
| return true; |
| } |
| }catch (e) { |
| console.log("Error posting to "+ mozdef.rootAPI + '/blockfqdn ' + JSON.stringify(formobj) ); |
| console.log(e) |
| if ( e.response.statusCode == 400 ){ |
| |
| console.log(e.response.content); |
| return e.response.content; |
| }else{ |
| return e; |
| } |
| } |
| } |
|
|
| function ipwhois(ipaddress){ |
| |
| var ipwhoisResponse = HTTP.post(mozdef.rootAPI + '/ipwhois/',{data: {'ipaddress':ipaddress}}); |
|
|
| if ( typeof ipwhoisResponse == 'undefined') { |
| console.log("ipwhois: no response from server") |
| return ""; |
| } else { |
| |
| return ipwhoisResponse; |
| } |
| } |
|
|
| function ipdshield(ipaddress){ |
| |
| var ipdshieldResponse = HTTP.post(mozdef.rootAPI + '/ipdshieldquery/',{data: {'ipaddress':ipaddress}}); |
|
|
| if ( typeof ipdshieldResponse == 'undefined') { |
| console.log("ipdshield: no response from server") |
| return ""; |
| } else { |
| |
| return ipdshieldResponse; |
| } |
| } |
|
|
| function ipsearch(ipaddress){ |
| |
| var ipsearchResponse = HTTP.post(mozdef.rootAPI + '/ipsearch/',{data: {'ipaddress':ipaddress}}); |
|
|
| if ( typeof ipsearchResponse == 'undefined') { |
| console.log("ipsearch: no response from server") |
| return ""; |
| } else { |
| |
| return ipsearchResponse; |
| } |
| } |
|
|
| function verisstats(){ |
| |
| var verisstatsResponse = HTTP.get(mozdef.rootAPI + '/veris/'); |
|
|
| if ( typeof verisstatsResponse == 'undefined') { |
| console.log("verisstats: no response from server") |
| return ""; |
| } else { |
| |
| return verisstatsResponse; |
| } |
| } |
|
|
| function getplugins(endpoint){ |
| |
| if ( typeof endpoint == 'undefined') { |
| var response = HTTP.get(mozdef.rootAPI + '/plugins/'); |
|
|
| } else { |
| var response = HTTP.get(mozdef.rootAPI + '/plugins/' + endpoint); |
| } |
| return response |
| } |
|
|
| function getserversetting(settingKey){ |
| if ( _.has(mozdef,settingKey) ){ |
| return mozdef[settingKey]; |
| }else{ |
| return ''; |
| } |
| } |
|
|
| }; |
|
|