<NME> methods.js
<BEF> /*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
Copyright (c) 2014 Mozilla Corporation
*/
import { Meteor } from 'meteor/meteor';

if (Meteor.isServer) {

    //public server-side functions
    Meteor.methods({
        'saySomething': saySomething,
        'loadKibanaDashboards': loadKibanaDashboards,
        'blockip': blockIP,
        'blockfqdn': blockFQDN,
        'watchitem': watchItem,
        'ipwhois': ipwhois,
        'ipintel': ipintel,
        'verisstats': verisstats,
        'logincounts': logincounts,
        'getplugins': getplugins
    });

    function saySomething() {
        //debug function
        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) {
            // set the current dashboards in the mongo collection
            console.log("Updating kibana dashboards...");
            kibanadashboards.remove({});
            dashboardsRequest.data.forEach(function(dashboard, index, arr) {
                kibanadashboards.insert(dashboard);
            });
          //console.log(dashboardsRequest.data);
        } 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 ){
                // rest API set a reason in content
                console.log(e.response.content);
                return e.response.content;
            }else{
                return e;
            }
        }
    }

    function ipwhois(ipaddress){
        //console.log('Posting ' + ipaddress + 'to ' + mozdef.rootAPI + '/ipwhois/');
        var ipwhoisResponse = HTTP.post(mozdef.rootAPI + '/ipwhois/',{data: {'ipaddress':ipaddress}});

        if ( typeof ipwhoisResponse == 'undefined') {
            console.log("ipwhois: no response from server")
            return "";
        } else {
            //console.log(ipwhoisResponse);
            return ipwhoisResponse;
        }
    }

    function ipdshield(ipaddress){
        //console.log('Posting ' + ipaddress + 'to ' + mozdef.rootAPI + '/ipwhois/');
        var ipdshieldResponse = HTTP.post(mozdef.rootAPI + '/ipdshieldquery/',{data: {'ipaddress':ipaddress}});

        if ( typeof ipdshieldResponse == 'undefined') {
            console.log("ipdshield: no response from server")
            return "";
        } else {
            //console.log(ipdshieldResponse);
            return ipdshieldResponse;
        }
    }

    function ipsearch(ipaddress){
        //console.log('Posting ' + ipaddress + 'to ' + mozdef.rootAPI + '/ipwhois/');
        var ipsearchResponse = HTTP.post(mozdef.rootAPI + '/ipsearch/',{data: {'ipaddress':ipaddress}});

        if ( typeof ipsearchResponse == 'undefined') {
            console.log("ipsearch: no response from server")
            return "";
        } else {
            //console.log(ipdshieldResponse);
            return ipsearchResponse;
        }
    }

    function verisstats(){
        //console.log('Calling ' + mozdef.rootAPI + '/veris/');
        var verisstatsResponse = HTTP.get(mozdef.rootAPI + '/veris/');

        if ( typeof verisstatsResponse == 'undefined') {
            console.log("verisstats: no response from server")
            return "";
        } else {
            //console.log(verisstatsResponse);
            return verisstatsResponse;
        }
    }

    function getplugins(endpoint){
        //console.log('Looking up  plugins registered for ' + endpoint + ' from ' + mozdef.rootAPI + '/plugins/' + endpoint);
        if ( typeof endpoint == 'undefined') {
            var response = HTTP.get(mozdef.rootAPI + '/plugins/');

        } else {
            var response = HTTP.get(mozdef.rootAPI + '/plugins/' + endpoint);
        }
        return response
    }
        return response
    }

};

<MSG> add get server settings function

<DFF> @@ -5,6 +5,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
 Copyright (c) 2014 Mozilla Corporation
 */
 import { Meteor } from 'meteor/meteor';
+import { _ } from 'meteor/underscore';
+
 
 if (Meteor.isServer) {
 
@@ -19,7 +21,8 @@ if (Meteor.isServer) {
         'ipintel': ipintel,
         'verisstats': verisstats,
         'logincounts': logincounts,
-        'getplugins': getplugins
+        'getplugins': getplugins,
+        'getserversetting': getserversetting
     });
 
     function saySomething() {
@@ -156,4 +159,12 @@ if (Meteor.isServer) {
         return response
     }
 
+    function getserversetting(settingKey){
+        if ( _.has(mozdef,settingKey) ){
+            return mozdef[settingKey];
+        }else{
+            return '';
+        }
+    }
+
 };

{'commit': "diff --git a/meteor/server/methods.js b/meteor/server/methods.js\nindex c36ae69a..66e4f7cb 100644\n--- a/meteor/server/methods.js\n+++ b/meteor/server/methods.js\n@@ -5,6 +5,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.\n Copyright (c) 2014 Mozilla Corporation\n */\n import { Meteor } from 'meteor/meteor';\n+import { _ } from 'meteor/underscore';\n+\n \n if (Meteor.isServer) {\n \n@@ -19,7 +21,8 @@ if (Meteor.isServer) {\n         'ipintel': ipintel,\n         'verisstats': verisstats,\n         'logincounts': logincounts,\n-        'getplugins': getplugins\n+        'getplugins': getplugins,\n+        'getserversetting': getserversetting\n     });\n \n     function saySomething() {\n@@ -156,4 +159,12 @@ if (Meteor.isServer) {\n         return response\n     }\n \n+    function getserversetting(settingKey){\n+        if ( _.has(mozdef,settingKey) ){\n+            return mozdef[settingKey];\n+        }else{\n+            return '';\n+        }\n+    }\n+\n };\n", 'commit_subject': 'add get server settings function', 'repo_name': 'mozilla/MozDef', 'committer': {'name': 'Jeff Bryner', 'email': 'f3e731dfa293c7a83119d8aacfa41b5d2d780be9@jeffbryner.com', 'time_sec': '1539993177', 'tz_offset': '-420', 'date': {'seconds': '1539993177'}}, 'commit_tree': 'b49172132d9e09fd4b484a532837b2a46b02edd4', 'commit_message': 'add get server settings function\n', 'language_name': 'HTML', 'license': 'mpl-2.0', 'hunks': "@@ -5,6 +5,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.\n Copyright (c) 2014 Mozilla Corporation\n */\n import { Meteor } from 'meteor/meteor';\n+import { _ } from 'meteor/underscore';\n+\n \n if (Meteor.isServer) {\n \n@@ -19,7 +21,8 @@ if (Meteor.isServer) {\n         'ipintel': ipintel,\n         'verisstats': verisstats,\n         'logincounts': logincounts,\n-        'getplugins': getplugins\n+        'getplugins': getplugins,\n+        'getserversetting': getserversetting\n     });\n \n     function saySomething() {\n@@ -156,4 +159,12 @@ if (Meteor.isServer) {\n         return response\n     }\n \n+    function getserversetting(settingKey){\n+        if ( _.has(mozdef,settingKey) ){\n+            return mozdef[settingKey];\n+        }else{\n+            return '';\n+        }\n+    }\n+\n };\n", 'addition_count': 12, 'deletion_count': 1, 'src_file': 'a/meteor/server/methods.js', 'tgt_file': 'b/meteor/server/methods.js', 'file_extension': '.js', 'before_file': '/*\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at https://mozilla.org/MPL/2.0/.\nCopyright (c) 2014 Mozilla Corporation\n*/\nimport { Meteor } from \'meteor/meteor\';\n\nif (Meteor.isServer) {\n\n    //public server-side functions\n    Meteor.methods({\n        \'saySomething\': saySomething,\n        \'loadKibanaDashboards\': loadKibanaDashboards,\n        \'blockip\': blockIP,\n        \'blockfqdn\': blockFQDN,\n        \'watchitem\': watchItem,\n        \'ipwhois\': ipwhois,\n        \'ipintel\': ipintel,\n        \'verisstats\': verisstats,\n        \'logincounts\': logincounts,\n        \'getplugins\': getplugins\n    });\n\n    function saySomething() {\n        //debug function\n        console.log("something is said");\n    }\n\n    function loadKibanaDashboards() {\n        console.log(\'Loading Kibana dashboards... \' + mozdef.rootAPI + \'/kibanadashboards\');\n        var dashboardsRequest = HTTP.get(mozdef.rootAPI + \'/kibanadashboards\');\n\n        if (dashboardsRequest.statusCode==200 && dashboardsRequest.data) {\n            // set the current dashboards in the mongo collection\n            console.log("Updating kibana dashboards...");\n            kibanadashboards.remove({});\n            dashboardsRequest.data.forEach(function(dashboard, index, arr) {\n                kibanadashboards.insert(dashboard);\n            });\n          //console.log(dashboardsRequest.data);\n        } else {\n            console.log("Could not retrieve kibana dashboards... check settings");\n            console.log(mozdef.rootAPI + \'/kibanadashboards\');\n            console.log("returned a " + dashboardsRequest.statusCode);\n            console.log(dashboardsRequest.data);\n        }\n    }\n    function watchItem(formobj) {\n        var watchItemRequest = HTTP.post(mozdef.rootAPI + \'/watchitem\', {data: formobj});\n\n        if (watchItemRequest.statusCode==200) {\n            console.log(JSON.stringify(formobj) + \' successfully sent to \' + mozdef.rootAPI);\n            return true;\n        } else {\n            console.log("Could not send to "+ mozdef.rootAPI + \'/watchitem \' + JSON.stringify(formobj) );\n            return watchItemRequest;\n        }\n}\n\n    function blockIP(formobj) {\n        var blockIPRequest = HTTP.post(mozdef.rootAPI + \'/blockip\', {data: formobj});\n\n        if (blockIPRequest.statusCode==200) {\n            console.log(JSON.stringify(formobj) + \' successfully sent to \' + mozdef.rootAPI);\n            return true;\n        } else {\n            console.log("Could not send to "+ mozdef.rootAPI + \'/blockip \' + JSON.stringify(formobj) );\n            return blockIPRequest;\n        }\n    }\n\n    function blockFQDN(formobj) {\n        try{\n            var blockFQDNRequest = HTTP.post(mozdef.rootAPI + \'/blockfqdn\', {data: formobj});\n\n            if (blockFQDNRequest.statusCode==200) {\n                console.log(JSON.stringify(formobj) + \' successfully sent to \' + mozdef.rootAPI);\n                return true;\n            }\n        }catch (e) {\n            console.log("Error posting to "+ mozdef.rootAPI + \'/blockfqdn \' + JSON.stringify(formobj) );\n            console.log(e)\n            if ( e.response.statusCode == 400 ){\n                // rest API set a reason in content\n                console.log(e.response.content);\n                return e.response.content;\n            }else{\n                return e;\n            }\n        }\n    }\n\n    function ipwhois(ipaddress){\n        //console.log(\'Posting \' + ipaddress + \'to \' + mozdef.rootAPI + \'/ipwhois/\');\n        var ipwhoisResponse = HTTP.post(mozdef.rootAPI + \'/ipwhois/\',{data: {\'ipaddress\':ipaddress}});\n\n        if ( typeof ipwhoisResponse == \'undefined\') {\n            console.log("ipwhois: no response from server")\n            return "";\n        } else {\n            //console.log(ipwhoisResponse);\n            return ipwhoisResponse;\n        }\n    }\n\n    function ipdshield(ipaddress){\n        //console.log(\'Posting \' + ipaddress + \'to \' + mozdef.rootAPI + \'/ipwhois/\');\n        var ipdshieldResponse = HTTP.post(mozdef.rootAPI + \'/ipdshieldquery/\',{data: {\'ipaddress\':ipaddress}});\n\n        if ( typeof ipdshieldResponse == \'undefined\') {\n            console.log("ipdshield: no response from server")\n            return "";\n        } else {\n            //console.log(ipdshieldResponse);\n            return ipdshieldResponse;\n        }\n    }\n\n    function ipsearch(ipaddress){\n        //console.log(\'Posting \' + ipaddress + \'to \' + mozdef.rootAPI + \'/ipwhois/\');\n        var ipsearchResponse = HTTP.post(mozdef.rootAPI + \'/ipsearch/\',{data: {\'ipaddress\':ipaddress}});\n\n        if ( typeof ipsearchResponse == \'undefined\') {\n            console.log("ipsearch: no response from server")\n            return "";\n        } else {\n            //console.log(ipdshieldResponse);\n            return ipsearchResponse;\n        }\n    }\n\n    function verisstats(){\n        //console.log(\'Calling \' + mozdef.rootAPI + \'/veris/\');\n        var verisstatsResponse = HTTP.get(mozdef.rootAPI + \'/veris/\');\n\n        if ( typeof verisstatsResponse == \'undefined\') {\n            console.log("verisstats: no response from server")\n            return "";\n        } else {\n            //console.log(verisstatsResponse);\n            return verisstatsResponse;\n        }\n    }\n\n    function getplugins(endpoint){\n        //console.log(\'Looking up  plugins registered for \' + endpoint + \' from \' + mozdef.rootAPI + \'/plugins/\' + endpoint);\n        if ( typeof endpoint == \'undefined\') {\n            var response = HTTP.get(mozdef.rootAPI + \'/plugins/\');\n\n        } else {\n            var response = HTTP.get(mozdef.rootAPI + \'/plugins/\' + endpoint);\n        }\n        return response\n    }\n        return response\n    }\n\n};\n', 'message': 'add get server settings function\n', 'author_name': 'Jeff Bryner', 'lang': 'js'}