Skip to content

Commit

Permalink
CY-512: Added the dashboard for win cert store addon
Browse files Browse the repository at this point in the history
  • Loading branch information
hardikhdholariya committed Jul 19, 2023
1 parent e9e3b0c commit fbe8b97
Show file tree
Hide file tree
Showing 4 changed files with 290 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ define([
onResultCallBack(resultDataRows)
onErrorCallBack(searchProperties)
*/
this.onResultCallBack = onResultCallBack;
this.onErrorCallBack = onErrorCallBack;
this.onResultCallBack = onResultCallBack;
this.onErrorCallBack = onErrorCallBack;
}

_defineActions(){
_defineActions() {
let _consoleSearchInfo = this.consoleSearchInfo;
let _manager = this.searchManager;
let _onResultCallBack = this.onResultCallBack;
Expand All @@ -33,26 +33,26 @@ define([
this.searchManager.on('search:done', function (properties) {
console.log(`Search query completed. ${_consoleSearchInfo} - searchProperties=${properties}`);

let searchManagerResults = _manager.data("results", {count: 0});
if(('_isFetching' in searchManagerResults && searchManagerResults['_isFetching'] === true) || '_data' in searchManagerResults ){
let searchManagerResults = _manager.data("results", { count: 0 });
if (('_isFetching' in searchManagerResults && searchManagerResults['_isFetching'] === true) || '_data' in searchManagerResults) {
searchManagerResults.on('data', function () {
let resultData = searchManagerResults.data();
console.log(`Search query (${_consoleSearchInfo}) completed with ${resultData.rows.length} number of results.`);
if (_onResultCallBack != undefined){
if (_onResultCallBack != undefined) {
_onResultCallBack(resultData);
}
});
}
else{
if (_onResultCallBack != undefined){
else {
if (_onResultCallBack != undefined) {
_onResultCallBack(null);
}
}
});

function onFailures(properties){
function onFailures(properties) {
console.error(`Unable to execute the search query. ${_consoleSearchInfo} - searchProperties=${properties}`);
if (_onErrorCallBack != undefined){
if (_onErrorCallBack != undefined) {
_onErrorCallBack(properties);
}
}
Expand All @@ -65,7 +65,7 @@ define([
});
}

searchByQuery(searchQuery, earliestTime='-1m', latestTime='now', searchId=undefined, executeNow=true){
searchByQuery(searchQuery, earliestTime = '-1m', latestTime = 'now', searchId = undefined, executeNow = true) {
/*
searchQuery, earliestTime, latestTime - Parameters to define the search (only valid if searchId is not defined)
searchId - define Id of search
Expand All @@ -80,20 +80,20 @@ define([
earliest_time: earliestTime,
latest_time: latestTime
};
if(searchId != undefined){
if (searchId != undefined) {
searchManagerProperties['id'] = searchId;
}

this.searchManager = new SearchManager(searchManagerProperties);

this._defineActions();

if(executeNow){
if (executeNow) {
this.startSearch();
}
}

postProcessSearchByQuery(baseManagerId, searchQuery, searchId=undefined, executeNow=true){
postProcessSearchByQuery(baseManagerId, searchQuery, searchId = undefined, executeNow = true) {
/*
searchQuery - Parameters to define the search (post process search of base search) (only valid if searchId is not defined)
baseManagerId - id of base search
Expand All @@ -108,20 +108,20 @@ define([
autostart: false,
search: searchQuery
};
if(searchId != undefined){
if (searchId != undefined) {
searchManagerProperties['id'] = searchId;
}

this.searchManager = new SearchManager(searchManagerProperties);

this._defineActions();

if(executeNow){
if (executeNow) {
this.startSearch();
}
}

searchById(searchId){
searchById(searchId) {
/*
searchId - Use already defined search
*/
Expand All @@ -131,7 +131,7 @@ define([
this._defineActions();
}

defineReusableSearch(searchId){
defineReusableSearch(searchId) {
this.consoleSearchInfo = `searchId=${searchId}`;

this.searchManager = new SearchManager({
Expand All @@ -143,20 +143,20 @@ define([
this._defineActions();
}

executeReusableSearch(searchQuery, earliestTime='-1m', latestTime='now', executeNow=true){
executeReusableSearch(searchQuery, earliestTime = '-1m', latestTime = 'now', executeNow = true) {
this.searchManager.set(
{
search: searchQuery,
earliest_time: earliestTime,
latest_time: latestTime
}
);
if(executeNow){
if (executeNow) {
this.startSearch();
}
}

defineReusablePostProcessSearch(managerId, searchId){
defineReusablePostProcessSearch(managerId, searchId) {
this.consoleSearchInfo = `searchId=${searchId}`;

this.searchManager = new PostProcessSearchManager({
Expand All @@ -169,24 +169,24 @@ define([
this._defineActions();
}

executeReusablePostProcessSearch(searchQuery, executeNow=true){
executeReusablePostProcessSearch(searchQuery, executeNow = true) {
this.searchManager.set(
{
search: searchQuery
}
);
if(executeNow){
if (executeNow) {
this.startSearch();
}
}

startSearch(){
startSearch() {
console.log("Executing the search query: ", this.consoleSearchInfo);
this.searchManager.startSearch();
}
}

function vWaitUntil(checkCondition, callBackFunction, waitMilliseconds=100) {
function vWaitUntil(checkCondition, callBackFunction, waitMilliseconds = 100) {
function checkFlag() {
if (checkCondition() === false) {
window.setTimeout(checkFlag, waitMilliseconds);
Expand All @@ -199,7 +199,7 @@ define([


class VTokenManager {
constructor(){
constructor() {
this.submittedTokens = mvc.Components.getInstance('submitted');
this.defaultTokens = mvc.Components.getInstance('default');
}
Expand All @@ -224,7 +224,7 @@ define([
this.submittedTokens.set(token_key, token_value);
}

setToken(token_key, token_value){
setToken(token_key, token_value) {
this.setDefaultToken(token_key, token_value);
this.setSubmittedToken(token_key, token_value);
}
Expand All @@ -237,7 +237,7 @@ define([
this.submittedTokens.unset(token_key);
}

unsetToken(token_key){
unsetToken(token_key) {
this.unsetDefaultToken(token_key);
this.unsetSubmittedToken(token_key);
}
Expand All @@ -246,17 +246,24 @@ define([
let VTokenManagerObj = new VTokenManager();


function vSetupMultiSelectInputHandler(instance_id, allOptionValue="*") {
function vSetupMultiSelectInputHandler(instance_id, allOptions = ["*", 'like(Issued_Common_Name, "%")']) {

// Get multiselect
var multi = mvc.Components.get(instance_id);

// On change, check selection
multi.on("change", (selectedValues) => {


for (let i = 0; i < allOptions.length; i++) {
if (selectedValues.includes(allOptions[i])) {
var allOptionValue = allOptions[i]
break;
}
}

if (selectedValues.length > 1 && selectedValues.includes(allOptionValue)) {
var indexOfAll = selectedValues.indexOf(allOptionValue);

// If "ALL" was selected before current (more specific) selection, remove it from list
if (indexOfAll == 0) {
selectedValues.splice(indexOfAll, 1);
Expand Down
1 change: 1 addition & 0 deletions cyences_app_for_splunk/default/data/ui/nav/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<view name="cs_ad_reports" /><!--Windows-->
<view name="cs_windows_reports" /><!--Windows-->
<view name="cs_windows_patch" /><!--Windows-->
<view name="cs_windows_cert_store" /><!--Windows-->
<view name="cs_linux_reports" /><!--Linux-->
<collection label="Cloud Tenancies">
<view name="cs_o365_reports" /><!--Office 365-->
Expand Down
Loading

0 comments on commit fbe8b97

Please sign in to comment.