-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create plugin wazuh check updates (#5897)
* Add wazuh_check_updates plugin Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Manage saved object for plugin configurations Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * New componente UpToDateStatus and improvements Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Current update component and improvements Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * CurrentUpdateDetails improvements and others Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Improvements with unit tests Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Complete public unit tests Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Unit test updatesNotification component Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Backend unit tests Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Add current update details to currentUpdateDetails component Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Add translation to show details message Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Add DismissNotificationCheck component Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Modify styles Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Expose new component Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Update DismissNotificationCheck component Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Add getCurrentUser implementation Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Fix plugin start types Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Fix checks ids Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Delete console.log in component Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Fixes in PR Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Modify README Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Delete unused files Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Delete commented code Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Removing unnecessary packages Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Clear available updates value on error Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Change constant name Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Change message on new update Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Change camelCase to kebab-case Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Change plugin name using kebab-case Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Add useEffect to component UpToDateStatus Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Improve return errors in routes Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Show update description in lines Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Add Logger Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Improve constant name Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Improve check texts and links icons Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Fix if statements Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Change folder name in dev.yml using kebab-case Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Update test snapshots Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Add I18nProvider wrapper to components Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Unit test for routes and kebab case fixes Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Add toast when on get updates error Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Omit username property on GET user preferences Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Improve try catch finally Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Add mock html_id_generator to component unit tests Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Fix unit test get-user-preferences Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Fix route unit tests port by adding a random port Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Improved user preferences saved object Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Fix toast message Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> * Change port in route unit tests Signed-off-by: Luciano Gorza <lucianogorza@gmail.com> --------- Signed-off-by: Luciano Gorza <lucianogorza@gmail.com>
- Loading branch information
1 parent
0da782f
commit 20e61a7
Showing
84 changed files
with
4,360 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"prefix": "wazuhCheckUpdates", | ||
"paths": { | ||
"wazuhCheckUpdates": "." | ||
}, | ||
"translations": ["translations/en-US.json"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Wazuh Check Updates Plugin | ||
|
||
The **Wazuh Check Updates Plugin** is a extension for Wazuh that allows you to seamlessly query an external service to retrieve information about the latest available updates and their corresponding features. This dedicated plugin has been designed to work in conjunction with the primary Wazuh plugin, enhancing its capabilities to notify users whenever new updates become accessible. With a focus on modularity, the Check Updates Plugin provides various components to manage updates and notification preferences. | ||
|
||
## Features | ||
|
||
### 1. Notification of New Updates | ||
|
||
The core functionality of the plugin is to notify users about the availability of new updates. It continuously queries an external service to check for updates and sends notifications to users when new updates are detected. | ||
|
||
### 2. Deployment Status | ||
|
||
Stay informed about the deployment status of updates. The plugin offers a component that allows you to easily view the status of updates. | ||
|
||
### 3. Update Details | ||
|
||
Get detailed information about the latest update, including links to release notes and updagrade guide, as well as the update description. | ||
|
||
## Software and libraries used | ||
|
||
- [OpenSearch](https://opensearch.org/) | ||
- [Elastic UI Framework](https://eui.elastic.co/) | ||
- [Node.js](https://nodejs.org) | ||
- [React](https://reactjs.org) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import path from 'path'; | ||
|
||
export const PLUGIN_ID = 'wazuhCheckUpdates'; | ||
export const PLUGIN_NAME = 'wazuh_check_updates'; | ||
|
||
export const SAVED_OBJECT_UPDATES = 'wazuh-check-updates-available-updates'; | ||
export const SAVED_OBJECT_SETTINGS = 'wazuh-check-updates-settings'; | ||
export const SAVED_OBJECT_USER_PREFERENCES = 'wazuh-check-updates-user-preferences'; | ||
|
||
export const DEFAULT_SCHEDULE = '* */12 * * *'; | ||
|
||
export enum routes { | ||
checkUpdates = '/api/wazuh-check-updates/updates', | ||
userPreferences = '/api/wazuh-check-updates/user-preferences', | ||
} | ||
|
||
// Security | ||
export const WAZUH_SECURITY_PLUGIN_OPENSEARCH_DASHBOARDS_SECURITY = | ||
'OpenSearch Dashboards Security'; | ||
|
||
// Default Elasticsearch user name context | ||
export const ELASTIC_NAME = 'elastic'; | ||
|
||
// Wazuh data path | ||
const WAZUH_DATA_PLUGIN_PLATFORM_BASE_PATH = 'data'; | ||
export const WAZUH_DATA_PLUGIN_PLATFORM_BASE_ABSOLUTE_PATH = path.join( | ||
__dirname, | ||
'../../../', | ||
WAZUH_DATA_PLUGIN_PLATFORM_BASE_PATH | ||
); | ||
export const WAZUH_DATA_ABSOLUTE_PATH = path.join( | ||
WAZUH_DATA_PLUGIN_PLATFORM_BASE_ABSOLUTE_PATH, | ||
'wazuh' | ||
); | ||
|
||
// Wazuh data path - config | ||
export const WAZUH_DATA_CONFIG_DIRECTORY_PATH = path.join(WAZUH_DATA_ABSOLUTE_PATH, 'config'); | ||
export const WAZUH_DATA_CONFIG_APP_PATH = path.join(WAZUH_DATA_CONFIG_DIRECTORY_PATH, 'wazuh.yml'); | ||
|
||
// Wazuh data path - logs | ||
export const MAX_MB_LOG_FILES = 100; | ||
export const WAZUH_DATA_LOGS_DIRECTORY_PATH = path.join(WAZUH_DATA_ABSOLUTE_PATH, 'logs'); | ||
export const WAZUH_DATA_LOGS_PLAIN_FILENAME = 'wazuhapp-plain.log'; | ||
export const WAZUH_DATA_LOGS_RAW_FILENAME = 'wazuhapp.log'; | ||
|
||
// App configuration | ||
export const WAZUH_CONFIGURATION_CACHE_TIME = 10000; // time in ms; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export interface AvailableUpdates { | ||
mayor: Update[]; | ||
minor: Update[]; | ||
patch: Update[]; | ||
last_check?: Date | string | undefined; | ||
} | ||
|
||
export interface Update { | ||
description: string; | ||
published_date: string; | ||
semver: { | ||
mayor: number; | ||
minor: number; | ||
patch: number; | ||
}; | ||
tag: string; | ||
title: string; | ||
} | ||
|
||
export interface UserPreferences { | ||
last_dismissed_update?: string; | ||
hide_update_notifications?: boolean; | ||
} | ||
|
||
export interface CheckUpdatesSettings { | ||
schedule?: string; | ||
} | ||
|
||
export type savedObjectType = AvailableUpdates | UserPreferences | CheckUpdatesSettings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"id": "wazuhCheckUpdates", | ||
"version": "1.0.0", | ||
"opensearchDashboardsVersion": "opensearchDashboards", | ||
"server": true, | ||
"ui": true, | ||
"requiredPlugins": ["navigation", "opensearchDashboardsUtils"], | ||
"optionalPlugins": ["securityDashboards"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "wazuh-check-updates", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "yarn plugin-helpers build", | ||
"plugin-helpers": "node ../../scripts/plugin_helpers", | ||
"osd": "node ../../scripts/osd", | ||
"test:ui:runner": "node ../../scripts/functional_test_runner.js", | ||
"test:server": "plugin-helpers test:server", | ||
"test:browser": "plugin-helpers test:browser", | ||
"test:jest": "node scripts/jest", | ||
"test:jest:runner": "node scripts/runner test" | ||
}, | ||
"dependencies": { | ||
"axios": "^1.5.0", | ||
"axios-mock-adapter": "^1.21.5", | ||
"md5": "^2.3.0", | ||
"node-cron": "^3.0.2", | ||
"winston": "^3.10.0" | ||
}, | ||
"devDependencies": { | ||
"@testing-library/user-event": "^14.5.0", | ||
"@types/": "testing-library/user-event", | ||
"@types/md5": "^2.3.2", | ||
"@types/node-cron": "^3.0.8" | ||
} | ||
} |
Oops, something went wrong.