// init var localStoragePreface = "sse" window.diagObject = [] // generateDiag.js content moved over to dashboard.js /* // removing console redirection, because it breaks IE 11 var console = window.console function intercept(method) { var original = console[method] console[method] = function() { window.diagObject.push(arguments); if (original.apply) { // Do this for normal browsers original.apply(console, arguments); } else { // Do this for IE var message = Array.prototype.slice.apply(arguments).join(' '); original(message); } } } var methods = ['log', 'warn', 'error']; for (var i = 0; i < methods.length; i++) { intercept(methods[i]); } */ function collectDiag() { require([ "jquery", Splunk.util.make_full_url( "/static/app/Splunk_Security_Essentials/vendor/jszip/jszip.js" ), Splunk.util.make_full_url( "/static/app/Splunk_Security_Essentials/vendor/FileSaver/FileSaver.js" ), ], function ($, JSZip) { //console.log("JSZip Loaded", JSZip) var zip = new JSZip() var browserInfo = new Object() browserInfo.ua = navigator.userAgent browserInfo.url = window.location.href browserInfo.cookies = document.cookie browserInfo.lang = navigator.language var searchManagers = new Object() for (var attribute in splunkjs.mvc.Components.attributes) { var sm = splunkjs.mvc.Components.getInstance(attribute) if (typeof sm != "undefined" && sm != null) { if (typeof sm.search != "undefined") { searchManagers[attribute] = new Object() searchManagers[attribute]["name"] = attribute searchManagers[attribute]["lastError"] = sm.lastError searchManagers[attribute]["attributes"] = sm.search.attributes } } } var local_configuration = window.$C var folder1 = zip.folder("diag-output-from-Splunk-Essentials") //folder1.file("console_log.json", JSON.stringify(window.diagObject, null, 4)); folder1.file("browser_info.json", JSON.stringify(browserInfo, null, 4)) folder1.file( "search_managers.json", JSON.stringify(searchManagers, null, 4) ) folder1.file("localStorage.json", JSON.stringify(localStorage, null, 4)) folder1.file( "configuration.json", JSON.stringify(local_configuration, null, 4) ) folder1.file( "tokens.json", JSON.stringify( splunkjs.mvc.Components.getInstance("submitted").attributes, null, 4 ) ) zip.generateAsync({ type: "blob" }).then(function (content) { // see FileSaver.js saveAs(content, "diag-output-from-Splunk-Essentials.zip") }) }) } var mylink = $('Generate Essentials-only Diag').click( function () { collectDiag() return false } ) $('div[data-view="views/shared/splunkbar/help/Master"]') .find("ul") .append($("
").append(mylink)) function updateShowcaseInfo() { $.ajax({ url: $C["SPLUNKD_PATH"] + "/services/updateShowcaseinfo", async: true, success: function (updateShowcaseinfo) { //console.log("Success",updateShowcaseinfo) //This will update the Configuration menu entry to green and tell the user to reload $("#launchConfigurationLink .updatestatusicon").attr( "class", "updatestatusicon icon-rotate" ) $("#launchConfigurationLink") .attr("data-placement", "bottom") .css("background-color", "#00950E") .css("color", "white") .attr("data-status", "elementUpdated") .attr( "data-original-title", "Update Available for Security Content" ) .unbind("click") .click(function () { location.reload() }) }, error: function (xhr, textStatus, error) { //console.log("Update of showcaseinfo failed",xhr, textStatus, error) }, }) } function updateMitreMatrixList(version) { //Check if search manager has already been created if ( typeof splunkjs.mvc.Components.getInstance( "updateMitreMatrixList_" + version ) == "undefined" ) { require(["splunkjs/mvc/utils", "splunkjs/mvc/searchmanager"], function ( utils, SearchManager ) { var search = '| union [| mitremap output="list" refresh_cache="true" | outputlookup mitre_enterprise_list] [| savedsearch "Generate MITRE Data Source Lookup"] [| savedsearch "Generate MITRE Detections Lookup"] [| savedsearch "Generate MITRE Threat Group Lookup"]' new SearchManager( { id: "updateMitreMatrixList_" + version, latest_time: "0", autostart: true, earliest_time: "now", search: search, app: utils.getCurrentApp(), auto_cancel: 90, }, { tokens: false } ) //console.log("Updated updateMitreMatrixList", SearchManager); }) } } function getFormKey() { const prefix = `splunkweb_csrf_token_${window.$C.MRSPARKLE_PORT_NUMBER}=` if (document.cookie) { for (const chunk of document.cookie.split(";")) { const cookie = String(chunk).trim() if (cookie.startsWith(prefix)) { return decodeURIComponent(cookie.slice(prefix.length)) } } } } window.getFormKey = getFormKey function addKnowledgeObject(obj) { let buttonId = "#add-" + obj.objectType + "-" + obj.name.split("(")[0] $.ajax({ url: $C["SPLUNKD_PATH"] + "/services/addKnowledgeObject?time=" + Date.now(), async: true, type: "POST", headers: { "X-Requested-With": "XMLHttpRequest", "X-Splunk-Form-Key": window.getFormKey(), }, contentType: "application/json", data: JSON.stringify(obj), success: function (addKnowledgeObject) { let prereqNum = $(buttonId) .closest("tr") .children("td") .eq(1) .attr("id") .split("data_check_test")[1] let searchManagerId = "data_check_search" + prereqNum if (obj.objectType == "macro") { $(buttonId).removeAttr("disabled") $(buttonId).text("Edit Macro") $(buttonId).addClass("external") $(buttonId).prop("title", "Click to Edit Macro") $(buttonId).on("click", function () { if ( typeof obj.arguments != "undefined" && obj.arguments != "" ) { obj.name += "(" + obj.arguments.length + ")" } var edit_macro_link_url = "/manager/Splunk_Security_Essentials/admin/macros/" + obj.name + "?action=edit" //Link format changed in 8.2 if ( parseInt(localStorage["splunk-major-version"]) > 8 || (parseInt(localStorage["splunk-major-version"]) == 8 && parseInt(localStorage["splunk-minor-version"]) == 2) ) { edit_macro_link_url = "/manager/Splunk_Security_Essentials/data/macros/" + obj.name + "?action=edit" } window.open(edit_macro_link_url, "_blank") }) } else { $(buttonId).hide() } document.getElementById("data_check_test" + prereqNum).innerHTML = '").text(textStatus) ) } else { myModal.body.append($("