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

Replace the plugin logging system by the provided by the platform #6161

Merged
merged 21 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
701b9aa
feat(logging): remove plugin logger from start tasks of main plugin
Desvelao Nov 21, 2023
70f02f4
feat(logging): minor fixes to logging messages in the main plugin
Desvelao Nov 21, 2023
c3ba9d1
feat(logging): remove custom logger from endpoints of main plugin
Desvelao Nov 21, 2023
7c34345
fix(logging): remove parameter of addJobToQueue
Desvelao Nov 21, 2023
ff2c07d
feat(core): replace the loggin service and move services to core plugin
Desvelao Nov 28, 2023
283788e
Merge branch 'master' of https://github.com/wazuh/wazuh-kibana-app in…
Desvelao Nov 28, 2023
842b4a3
feat(logging): removed constants related to log files path
Desvelao Nov 28, 2023
dad9274
fix(dependency): removed winston dependency of plugins and update the…
Desvelao Nov 28, 2023
3914913
fix(logging): removed logs.level plugin setting
Desvelao Nov 28, 2023
20ed9bc
fix(logging): fixed monitoring and statistics backend tasks
Desvelao Nov 28, 2023
dba3e2f
Merge branch 'master' of https://github.com/wazuh/wazuh-kibana-app in…
Desvelao Dec 1, 2023
2d0053b
fix(monitoring): manage API host entries
Desvelao Dec 4, 2023
a9de346
feat(core): add description to core services classes
Desvelao Dec 4, 2023
20b0f90
feat(docs): add docs to core plugin
Desvelao Dec 4, 2023
9ca647e
feat(docs): add description to core services
Desvelao Dec 4, 2023
54187b5
test: fix of check updates plugin
Desvelao Dec 5, 2023
efc99e2
test: fix of check updates plugin
Desvelao Dec 5, 2023
d726682
feat(logging): remove the App logs application
Desvelao Dec 11, 2023
ab731fc
Merge branch 'master' into enhancement/6137-adapt-logging-method
Desvelao Dec 11, 2023
f11c6ef
Merge branch 'master' into enhancement/6137-adapt-logging-method
yenienserrano Dec 26, 2023
fb180fb
Fix test
yenienserrano Dec 26, 2023
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
12 changes: 0 additions & 12 deletions plugins/main/common/config-equivalences.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const configEquivalences = {
'wazuh.monitoring.pattern':
'Default index pattern to use for Wazuh monitoring.',
hideManagerAlerts: 'Hide the alerts of the manager in every dashboard.',
'logs.level': 'Logging level of the App.',
'enrollment.dns':
'Specifies the Wazuh registration server, used for the agent enrollment.',
'enrollment.password':
Expand Down Expand Up @@ -85,7 +84,6 @@ export const nameEquivalence = {
'wazuh.monitoring.creation': 'Index creation',
'wazuh.monitoring.pattern': 'Index pattern',
hideManagerAlerts: 'Hide manager alerts',
'logs.level': 'Log level',
'enrollment.dns': 'Enrollment DNS',
'cron.prefix': 'Cron prefix',
'cron.statistics.status': 'Status',
Expand Down Expand Up @@ -142,7 +140,6 @@ export const categoriesEquivalence = {
'wazuh.monitoring.creation': MONITORING,
'wazuh.monitoring.pattern': MONITORING,
hideManagerAlerts: GENERAL,
'logs.level': GENERAL,
'enrollment.dns': GENERAL,
'cron.prefix': GENERAL,
'cron.statistics.status': STATISTICS,
Expand Down Expand Up @@ -197,15 +194,6 @@ export const formEquivalence = {
},
'wazuh.monitoring.pattern': { type: TEXT },
hideManagerAlerts: { type: BOOLEAN },
'logs.level': {
type: LIST,
params: {
options: [
{ text: 'Info', value: 'info' },
{ text: 'Debug', value: 'debug' },
],
},
},
'enrollment.dns': { type: TEXT },
'cron.prefix': { type: TEXT },
'cron.statistics.status': { type: BOOLEAN },
Expand Down
61 changes: 0 additions & 61 deletions plugins/main/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,35 +140,6 @@ export const WAZUH_DATA_CONFIG_REGISTRY_PATH = path.join(
'wazuh-registry.json',
);

// 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_PLAIN_PATH = path.join(
WAZUH_DATA_LOGS_DIRECTORY_PATH,
WAZUH_DATA_LOGS_PLAIN_FILENAME,
);
export const WAZUH_DATA_LOGS_RAW_FILENAME = 'wazuhapp.log';
export const WAZUH_DATA_LOGS_RAW_PATH = path.join(
WAZUH_DATA_LOGS_DIRECTORY_PATH,
WAZUH_DATA_LOGS_RAW_FILENAME,
);

// Wazuh data path - UI logs
export const WAZUH_UI_LOGS_PLAIN_FILENAME = 'wazuh-ui-plain.log';
export const WAZUH_UI_LOGS_RAW_FILENAME = 'wazuh-ui.log';
export const WAZUH_UI_LOGS_PLAIN_PATH = path.join(
WAZUH_DATA_LOGS_DIRECTORY_PATH,
WAZUH_UI_LOGS_PLAIN_FILENAME,
);
export const WAZUH_UI_LOGS_RAW_PATH = path.join(
WAZUH_DATA_LOGS_DIRECTORY_PATH,
WAZUH_UI_LOGS_RAW_FILENAME,
);

// Wazuh data path - downloads
export const WAZUH_DATA_DOWNLOADS_DIRECTORY_PATH = path.join(
WAZUH_DATA_ABSOLUTE_PATH,
Expand Down Expand Up @@ -1506,38 +1477,6 @@ export const PLUGIN_SETTINGS: { [key: string]: TPluginSetting } = {
return schema.boolean();
},
},
'logs.level': {
title: 'Log level',
description: 'Logging level of the App.',
category: SettingCategory.GENERAL,
type: EpluginSettingType.select,
options: {
select: [
{
text: 'Info',
value: 'info',
},
{
text: 'Debug',
value: 'debug',
},
],
},
defaultValue: 'info',
isConfigurableFromFile: true,
isConfigurableFromUI: true,
requiresRestartingPluginPlatform: true,
validate: function (value) {
return SettingsValidator.literal(
this.options.select.map(({ value }) => value),
)(value);
},
validateBackend: function (schema) {
return schema.oneOf(
this.options.select.map(({ value }) => schema.literal(value)),
);
},
},
pattern: {
title: 'Index pattern',
description:
Expand Down
3 changes: 0 additions & 3 deletions plugins/main/common/plugin-settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ describe('[settings] Input validation', () => {
${'ip.ignore'} | ${['test', 'test#']} | ${'It can\'t contain invalid characters: \\, /, ?, ", <, >, |, ,, #.'}
${'ip.selector'} | ${true} | ${undefined}
${'ip.selector'} | ${''} | ${'It should be a boolean. Allowed values: true or false.'}
${'logs.level'} | ${'info'} | ${undefined}
${'logs.level'} | ${'debug'} | ${undefined}
${'logs.level'} | ${''} | ${'Invalid value. Allowed values: info, debug.'}
${'pattern'} | ${'test'} | ${undefined}
${'pattern'} | ${'test*'} | ${undefined}
${'pattern'} | ${''} | ${'Value can not be empty.'}
Expand Down
1 change: 0 additions & 1 deletion plugins/main/common/wazu-menu/wz-menu-settings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export enum WAZUH_MENU_SETTINGS_SECTIONS_CY_TEST_ID {
MODULES = 'menuSettingsModulesLink',
SAMPLE_DATA = 'menuSettingsSampleDataLink',
CONFIGURATION = 'menuSettingsConfigurationLink',
LOGS = 'menuSettingsLogsLink',
MISCELLANEOUS = 'menuSettingsMiscellaneousLink',
ABOUT = 'menuSettingsAboutLink',
}
1 change: 1 addition & 0 deletions plugins/main/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"opensearchDashboardsUtils",
"opensearchDashboardsLegacy",
"wazuhCheckUpdates",
"wazuhCore",
"wazuhEndpoints"
],
"optionalPlugins": [
Expand Down
5 changes: 2 additions & 3 deletions plugins/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
"react-cookie": "^4.0.3",
"read-last-lines": "^1.7.2",
"timsort": "^0.3.0",
"typescript": "^5.0.4",
"winston": "3.9.0"
"typescript": "^5.0.4"
},
"devDependencies": {
"@types/node-cron": "^2.0.3",
Expand All @@ -89,4 +88,4 @@
"redux-mock-store": "^1.5.4",
"swagger-client": "^3.19.11"
}
}
}
11 changes: 6 additions & 5 deletions plugins/main/public/components/security/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Users } from './users/users';
import { Roles } from './roles/roles';
import { Policies } from './policies/policies';
import { GenericRequest } from '../../react-services/generic-request';
import { API_USER_STATUS_RUN_AS } from '../../../server/lib/cache-api-user-has-run-as';
import { AppState } from '../../react-services/app-state';
import { RolesMapping } from './roles-mapping/roles-mapping';
import {
Expand All @@ -30,6 +29,7 @@ import { UI_ERROR_SEVERITIES } from '../../react-services/error-orchestrator/typ
import { getErrorOrchestrator } from '../../react-services/common-services';
import { getPluginDataPath } from '../../../common/plugin';
import { security } from '../../utils/applications';
import { getWazuhCorePlugin } from '../../kibana-services';

const tabs = [
{
Expand Down Expand Up @@ -128,16 +128,16 @@ export const WzSecurity = compose(
const isNotRunAs = allowRunAs => {
let runAsWarningTxt = '';
switch (allowRunAs) {
case API_USER_STATUS_RUN_AS.HOST_DISABLED:
case getWazuhCorePlugin().API_USER_STATUS_RUN_AS.HOST_DISABLED:
runAsWarningTxt = `For the role mapping to take effect, enable run_as in ${getPluginDataPath(
'config/wazuh.yml',
)} configuration file, restart the ${PLUGIN_PLATFORM_NAME} service and clear your browser cache and cookies.`;
break;
case API_USER_STATUS_RUN_AS.USER_NOT_ALLOWED:
case getWazuhCorePlugin().API_USER_STATUS_RUN_AS.USER_NOT_ALLOWED:
runAsWarningTxt =
'The role mapping has no effect because the current Wazuh API user has allow_run_as disabled.';
break;
case API_USER_STATUS_RUN_AS.ALL_DISABLED:
case getWazuhCorePlugin().API_USER_STATUS_RUN_AS.ALL_DISABLED:
runAsWarningTxt = `For the role mapping to take effect, enable run_as in ${getPluginDataPath(
'config/wazuh.yml',
)} configuration file and set the current Wazuh API user allow_run_as to true. Restart the ${PLUGIN_PLATFORM_NAME} service and clear your browser cache and cookies.`;
Expand Down Expand Up @@ -174,7 +174,8 @@ export const WzSecurity = compose(
{selectedTabId === 'roleMapping' && (
<>
{allowRunAs !== undefined &&
allowRunAs !== API_USER_STATUS_RUN_AS.ENABLED &&
allowRunAs !==
getWazuhCorePlugin().API_USER_STATUS_RUN_AS.ENABLED &&
isNotRunAs(allowRunAs)}
<RolesMapping></RolesMapping>
</>
Expand Down
Loading
Loading