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

Add initialization service #7145

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7f186d6
feat(initialization): add initialization service
Desvelao Nov 8, 2024
710774b
fix: call method of saved object service
Desvelao Nov 8, 2024
5f94e00
chore: remove console.log
Desvelao Nov 8, 2024
f76784a
feat(initialization): add API endpoints to manage the initialization …
Desvelao Nov 11, 2024
11e40e9
feat(initialization): enhance documentation
Desvelao Nov 11, 2024
c5aaf7c
feat(initialization): add tests
Desvelao Nov 12, 2024
4c0a863
feat(initialization): enhance task related to check connection and co…
Desvelao Nov 12, 2024
d5b0b9f
fix(initialization): minor fixes in tasks
Desvelao Nov 12, 2024
1b052be
feat(initialization): add default fields for vulnerability-states ind…
Desvelao Nov 12, 2024
2777291
Merge branch 'master' of https://github.com/wazuh/wazuh-kibana-app in…
Desvelao Nov 12, 2024
168c4d7
Merge branch 'master' into enhancement/7133-add-initialization-service
asteriscos Nov 21, 2024
fb4eb7f
fix: import statement related to specific function instead of all module
Desvelao Nov 22, 2024
5920547
Apply suggestions from code review
Desvelao Nov 22, 2024
a68e03d
fix: rename setting
Desvelao Nov 22, 2024
409115f
fix(initialization): apply review suggestions related to creation of …
Desvelao Nov 25, 2024
d123f31
fix(initialization): move InitializationTask class to another file
Desvelao Nov 25, 2024
5e03e8b
fix(initialization): add types
Desvelao Nov 26, 2024
d194092
fix(initialization): typo
Desvelao Nov 26, 2024
fdc987c
fix(initialization): move temporal registration to core plugin
Desvelao Nov 26, 2024
e3b1cc4
fix(initialization): add missing default index pattern fields for alerts
Desvelao Nov 26, 2024
90c99aa
fix(initialization): enhance types and rename error variable
Desvelao Nov 26, 2024
83ea856
fix(initialization): variable name in test
Desvelao Nov 26, 2024
92f6d0c
fix(initialization): enhance types and rename error variable
Desvelao Nov 26, 2024
fa3b79a
fix(initialization): enhance types
Desvelao Nov 26, 2024
b27efff
Merge branch 'master' of https://github.com/wazuh/wazuh-kibana-app in…
Desvelao Nov 26, 2024
0fbe92a
fix(prettier): initalization task
Desvelao Nov 26, 2024
bff0b53
chore(changelog): add entry
Desvelao Nov 27, 2024
c01b2aa
Update plugins/wazuh-core/common/services/initialization/constants.ts
Desvelao Nov 28, 2024
1df7f7a
Update plugins/wazuh-core/common/services/initialization/types.ts
Desvelao Nov 28, 2024
b993f59
fix(initialization): adapt initialization task to new constants
Desvelao Nov 29, 2024
2f3af97
Merge branch 'master' of https://github.com/wazuh/wazuh-kibana-app in…
Desvelao Nov 29, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to the Wazuh app project will be documented in this file.

- Support for Wazuh 5.0.0
- Added creation of report definition when creating dashboard by reference and the button to reset the report [#7091](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7091)
- Added an initilization service to core plugin to run the initilization tasks related to user scope [#7145](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7145)

### Removed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';

Check failure on line 1 in plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

Definition for rule 'import/order' was not found

Check failure on line 1 in plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

Definition for rule 'import/no-duplicates' was not found

Check failure on line 1 in plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

Import name `React` must match one of the following formats: camelCase
import { compose } from 'redux';
import { connect } from 'react-redux';
import { withGuardAsync } from '../../../../common/hocs';
Expand All @@ -9,7 +9,7 @@
import { webDocumentationLink } from '../../../../../../common/services/web_documentation';
import { vulnerabilityDetection } from '../../../../../utils/applications';
import { LoadingSpinnerDataSource } from '../../../../common/loading/loading-spinner-data-source';
import NavigationService from '../../../../../react-services/navigation-service';

Check failure on line 12 in plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

Import name `NavigationService` must match one of the following formats: camelCase

const INDEX_PATTERN_CREATION_NO_INDEX = 'INDEX_PATTERN_CREATION_NO_INDEX';

Expand All @@ -20,15 +20,15 @@
async function checkExistenceIndices(indexPatternId: string) {
try {
const fields = await SavedObject.getIndicesFields(indexPatternId);
return { exist: true, fields };

Check failure on line 23 in plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

Expected blank line before this statement
} catch (error) {

Check failure on line 24 in plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

Remove unused catch binding `error`

Check failure on line 24 in plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

'error' is defined but never used
return { exist: false };
}
}

async function createIndexPattern(indexPattern, fields: any) {
try {
await SavedObject.createSavedObjectIndexPattern(
await SavedObject.createSavedObject(
'index-pattern',
indexPattern,
{
Expand All @@ -51,7 +51,7 @@
try {
// Check the existence of related index pattern
const existIndexPattern = await checkExistenceIndexPattern(indexPatternID);
let indexPattern = existIndexPattern;

Check failure on line 54 in plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

'indexPattern' is never reassigned. Use 'const' instead

// If the idnex pattern does not exist, then check the existence of index
if (existIndexPattern?.error?.statusCode === 404) {
Expand All @@ -71,11 +71,11 @@
};
}
// If the some index match the index pattern, then create the index pattern
const resultCreateIndexPattern = await createIndexPattern(

Check failure on line 74 in plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

Expected blank line before this statement
indexPatternID,
fields,
);
if (resultCreateIndexPattern?.error) {

Check failure on line 78 in plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

Expected blank line before this statement
return {
ok: true,
data: {
Expand Down
16 changes: 16 additions & 0 deletions plugins/wazuh-core/common/services/initialization/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const INITIALIZATION_TASK = {
RUN_STATUS: {
NOT_STARTED: 'not_started',
RUNNING: 'running',
FINISHED: 'finished',
},
RUN_RESULT: {
NULL: null,
SUCCESS: 'success',
FAIL: 'fail',
},
CONTEXT: {
INTERNAL: 'internal',
USER: 'user',
},
} as const;
13 changes: 13 additions & 0 deletions plugins/wazuh-core/common/services/initialization/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { INITIALIZATION_TASK } from './constants';

type RunStatusEnum = (typeof INITIALIZATION_TASK)['RUN_STATUS'];

export type InitializationTaskRunStatus = RunStatusEnum[keyof RunStatusEnum];

type RunResultEnum = (typeof INITIALIZATION_TASK)['RUN_RESULT'];

export type InitializationTaskRunResult = RunResultEnum[keyof RunResultEnum];

type ContextEnum = (typeof INITIALIZATION_TASK)['CONTEXT'];

export type InitializationTaskContext = ContextEnum[keyof ContextEnum];
2 changes: 1 addition & 1 deletion plugins/wazuh-core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export function plugin(initializerContext: PluginInitializerContext) {
return new WazuhCorePlugin(initializerContext);
}

export type { WazuhCorePluginSetup, WazuhCorePluginStart } from './types';
export * from './types';
export type { IConfigurationEnhanced } from './services/enhance-configuration';
Loading
Loading