Open atownson opened 3 weeks ago
The same is true for showPassword()
function showPassword(row) {
var dfd = $.Deferred();
var splunkJsComponent = mvc.Components.getInstance("passwordSearch");
if(splunkJsComponent) {
splunkJsComponent.dispose();
}
var passwordSearch = new SearchManager({
"id": "passwordSearch",
"cancelOnUnload": true,
"status_buckets": 0,
"earliest_time": "-24h@h",
"latest_time": "now",
"sample_ratio": 1,
"search": "| rest /servicesNS/-/-/storage/passwords splunk_server=local \
| search title=" + row.realm + ":" + row.username + ": \
| table clear_password",
"app": utils.getCurrentApp(),
"auto_cancel": 90,
"preview": true,
"tokenDependencies": {
},
"runWhenTimeIsUndefined": false
}, {tokens: true, tokenNamespace: "submitted"});
var myResults = passwordSearch.data('results', { output_mode:'json', count:0 });
myResults.on("data", function() {
var data = myResults.data().results;
if (data === undefined || data.length == 0)
{
return renderModal("password-not-found",
"Not Found",
"<div class=\"alert alert-warning\"><i class=\"icon-alert\"></i>No password found. Verify <b>list_storage_passwords</b> capability role is enabled.</div>",
"Close");
}
else {
dfd.resolve(renderModal("show-password",
"Password",
"<h3>" + data[0].clear_password + "</h3>",
"Close"));
}
});
return dfd.promise();
}
In our Splunk environment, we're seeing an issue where the Credential Management table will populate and then the content will be removed a fraction of a second later. I took a look at the code a found the problematic blocks in the
populateTable()
function. The search is stored as two different variables,search1
andmainSearch
, both with their event handlers creating a race condition. This update topopulateTable()
removes the second reference to the search and fixes the issue: