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

Rollback configuration store from saved object to configuration file #6573

Merged
merged 36 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0c71645
rollback(configuration-store): rollback the store system to configura…
Desvelao Apr 2, 2024
0015485
remove(configuration): remove the migration task of configuration fil…
Desvelao Apr 2, 2024
8fbbfce
rollback(configuration): remove references to plugin settings defition
Desvelao Apr 2, 2024
eebfb94
rollback(configuration): remove enhanceConfiguration from frontend side
Desvelao Apr 2, 2024
0352d9d
fix(configuration): replace logger methods for noop
Desvelao Apr 2, 2024
7fe34c9
rollback(configuration): display the path to the configuration file o…
Desvelao Apr 2, 2024
ea180bc
remove: unused constant PLUGIN_PLATFORM_BASE_INSTALLATION_PATH
Desvelao Apr 2, 2024
f183e98
rollback(configuration): remove management of API connections on Serv…
Desvelao Apr 2, 2024
82327ff
rollback(configuration): remove management of API connection from the…
Desvelao Apr 2, 2024
8308756
fix: fix innaccesible view of Miscellaneous tab on App Settings
Desvelao Apr 2, 2024
2339a00
fix(configuration): fix error when editing some setting from the UI d…
Desvelao Apr 3, 2024
c363354
rollback(configuration): clear entry on configuration file
Desvelao Apr 3, 2024
d0947e9
rollback(configuration): remove API endpoint POST /utils/configuratio…
Desvelao Apr 3, 2024
38d05c8
feat(configuration): enhance validation of plugin settings
Desvelao Apr 4, 2024
1d2905d
feat(configuration): enhance validation of enrollment.dns plugin setting
Desvelao Apr 4, 2024
30b8ae0
clean: import of non-existent method
Desvelao Apr 4, 2024
09e40e4
rollback(configuration): remove import configuration from file
Desvelao Apr 4, 2024
096c7e4
fix(configuration): remove the visibility of default values of custom…
Desvelao Apr 4, 2024
4fd06a2
fix(configuration): minimize the references to branding on the config…
Desvelao Apr 4, 2024
3863e56
rollback(administrator): consideration of administrator user
Desvelao Apr 5, 2024
87ce49c
changelog: adapt some entries related to rollback the configuartion s…
Desvelao Apr 5, 2024
21ad74f
test: fix reporting tests
Desvelao Apr 5, 2024
7abbbdf
Merge branch '4.9.0' of https://github.com/wazuh/wazuh-kibana-app int…
Desvelao Apr 5, 2024
c812fba
tests: fix of core plugin
Desvelao Apr 5, 2024
3285237
rollback: remove encryption service
Desvelao Apr 5, 2024
6763d12
tests: fix tests
Desvelao Apr 5, 2024
7edf984
tests: remove references to deprecated validateBackend method of plug…
Desvelao Apr 5, 2024
ccde82e
tests(configuration-store): add tests
Desvelao Apr 8, 2024
e181033
remove: deprecated createLogFileIfNotExists method
Desvelao Apr 8, 2024
6dd6765
Merge branch '4.9.0' of https://github.com/wazuh/wazuh-kibana-app int…
Desvelao Apr 8, 2024
a94811a
fix: comment
Desvelao Apr 8, 2024
6965f89
fix(configuration-store): dirname of configuration file
Desvelao Apr 8, 2024
7df5a55
rollback(configuration-store): rename logger of ConfigurationStore se…
Desvelao Apr 8, 2024
4c16459
rollback(configuration): remove API endpoint POST /utils/configuratio…
Desvelao Apr 9, 2024
e85b63b
fix(configuration): fix error removing customization logos in a short…
Desvelao Apr 9, 2024
b6f7bfb
tests(configuration-store): adapt to latest changes
Desvelao Apr 9, 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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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)
- Added a migration task to setup the configuration using a configuration file [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337)
- Added the ability to manage the API hosts from the Server APIs [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337) [#6519](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6519)
- Improve fleet management by adding 'Edit Agent Groups' and 'Upgrade Agents' actions, as well as a filter to show only outdated agents [#6250](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6250) [#6476](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6476) [#6274](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6274) [#6501](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6501) [#6529](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6529)
- Added propagation of updates from the table to dashboard visualizations in Endpoints summary [#6460](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6460)
- Handle index pattern selector on new discover [#6499](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6499)
Expand All @@ -20,7 +19,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Removed embedded discover [#6120](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6120) [#6235](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6235) [#6254](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6254) [#6285](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6285) [#6288](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6288) [#6290](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6290) [#6289](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6289) [#6286](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6286) [#6275](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6275) [#6287](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6297](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6297) [#6287](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6291](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6459](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6459) [#6434](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6434)
- 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)
- Changed as the configuration is defined and stored [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337)
- Change how the configuration is managed in the backend side [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337) [#6519](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6519) [#6570](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6570)
- Change the view of API is down and check connection to Server APIs application [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337)
- Changed the usage of the endpoint GET /groups/{group_id}/files/{file_name} [#6385](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6385)
- Refactoring and redesign endpoints summary visualizations [#6268](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6268)
Expand All @@ -34,6 +33,7 @@ All notable changes to the Wazuh app project will be documented in this file.
### Fixed

- Fixed the scripted fields disappear when the fields of the events index pattern was refreshed [#6237](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6237)
- Fixed the validation for `enrollment.dns` on App Settings application [#6570](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6570)

### Removed

Expand Down
2 changes: 0 additions & 2 deletions plugins/main/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ export const REPORTS_PAGE_HEADER_TEXT = 'info@wazuh.com\nhttps://wazuh.com';

// Plugin platform
export const PLUGIN_PLATFORM_NAME = 'dashboard';
export const PLUGIN_PLATFORM_BASE_INSTALLATION_PATH =
'/usr/share/wazuh-dashboard/data/wazuh/';
export const PLUGIN_PLATFORM_INSTALLATION_USER = 'wazuh-dashboard';
export const PLUGIN_PLATFORM_INSTALLATION_USER_GROUP = 'wazuh-dashboard';
export const PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_UPGRADE_PLATFORM =
Expand Down
8 changes: 0 additions & 8 deletions plugins/main/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ app.run([
})
.catch(() => {});

// Set user account data in Redux when app starts.
getWazuhCorePlugin()
.dashboardSecurity.fetchAccount()
.then(response => {
store.dispatch(updateUserAccount(response));
})
.catch(() => {});

// Init the process of refreshing the user's token when app start.
checkPluginVersion().finally(WzAuthentication.refresh);

Expand Down
4 changes: 1 addition & 3 deletions plugins/main/public/components/common/form/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,7 @@ export const useForm = (fields: FormConfiguration): UseFormReturn => {
pathFormState: [],
},
({ changed, error, value }, _, { pathFormState, fieldDefinition }) => {
changed &&
(result.changed[pathFormState] =
fieldDefinition?.transformChangedOutputValue?.(value) ?? value);
changed && (result.changed[pathFormState] = value);
error && (result.errors[pathFormState] = error);
},
);
Expand Down
1 change: 0 additions & 1 deletion plugins/main/public/components/common/form/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ interface FieldConfiguration {
initialValue: any;
validate?: (value: any) => string | undefined;
transformChangedInputValue?: (value: any) => any;
transformChangedOutputValue?: (value: any) => any;
}

export interface DefaultFieldConfiguration extends FieldConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { useSelector } from 'react-redux';
// It retuns user requirements if is is not admin
export const useUserPermissionsIsAdminRequirements = () => {
const account = useSelector(state => state.appStateReducers.userAccount);
return [account.administrator_error_message, account];
return [account.administrator_requirements, account];
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ import {
} from '../../../../common/hocs';
import GroupInput from '../../components/group-input/group-input';
import { OsCard } from '../../components/os-selector/os-card/os-card';
import {
validateServerAddress,
validateAgentName,
} from '../../utils/validations';
import { validateAgentName } from '../../utils/validations';
import { compose } from 'redux';
import { endpointSummary } from '../../../../../utils/applications';
import { getCore } from '../../../../../kibana-services';
import { getCore, getWazuhCorePlugin } from '../../../../../kibana-services';
import { getErrorOrchestrator } from '../../../../../react-services/common-services';

export const RegisterAgent = compose(
Expand Down Expand Up @@ -80,7 +77,9 @@ export const RegisterAgent = compose(
serverAddress: {
type: 'text',
initialValue: configuration['enrollment.dns'] || '',
validate: validateServerAddress,
validate:
getWazuhCorePlugin().configuration._settings.get('enrollment.dns')
.validate,
},
agentName: {
type: 'text',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,53 +1,6 @@
import { validateServerAddress, validateAgentName } from './validations';
import { validateAgentName } from './validations';

describe('Validations', () => {
it('should return undefined for an empty value', () => {
const result = validateServerAddress('');
expect(result).toBeUndefined();
});

it('should return undefined for a valid FQDN', () => {
const validFQDN = 'example.fqdn.valid';
const result = validateServerAddress(validFQDN);
expect(result).toBeUndefined();
});

it('should return undefined for a valid IPv4', () => {
const validIP = '192.168.1.1';
const result = validateServerAddress(validIP);
expect(result).toBeUndefined();
});

it('should return undefined for a valid IPv6', () => {
const validIP = '2001:0db8:85a3:0000:0000:8a2e:0370:7334';
const result = validateServerAddress(validIP);
expect(result).toBeUndefined();
});

it('should return an error message for an invalid IPv6', () => {
const invalidIPV6 = '2001:db8:85a3::8a2e:370:7334';
const result = validateServerAddress(invalidIPV6);
expect(result).toBe(
'It should be a valid hostname, FQDN, IPv4 or uncompressed IPv6',
);
});

it('should return an error message for a compressed IPv6', () => {
const compressedIPV6 = '2001:0db8:85a3:0000:0000:8a2e:0370:7334:KL12';
const result = validateServerAddress(compressedIPV6);
expect(result).toBe(
'It should be a valid hostname, FQDN, IPv4 or uncompressed IPv6',
);
});

it('should return an error message for an invalid FQDN', () => {
const invalidFQDN = 'example.';
const result = validateServerAddress(invalidFQDN);
expect(result).toBe(
'It should be a valid hostname, FQDN, IPv4 or uncompressed IPv6',
);
});

test('should return undefined for an empty value', () => {
const emptyValue = '';
const result = validateAgentName(emptyValue);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
//IPv4: This is a set of four numbers, for example, 192.158.1.38. Each number in the set can range from 0 to 255. Therefore, the full range of IP addresses goes from 0.0.0.0 to 255.255.255.255
//IPv6: This is a set or eight hexadecimal expressions, each from 0000 to FFFF. 2001:0db8:85a3:0000:0000:8a2e:0370:7334

// FQDN: Maximum of 63 characters per label.
// Can only contain numbers, letters and hyphens (-)
// Labels cannot begin or end with a hyphen
// Currently supports multilingual characters, i.e. letters not included in the English alphabet: e.g. á é í ó ú ü ñ.
// Minimum 3 labels
// A label can contain only numbers

// Hostname: Maximum of 63 characters per label. Same rules as FQDN apply.

export const validateServerAddress = (value: string) => {
const isFQDNOrHostname =
/^(?!-)(?!.*--)[a-zA-Z0-9áéíóúüñ-]{0,62}[a-zA-Z0-9áéíóúüñ](?:\.[a-zA-Z0-9áéíóúüñ-]{0,62}[a-zA-Z0-9áéíóúüñ]){0,}$/;
const isIPv6 = /^(?:[0-9a-fA-F]{4}:){7}[0-9a-fA-F]{4}$/;

if (
value.length > 255 ||
(value.length > 0 && !isFQDNOrHostname.test(value) && !isIPv6.test(value))
) {
return 'It should be a valid hostname, FQDN, IPv4 or uncompressed IPv6';
}
return undefined;
};

export const validateAgentName = (value: any) => {
if (value.length === 0) {
return undefined;
Expand Down
Loading
Loading