Skip to content

Commit

Permalink
Merge branch 'master' into fix/3632-refresh-index-pattern-fields-scri…
Browse files Browse the repository at this point in the history
…pted-fields
  • Loading branch information
asteriscos authored Jan 2, 2024
2 parents 5c72cbd + d7ba9d3 commit f6d6551
Show file tree
Hide file tree
Showing 148 changed files with 4,784 additions and 7,012 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ All notable changes to the Wazuh app project will be documented in this file.

- Support for Wazuh 4.9.0
- Added AngularJS dependencies [#6145](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6145)
- Remove embedded discover [#6120](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6120)

### Changed

- Removed embedded discover [#6120](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6120) [#6235](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6235)
- Develop logic of a new index for the fim module [#6227](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6227)
- Allow editing groups for an agent from Endpoints Summary [#6250](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6250)

# Fixed

Expand Down
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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,11 @@ const DocViewer = (props: tDocViewerProps) => {
<EuiFlexItem grow={false}>
<FieldIcon type={fieldType} label={typeName} scripted={scripted} {...fieldIconProps} />
</EuiFlexItem>
<EuiFlexItem className="eui-textTruncate">
<EuiFlexItem>
<EuiToolTip
position="top"
content={displayName}
delay="long"
anchorClassName="eui-textTruncate"
>
<span>{displayName}</span>
</EuiToolTip>
Expand Down
115 changes: 50 additions & 65 deletions plugins/main/public/components/common/permissions/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,83 +10,68 @@
* Find more information about this on the LICENSE file.
*/

import React, { Fragment } from 'react';
import { useUserPermissionsRequirements } from '../hooks/useUserPermissions';
import { useUserRolesRequirements } from '../hooks/useUserRoles';
import React from 'react';

import {
EuiSwitch,
EuiButton,
EuiButtonEmpty,
EuiButtonIcon,
EuiLink,
EuiToolTip,
EuiSpacer
} from '@elastic/eui';

import { WzPermissionsFormatted } from './format';
import { IWzElementPermissionsProps, WzElementPermissions } from './element';

export interface IUserPermissionsObject{action: string, resource: string};
export type TUserPermissionsFunction = (props : any) => TUserPermissions;
export type TUserPermissions = (string | IUserPermissionsObject)[] | null;
export type TUserRoles = string[] | null;
export type TUserRolesFunction = (props : any) => TUserRoles;
interface IWzButtonPermissionsProps
extends Omit<
IWzElementPermissionsProps,
'children' | 'additionalPropsFunction'
> {
buttonType?: 'default' | 'empty' | 'icon' | 'link' | 'switch';
rest: any;
}

interface IWzButtonPermissionsProps{
permissions?: TUserPermissions | TUserPermissionsFunction
roles?: TUserRoles | TUserRolesFunction
buttonType?: 'default' | 'empty' | 'icon' | 'link' | 'switch'
tooltip?: any
rest?: any
};

export const WzButtonPermissions = ({permissions = null, roles = null, buttonType = 'default', tooltip, ...rest} : IWzButtonPermissionsProps) => {
const [userPermissionRequirements, userPermissions] = useUserPermissionsRequirements(typeof permissions === 'function' ? permissions(rest) : permissions);
const [userRolesRequirements, userRoles] = useUserRolesRequirements(typeof roles === 'function' ? roles(rest) : roles);
export const WzButtonPermissions = ({
buttonType = 'default',
permissions,
roles,
tooltip,
...rest
}: IWzButtonPermissionsProps) => {
const Button =
buttonType === 'empty'
? EuiButtonEmpty
: buttonType === 'icon'
? EuiButtonIcon
: buttonType === 'link'
? EuiLink
: buttonType === 'switch'
? EuiSwitch
: EuiButton;

const Button = buttonType === 'default' ? EuiButton
: buttonType === 'empty' ? EuiButtonEmpty
: buttonType === 'icon' ? EuiButtonIcon
: buttonType === 'link' ? EuiLink
: buttonType === 'switch' ? EuiSwitch
: null
const disabled = Boolean(userRolesRequirements || userPermissionRequirements || rest.isDisabled || rest.disabled);
const disabledProp = !['link', 'switch'].includes(buttonType) ? { isDisabled: disabled } : { disabled };
const onClick = disabled || !rest.onClick ? undefined : rest.onClick;
const onChange = disabled || !rest.onChange ? undefined : rest.onChange;
const customProps = { ...rest, onChange, onClick };
return (
<WzElementPermissions
permissions={permissions}
roles={roles}
tooltip={tooltip}
getAdditionalProps={disabled => {
const additionalProps = {
...(!['link', 'switch'].includes(buttonType)
? { isDisabled: disabled }
: { disabled }),
onClick:
disabled || !rest.onClick || buttonType == 'switch'
? undefined
: rest.onClick,
onChange: disabled || !rest.onChange ? undefined : rest.onChange,
};

if (buttonType == 'switch') delete customProps.onClick;
if (buttonType == 'switch') delete additionalProps.onClick;

const button = <Button {...customProps} {...disabledProp} />;

const buttonTextRequirements = (userRolesRequirements || userPermissionRequirements) && (
<Fragment>
{userPermissionRequirements && (
<div>
<div>Require the {userPermissionRequirements.length === 1 ? 'permission' : 'permissions'}:</div>
{WzPermissionsFormatted(userPermissionRequirements)}
</div>
)}
{(userPermissionRequirements && userRolesRequirements) && <EuiSpacer size='s' />}
{userRolesRequirements && (
<div>
Require {userRolesRequirements.map(role => <strong key={`empty-prompt-no-roles-${role}`}>{role}</strong>).reduce((prev, cur) => [prev, ', ' , cur])} {userRolesRequirements.length > 1 ? 'roles': 'role'}
</div>
)}
</Fragment>
)
return (userRolesRequirements || userPermissionRequirements) ?
(<EuiToolTip
{...tooltip}
content={buttonTextRequirements}
return additionalProps;
}}
>
{button}
</EuiToolTip>) : tooltip && tooltip.content ?
(<EuiToolTip
{...tooltip}
>
{button}
</EuiToolTip>)
: button
}
<Button {...rest} />
</WzElementPermissions>
);
};
Loading

0 comments on commit f6d6551

Please sign in to comment.