Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor search handler events refactor #1327

Merged
merged 10 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to the Wazuh app for Splunk project will be documented in th

## Wazuh v4.3.4 - Splunk Enterprise v8.1.[1-10], v8.2.x - Revision 4307

### Changed
- Improved Splunk search-handler event management to avoid forwarder toast error mis-interpretation. [#1327](https://github.com/wazuh/wazuh-splunk/pull/1327)

### Fixed
- Fixed unhandled expired session when requesting Splunk DB documents. [#1329](https://github.com/wazuh/wazuh-splunk/pull/1329)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@
<p>Most active agent</p>
</div>
<p
ng-if="lastAgent && lastAgent.id && mostActiveAgent.id !== '000'"
ng-if="lastAgent && lastAgent.id && mostActiveAgent.id !== '000' && mostActiveAgent"
ng-click="showAgent(mostActiveAgent)"
class="euiTitle euiTitle--small euiStat__title wz-text-link cursor-pointer">
{{mostActiveAgent}}
</p>
<p
ng-if="!lastAgent || !lastAgent.id"
ng-if="!lastAgent || !lastAgent.id || !mostActiveAgent"
class="euiTitle euiTitle--small euiStat__title">
-
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ define([
$urlTokenModel,
$notificationService
)

const DEFAULT_METRIC_VALUES = '-'
this.scope.newFiles = DEFAULT_METRIC_VALUES
this.scope.readFiles = DEFAULT_METRIC_VALUES
this.scope.filesModifiedToken = DEFAULT_METRIC_VALUES
this.scope.filesDeleted = DEFAULT_METRIC_VALUES

this.scope.reportingEnabled = reportingEnabled
this.scope.extensions = extensions
this.agent = agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ define([
this.state.go('overview')
}

const DEFAULT_KPI_VALUE = '-'
this.scope.lastNotChecked = DEFAULT_KPI_VALUE
this.scope.lastPass = DEFAULT_KPI_VALUE
this.scope.lastScanScore = DEFAULT_KPI_VALUE
this.scope.lastScanDate = DEFAULT_KPI_VALUE
this.scope.lastErrors = DEFAULT_KPI_VALUE
this.scope.lastFails = DEFAULT_KPI_VALUE
this.scope.lastUnknown = DEFAULT_KPI_VALUE
this.scope.lastScanBenchmark = DEFAULT_KPI_VALUE

this.scope.reportingEnabled = reportingEnabled
this.scope.extensions = extensions
this.agent = agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ define([
$urlTokenModel,
$notificationService
)

const DEFAULT_METRIC_VALUES = '-'
this.scope.totalAlerts = DEFAULT_METRIC_VALUES
this.scope.levelTwelve = DEFAULT_METRIC_VALUES
this.scope.authFailure = DEFAULT_METRIC_VALUES
this.scope.authSuccess = DEFAULT_METRIC_VALUES

this.scope.reportingEnabled = reportingEnabled
this.requestService = $requestService
this.notification = $notificationService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ define([
$urlTokenModel,
$notificationService
)

const DEFAULT_METRIC_VALUES = '0'
this.scope.scapLastScore = DEFAULT_METRIC_VALUES
this.scope.scapHighestScore = DEFAULT_METRIC_VALUES
this.scope.scapLowestScore = DEFAULT_METRIC_VALUES

this.scope.reportingEnabled = reportingEnabled
this.scope.extensions = extensions
this.agent = agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ define([
$urlTokenModel,
$notificationService
)

const DEFAULT_METRIC_VALUES = '-'
this.scope.criticalSeverity = DEFAULT_METRIC_VALUES
this.scope.highSeverity = DEFAULT_METRIC_VALUES
this.scope.mediumSeverity = DEFAULT_METRIC_VALUES
this.scope.lowSeverity = DEFAULT_METRIC_VALUES

this.scope.reportingEnabled = reportingEnabled
this.scope.extensions = extensions
this.currentDataService.addFilter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ define([
$urlTokenModel,
$notificationService
)

const DEFAULT_METRIC_VALUES = '-'
this.scope.newFiles = DEFAULT_METRIC_VALUES
this.scope.readFiles = DEFAULT_METRIC_VALUES
this.scope.filesModifiedToken = DEFAULT_METRIC_VALUES
this.scope.filesDeleted = DEFAULT_METRIC_VALUES

this.notification = $notificationService
this.scope.reportingEnabled = reportingEnabled
this.scope.extensions = extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ define([
$urlTokenModel,
$notificationService
)

const DEFAULT_KPI_VALUE = '-'
this.scope.lastNotChecked = DEFAULT_KPI_VALUE
this.scope.lastPass = DEFAULT_KPI_VALUE
this.scope.lastScanScore = DEFAULT_KPI_VALUE
this.scope.lastScanDate = DEFAULT_KPI_VALUE
this.scope.lastErrors = DEFAULT_KPI_VALUE
this.scope.lastFails = DEFAULT_KPI_VALUE
this.scope.lastUnknown = DEFAULT_KPI_VALUE
this.scope.lastScanBenchmark = DEFAULT_KPI_VALUE

this.scope.reportingEnabled = reportingEnabled
this.scope.extensions = extensions
this.addFilter = $currentDataService.addFilter
Expand Down Expand Up @@ -178,6 +189,16 @@ define([
*/
$onInit() {
try {
const DEFAULT_KPI_VALUE = '-'
this.scope.lastNotChecked = DEFAULT_KPI_VALUE
this.scope.lastPass = DEFAULT_KPI_VALUE
this.scope.lastScanScore = DEFAULT_KPI_VALUE
this.scope.lastScanDate = DEFAULT_KPI_VALUE
this.scope.lastErrors = DEFAULT_KPI_VALUE
this.scope.lastFails = DEFAULT_KPI_VALUE
this.scope.lastUnknown = DEFAULT_KPI_VALUE
this.scope.lastScanBenchmark = DEFAULT_KPI_VALUE

this.addFilter(`{"rule.groups{}":"ciscat", "implicit":true}`)
/**
* Generates report
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ define([
$notificationService
)
this.rootScope = $rootScope

const DEFAULT_METRIC_VALUES = '-'
this.scope.totalAlerts = DEFAULT_METRIC_VALUES
this.scope.levelTwelve = DEFAULT_METRIC_VALUES
this.scope.authFailure = DEFAULT_METRIC_VALUES
this.scope.authSuccess = DEFAULT_METRIC_VALUES

this.scope.reportingEnabled = reportingEnabled
this.scope.awsExtensionEnabled = awsExtensionEnabled
this.apiReq = $requestService.apiReq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ define([
$urlTokenModel,
$notificationService
)

const DEFAULT_METRIC_VALUES = '0'
this.scope.scapLastScore = DEFAULT_METRIC_VALUES
this.scope.scapHighestScore = DEFAULT_METRIC_VALUES
this.scope.scapLowestScore = DEFAULT_METRIC_VALUES

this.notification = $notificationService
this.scope.reportingEnabled = reportingEnabled
this.scope.extensions = extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ define([
$urlTokenModel,
$notificationService
)

const DEFAULT_METRIC_VALUES = '-'
this.scope.criticalSeverity = DEFAULT_METRIC_VALUES
this.scope.highSeverity = DEFAULT_METRIC_VALUES
this.scope.mediumSeverity = DEFAULT_METRIC_VALUES
this.scope.lowSeverity = DEFAULT_METRIC_VALUES

this.scope.reportingEnabled = reportingEnabled
this.scope.extensions = extensions
this.currentDataService.addFilter(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const UI_METADATA = {
"version": "4.3.4",
"revision": "4307"
"version": "4.3.3",
"revision": "4306"
}

define(['../module'], function (module) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ define(['splunkjs/mvc/simplexml/searcheventhandler', '../viz/viz'], function (
) {
'use strict'

const FORWARDER_ERROR =
'Unable to retrieve results. It may be due to a connection problem with the Splunk forwarder,\nplease try restarting this service.'
const FORWARDER_ERROR = `Unable to retrieve results.\n
It may be due to a connection problem with the Splunk forwarder,\nplease try restarting this service.`

return class SearchHandler extends Viz {
/**
Expand Down Expand Up @@ -61,7 +61,7 @@ define(['splunkjs/mvc/simplexml/searcheventhandler', '../viz/viz'], function (
})

this.getSearch().on('search:error', (error) => {
console.error(error)
console.error('search:error', error)
})

this.getSearch().on('search:progress', () => {
Expand All @@ -74,35 +74,26 @@ define(['splunkjs/mvc/simplexml/searcheventhandler', '../viz/viz'], function (
if (this.loading) {
this.scope[this.loadingBindedValue] = false
}
const result = this.submittedTokenModel.get(this.token)
if (
result &&
result !== value &&
typeof result !== 'undefined' &&
result !== 'undefined'
) {
this.scope[bindedValue] = result
} else {
this.scope[bindedValue] = '0'
this.notification && this.notification.showErrorToast(FORWARDER_ERROR)
}
this.scope.$applyAsync()
})

this.submittedTokenModel.on(`change:${this.token}`, () => {
const loadedTokenJS = this.submittedTokenModel.get(this.token)
if (
loadedTokenJS &&
loadedTokenJS !== value &&
typeof loadedTokenJS !== 'undefined' &&
loadedTokenJS !== 'undefined'
) {
this.scope[bindedValue] = loadedTokenJS
} else {
this.scope[bindedValue] = '0'
this.notification && this.notification.showErrorToast(FORWARDER_ERROR)
}
this.scope.$applyAsync()

// More info in:
// https://docs.splunk.com/DocumentationStatic/WebFramework/1.5/compref_splunkresultsmodel.html#top
const resultModel = this.search.data('results')
resultModel.on('data', (data) => {
try {
if (data.hasData()) {
const result = this.submittedTokenModel.get(this.token)
this.scope[bindedValue] = result
this.scope.$applyAsync()
}
} catch (err) {
console.error('Error fetching table data ', err)
}
})
resultModel.on('error', (err) => {
console.error('Search Handler - onError: ', err)
})
if (!this.search.query?.changed?.data?.resultCount)
this.notification && this.notification.showWarningToast(FORWARDER_ERROR)
})

this.initSearch()
Expand Down
2 changes: 1 addition & 1 deletion SplunkAppForWazuh/default/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ is_visible = 1
label = Wazuh

[launcher]
version = 4.3.4
version = 4.3.3
author = [email protected]
description = Wazuh helps you to gain deeper security visibility into your infrastructure by monitoring hosts at an operating system and application level.

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"pretty": "prettier --config .prettierrc --write SplunkAppForWazuh/**/*.js SplunkAppForWazuh/**/*.html SplunkAppForWazuh/**/*.css !SplunkAppForWazuh/appserver/static/js/libs/** !SplunkAppForWazuh/appserver/static/js/utils/codemirror/**",
"test": "mocha tests/manager.js"
},
"version": "4.3.4",
"revision": "4307",
"version": "4.3.3",
"revision": "4306",
"splunk": "8.2.6"
}