this.props.addingNewAgent()}
+ href={getCore().application.getUrlForApp(endpointSumary.id, {
+ path: `#${endpointSumary.redirectTo()}deploy`,
+ })}
>
Deploy new agent
,
@@ -475,17 +471,6 @@ export const AgentsTable = withErrorBoundary(
},
},
}}
- searchBarProps={{
- buttonsRender: () => (
-
this.reloadAgents()}
- >
- Refresh
-
- ),
- }}
saveStateStorage={{
system: 'localStorage',
key: 'wz-agents-overview-table',
@@ -532,11 +517,3 @@ export const AgentsTable = withErrorBoundary(
}
},
);
-
-AgentsTable.propTypes = {
- wzReq: PropTypes.func,
- addingNewAgent: PropTypes.func,
- downloadCsv: PropTypes.func,
- timeService: PropTypes.func,
- reload: PropTypes.func,
-};
diff --git a/plugins/main/public/controllers/agent/components/agent-table.test.tsx b/plugins/main/public/components/endpoints-summary/table/agents-table.test.tsx
similarity index 98%
rename from plugins/main/public/controllers/agent/components/agent-table.test.tsx
rename to plugins/main/public/components/endpoints-summary/table/agents-table.test.tsx
index 66ca6e2932..872773a878 100644
--- a/plugins/main/public/controllers/agent/components/agent-table.test.tsx
+++ b/plugins/main/public/components/endpoints-summary/table/agents-table.test.tsx
@@ -275,6 +275,15 @@ const localStorageMock = (function () {
Object.defineProperty(window, 'localStorage', { value: localStorageMock });
+jest.mock('../../../kibana-services', () => ({
+ getCore: jest.fn().mockReturnValue({
+ application: {
+ navigateToApp: () => 'http://url',
+ getUrlForApp: () => 'http://url',
+ },
+ }),
+}));
+
jest.mock('../../../react-services/common-services', () => ({
getErrorOrchestrator: () => ({
handleError: options => {},
diff --git a/plugins/main/public/controllers/agent/agents-preview.js b/plugins/main/public/controllers/agent/agents-preview.js
deleted file mode 100644
index 6fd90cce6e..0000000000
--- a/plugins/main/public/controllers/agent/agents-preview.js
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Wazuh app - Agents preview controller
- * Copyright (C) 2015-2022 Wazuh, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Find more information about this on the LICENSE file.
- */
-import * as FileSaver from '../../services/file-saver';
-import { DataFactory } from '../../services/data-factory';
-import { version } from '../../../package.json';
-import { clickAction } from '../../services/click-action';
-import { AppState } from '../../react-services/app-state';
-import { WazuhConfig } from '../../react-services/wazuh-config';
-import { GenericRequest } from '../../react-services/generic-request';
-import { WzRequest } from '../../react-services/wz-request';
-import { ShareAgent } from '../../factories/share-agent';
-import { formatUIDate } from '../../react-services/time-service';
-import { ErrorHandler } from '../../react-services/error-handler';
-import { getDataPlugin, getToasts } from '../../kibana-services';
-import store from '../../redux/store';
-import { UI_LOGGER_LEVELS } from '../../../common/constants';
-import { UI_ERROR_SEVERITIES } from '../../react-services/error-orchestrator/types';
-import { getErrorOrchestrator } from '../../react-services/common-services';
-import { webDocumentationLink } from '../../../common/services/web_documentation';
-
-export class AgentsPreviewController {
- /**
- * Class constructor
- * @param {Object} $scope
- * @param {Object} $location
- * @param {Object} errorHandler
- * @param {Object} csvReq
- */
- constructor(
- $scope,
- $location,
- $route,
- errorHandler,
- csvReq,
- commonData,
- $window,
- ) {
- this.$scope = $scope;
- this.genericReq = GenericRequest;
- this.$location = $location;
- this.$route = $route;
- this.errorHandler = errorHandler;
- this.csvReq = csvReq;
- this.shareAgent = new ShareAgent();
- this.commonData = commonData;
- this.wazuhConfig = new WazuhConfig();
- this.errorInit = false;
- this.$window = $window;
- this.addingNewAgent = false;
- }
-
- /**
- * On controller loads
- */
- async $onInit() {
- this.init = true;
- this.api = JSON.parse(AppState.getCurrentAPI()).id;
- const loc = this.$location.search();
- if ((loc || {}).agent && (loc || {}).agent !== '000') {
- this.commonData.setTimefilter(
- getDataPlugin().timefilter.timefilter.getTime(),
- );
- return this.showAgent({ id: loc.agent });
- }
-
- this.isClusterEnabled =
- AppState.getClusterInfo() &&
- AppState.getClusterInfo().status === 'enabled';
- this.loading = true;
- this.osPlatforms = [];
- this.versions = [];
- this.groups = [];
- this.nodes = [];
- this.mostActiveAgent = {
- name: '',
- id: '',
- };
- this.prevSearch = false;
-
- // Load URL params
- if (loc && loc.tab) {
- this.submenuNavItem = loc.tab;
- }
- // Watcher for URL params
- this.$scope.$watch('submenuNavItem', () => {
- this.$location.search('tab', this.submenuNavItem);
- });
-
- this.$scope.$on('wazuhFetched', evt => {
- evt.stopPropagation();
- });
- this.registerAgentsProps = {
- addNewAgent: flag => this.addNewAgent(flag),
- hasAgents: () => this.hasAgents,
- reload: () => this.$route.reload(),
- getWazuhVersion: () => this.getWazuhVersion(),
- getCurrentApiAddress: () => this.getCurrentApiAddress(),
- };
- this.hasAgents = true;
- this.init = false;
- const instance = new DataFactory(WzRequest.apiReq, '/agents', false, false);
- //Props
- this.tableAgentsProps = {
- updateSummary: summary => {
- this.summary = summary;
- if (this.summary.total === 0) {
- this.addNewAgent(true);
- this.hasAgents = false;
- } else {
- this.hasAgents = true;
- }
- },
- wzReq: (method, path, body) => WzRequest.apiReq(method, path, body),
- addingNewAgent: () => {
- this.addNewAgent(true);
- this.$scope.$applyAsync();
- },
- downloadCsv: (filters = []) => {
- this.downloadCsv(filters);
- this.$scope.$applyAsync();
- },
- showAgent: agent => {
- this.showAgent(agent);
- this.$scope.$applyAsync();
- },
- getMostActive: async () => {
- return await this.getMostActive();
- },
- clickAction: (item, openAction = false) => {
- clickAction(
- item,
- openAction,
- instance,
- this.shareAgent,
- this.$location,
- this.$scope,
- );
- this.$scope.$applyAsync();
- },
- formatUIDate: date => formatUIDate(date),
- summary: this.summary,
- };
- //Load
- this.load();
- }
-
- /**
- * Searches by a query and term
- * @param {String} query
- * @param {String} search
- */
- query(query, search) {
- this.$scope.$broadcast('wazuhQuery', { query, search });
- this.prevSearch = search || false;
- }
-
- /**
- * Selects an agent
- * @param {String} agent
- */
- showAgent(agent) {
- this.shareAgent.setAgent(agent);
- this.$location.path('/agents');
- }
-
- /**
- * Exports the table in CSV format
- */
- async downloadCsv(filters) {
- try {
- ErrorHandler.info('Your download should begin automatically...', 'CSV');
- const output = await this.csvReq.fetch('/agents', this.api, filters);
- const blob = new Blob([output], { type: 'text/csv' }); // eslint-disable-line
-
- FileSaver.saveAs(blob, 'agents.csv');
-
- return;
- } catch (error) {
- const options = {
- context: `${AgentsPreviewController.name}.downloadCsv`,
- level: UI_LOGGER_LEVELS.ERROR,
- severity: UI_ERROR_SEVERITIES.BUSINESS,
- error: {
- error: error,
- message: error.message || error,
- title: `Error exporting CSV: ${error.message || error}`,
- },
- };
- getErrorOrchestrator().handleError(options);
- }
- }
-
- async getMostActive() {
- try {
- const data = await this.genericReq.request(
- 'GET',
- `/elastic/top/${this.firstUrlParam}/${this.secondUrlParam}/agent.name/${
- this.pattern
- }?agentsList=${store
- .getState()
- .appStateReducers.allowedAgents.toString()}`,
- );
- this.mostActiveAgent.name = data.data.data;
- const info = await this.genericReq.request(
- 'GET',
- `/elastic/top/${this.firstUrlParam}/${this.secondUrlParam}/agent.id/${
- this.pattern
- }?agentsList=${store
- .getState()
- .appStateReducers.allowedAgents.toString()}`,
- );
- if (info.data.data === '' && this.mostActiveAgent.name !== '') {
- this.mostActiveAgent.id = '000';
- } else {
- this.mostActiveAgent.id = info.data.data;
- }
- return this.mostActiveAgent;
- } catch (error) {
- const options = {
- context: `${AgentsPreviewController.name}.getMostActive`,
- level: UI_LOGGER_LEVELS.ERROR,
- severity: UI_ERROR_SEVERITIES.BUSINESS,
- store: true,
- error: {
- error: error,
- message: error.message || error,
- title: `An error occurred while trying to get the most active agent: ${
- error.message || error
- }`,
- },
- };
- getErrorOrchestrator().handleError(options);
- }
- }
-
- /**
- * On controller loads
- */
- async load() {
- try {
- this.errorInit = false;
- const clusterInfo = AppState.getClusterInfo();
- this.firstUrlParam =
- clusterInfo.status === 'enabled' ? 'cluster' : 'manager';
- this.secondUrlParam = clusterInfo[this.firstUrlParam];
- this.pattern = (
- await getDataPlugin().indexPatterns.get(AppState.getCurrentPattern())
- ).title;
- } catch (error) {
- const options = {
- context: `${AgentsPreviewController.name}.load`,
- level: UI_LOGGER_LEVELS.ERROR,
- severity: UI_ERROR_SEVERITIES.CRITICAL,
- store: true,
- error: {
- error: error,
- message: error.message || error,
- title: error.message || error,
- },
- };
- getErrorOrchestrator().handleError(options);
- }
- this.loading = false;
- this.$scope.$applyAsync();
- }
-
- addNewAgent(flag) {
- this.addingNewAgent = flag;
- }
-
- /**
- * Returns the current API address
- */
- async getCurrentApiAddress() {
- try {
- const result = await this.genericReq.request('GET', '/hosts/apis');
- const entries = result.data || [];
- const host = entries.filter(e => {
- return e.id == this.api;
- });
- const url = host[0].url;
- const numToClean = url.startsWith('https://') ? 8 : 7;
- return url.substr(numToClean);
- } catch (error) {
- const options = {
- context: `${AgentsPreviewController.name}.getCurrentApiAddress`,
- level: UI_LOGGER_LEVELS.ERROR,
- severity: UI_ERROR_SEVERITIES.UI,
- error: {
- error: error,
- message: error.message || error,
- title: `Could not get the Wazuh API address: ${
- error.message || error
- }`,
- },
- };
- getErrorOrchestrator().handleError(options);
- }
- }
-
- /**
- * Returns the Wazuh version as x.y.z
- */
- async getWazuhVersion() {
- try {
- const data = await WzRequest.apiReq('GET', '/', {});
- const result = ((data || {}).data || {}).data || {};
- return result.api_version;
- } catch (error) {
- const options = {
- context: `${AgentsPreviewController.name}.getWazuhVersion`,
- level: UI_LOGGER_LEVELS.ERROR,
- severity: UI_ERROR_SEVERITIES.BUSINESS,
- error: {
- error: error,
- message: error.message || error,
- title: `Could not get the Wazuh version: ${error.message || error}`,
- },
- };
- getErrorOrchestrator().handleError(options);
- return version;
- }
- }
-}
diff --git a/plugins/main/public/controllers/agent/components/agents-preview.js b/plugins/main/public/controllers/agent/components/agents-preview.js
deleted file mode 100644
index bb02a41ce3..0000000000
--- a/plugins/main/public/controllers/agent/components/agents-preview.js
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Wazuh app - React component for building the agents preview section.
- *
- * Copyright (C) 2015-2022 Wazuh, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Find more information about this on the LICENSE file.
- */
-
-import React, { Component, Fragment } from 'react';
-import PropTypes from 'prop-types';
-import {
- EuiPage,
- EuiFlexGroup,
- EuiFlexItem,
- EuiStat,
- EuiLoadingChart,
- EuiSpacer,
- EuiToolTip,
- EuiCard,
- EuiLink,
-} from '@elastic/eui';
-import { AgentsTable } from './agents-table';
-import { WzRequest } from '../../../react-services/wz-request';
-import KibanaVis from '../../../kibana-integrations/kibana-vis';
-import WzReduxProvider from '../../../redux/wz-redux-provider';
-import { VisFactoryHandler } from '../../../react-services/vis-factory-handler';
-import { AppState } from '../../../react-services/app-state';
-import { FilterHandler } from '../../../utils/filter-handler';
-import { TabVisualizations } from '../../../factories/tab-visualizations';
-import { WazuhConfig } from './../../../react-services/wazuh-config.js';
-import {
- withReduxProvider,
- withGlobalBreadcrumb,
- withUserAuthorizationPrompt,
-} from '../../../components/common/hocs';
-import { formatUIDate } from '../../../../public/react-services/time-service';
-import { compose } from 'redux';
-import { withErrorBoundary } from '../../../components/common/hocs';
-import './agents-preview.scss';
-import {
- UI_LOGGER_LEVELS,
- UI_ORDER_AGENT_STATUS,
-} from '../../../../common/constants';
-import { UI_ERROR_SEVERITIES } from '../../../react-services/error-orchestrator/types';
-import { getErrorOrchestrator } from '../../../react-services/common-services';
-import { VisualizationBasic } from '../../../components/common/charts/visualizations/basic';
-import {
- agentStatusColorByAgentStatus,
- agentStatusLabelByAgentStatus,
-} from '../../../../common/services/wz_agent_status';
-import { endpointSumary } from '../../../utils/applications';
-
-export const AgentsPreview = compose(
- withErrorBoundary,
- withReduxProvider,
- withGlobalBreadcrumb([{ text: endpointSumary.title }]),
- withUserAuthorizationPrompt([
- [
- { action: 'agent:read', resource: 'agent:id:*' },
- { action: 'agent:read', resource: 'agent:group:*' },
- ],
- ]),
-)(
- class AgentsPreview extends Component {
- _isMount = false;
- constructor(props) {
- super(props);
- this.state = {
- loadingAgents: false,
- loadingSummary: false,
- showAgentsEvolutionVisualization: true,
- agentTableFilters: [],
- agentStatusSummary: {
- active: '-',
- disconnected: '-',
- total: '-',
- pending: '-',
- never_connected: '-',
- },
- agentConfiguration: {},
- agentsActiveCoverage: 0,
- };
- this.wazuhConfig = new WazuhConfig();
- this.agentStatus = UI_ORDER_AGENT_STATUS.map(agentStatus => ({
- status: agentStatus,
- label: agentStatusLabelByAgentStatus(agentStatus),
- color: agentStatusColorByAgentStatus(agentStatus),
- }));
- }
-
- async componentDidMount() {
- this._isMount = true;
- this.fetchAgentStatusDetailsData();
- if (this.wazuhConfig.getConfig()['wazuh.monitoring.enabled']) {
- this._isMount &&
- this.setState({
- showAgentsEvolutionVisualization: true,
- });
- const tabVisualizations = new TabVisualizations();
- tabVisualizations.removeAll();
- tabVisualizations.setTab('general');
- tabVisualizations.assign({
- general: 1,
- });
- const filterHandler = new FilterHandler(AppState.getCurrentPattern());
- await VisFactoryHandler.buildOverviewVisualizations(
- filterHandler,
- 'general',
- null,
- );
- }
- }
-
- componentWillUnmount() {
- this._isMount = false;
- }
-
- groupBy = function (arr) {
- return arr.reduce(function (prev, item) {
- if (item in prev) prev[item]++;
- else prev[item] = 1;
- return prev;
- }, {});
- };
- async fetchSummaryStatus() {
- this.setState({ loadingSummary: true });
- const {
- data: {
- data: {
- connection: agentStatusSummary,
- configuration: agentConfiguration,
- },
- },
- } = await WzRequest.apiReq('GET', '/agents/summary/status', {});
-
- this.props.tableProps.updateSummary(agentStatusSummary);
-
- const agentsActiveCoverage = (
- (agentStatusSummary.active / agentStatusSummary.total) *
- 100
- ).toFixed(2);
-
- this.setState({
- loadingSummary: false,
- agentStatusSummary,
- agentConfiguration,
- /* Calculate the agents active coverage.
- Ensure the calculated value is not a NaN, otherwise set a 0.
- */
- agentsActiveCoverage: isNaN(agentsActiveCoverage)
- ? 0
- : agentsActiveCoverage,
- });
- }
-
- async fetchAgents() {
- this.setState({ loadingAgents: true });
- const {
- data: {
- data: {
- affected_items: [lastRegisteredAgent],
- },
- },
- } = await WzRequest.apiReq('GET', '/agents', {
- params: { limit: 1, sort: '-dateAdd', q: 'id!=000' },
- });
- const agentMostActive = await this.props.tableProps.getMostActive();
- this.setState({
- loadingAgents: false,
- lastRegisteredAgent,
- agentMostActive,
- });
- }
- async fetchAgentStatusDetailsData() {
- try {
- this.fetchSummaryStatus();
- this.fetchAgents();
- } catch (error) {
- this.setState({ loadingAgents: false, loadingSummary: false });
- const options = {
- context: `${AgentsPreview.name}.fetchAgentStatusDetailsData`,
- level: UI_LOGGER_LEVELS.ERROR,
- severity: UI_ERROR_SEVERITIES.BUSINESS,
- store: true,
- error: {
- error: error,
- message: error.message || error,
- title: `Could not get the agents summary`,
- },
- };
- getErrorOrchestrator().handleError(options);
- }
- }
-
- removeFilters() {
- this._isMount && this.setState({ agentTableFilters: {} });
- }
-
- showAgent(agent) {
- agent && this.props.tableProps.showAgent(agent);
- }
-
- filterAgentByStatus(status) {
- this._isMount &&
- this.setState({
- agentTableFilters: { q: `id!=000;status=${status}` },
- });
- }
- onRenderComplete() {
- this.setState({
- evolutionRenderComplete: true,
- });
- }
-
- render() {
- const evolutionIsReady = this.props.resultState !== 'loading';
-
- return (
-
-
-
- {
- <>
-
-
-
-
- ({
- label,
- value:
- this.state.agentStatusSummary[status] || 0,
- color,
- onClick: () => this.filterAgentByStatus(status),
- }),
- )}
- noDataTitle='No results'
- noDataMessage='No results were found.'
- />
-
-
-
-
-
-
-
- {this.agentStatus.map(({ status, label, color }) => (
-
-
-
- this.filterAgentByStatus(status)
- }
- style={{ cursor: 'pointer' }}
- >
- {this.state.agentStatusSummary[status]}
-
-
- }
- titleSize='s'
- description={label}
- titleColor={color}
- className='white-space-nowrap'
- />
-
- ))}
-
-
-
-
-
-
-
-
- this.showAgent(
- this.state.lastRegisteredAgent,
- )
- }
- >
- {this.state.lastRegisteredAgent?.name || '-'}
-
-
- }
- titleSize='s'
- description='Last registered agent'
- titleColor='primary'
- />
-
- {
-
-
-
- this.showAgent(this.state.agentMostActive)
- }
- >
- {this.state.agentMostActive?.name || '-'}
-
-
- }
- titleSize='s'
- description='Most active agent'
- titleColor='primary'
- />
-
- }
-
-
-
- >
- }
-
-
-
-
-
-
-
-
-
- {!evolutionIsReady && (
-
-
-
- )}
-
-
-
-
-
-
-
- this.removeFilters()}
- wzReq={this.props.tableProps.wzReq}
- addingNewAgent={this.props.tableProps.addingNewAgent}
- downloadCsv={this.props.tableProps.downloadCsv}
- formatUIDate={date => formatUIDate(date)}
- reload={() => this.fetchAgentStatusDetailsData()}
- />
-
-
-
- );
- }
- },
-);
-
-AgentsTable.propTypes = {
- tableProps: PropTypes.object,
- showAgent: PropTypes.func,
-};
diff --git a/plugins/main/public/controllers/agent/components/checkUpgrade.tsx b/plugins/main/public/controllers/agent/components/checkUpgrade.tsx
deleted file mode 100644
index a75d7c5f5e..0000000000
--- a/plugins/main/public/controllers/agent/components/checkUpgrade.tsx
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Wazuh app - React component for show search and filter
- * Copyright (C) 2015-2022 Wazuh, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Find more information about this on the LICENSE file.
- */
-
-import React, { Component } from 'react';
-import { EuiLoadingSpinner, EuiToolTip } from '@elastic/eui';
-import { WzRequest } from '../../../react-services/wz-request';
-import { UI_LOGGER_LEVELS } from '../../../../common/constants';
-import { UI_ERROR_SEVERITIES } from '../../../react-services/error-orchestrator/types';
-import { getErrorOrchestrator } from '../../../react-services/common-services';
-
-export class CheckUpgrade extends Component {
- props!: {
- id: String;
- version: String;
- agent: Object;
- upgrading: Boolean;
- managerVersion: String;
- changeStatusUpdate: Function;
- reloadAgent: Function;
- };
- interval: any;
-
- constructor(props) {
- super(props);
- }
-
- componentWillUnmount() {
- clearInterval(this.interval);
- }
-
- componentDidUpdate(prevProps) {
- if (prevProps.upgrading !== this.props.upgrading) {
- if (this.props.upgrading === true)
- this.interval = setInterval(() => this.checkUpgrade(this.props.id), 3000);
- }
- }
-
- async checkUpgrade(agentId) {
- try {
- const response = await WzRequest.apiReq('GET', `/agents/${agentId}/upgrade_result`, {});
- if (response.data === 200) {
- this.props.changeStatusUpdate(agentId);
- this.props.reloadAgent();
- clearInterval(this.interval);
- console.log(`${this.props.id} agent ends interval`);
- }
- } catch (error) {
- const options = {
- context: `${CheckUpgrade.name}.checkUpgrade`,
- level: UI_LOGGER_LEVELS.ERROR,
- severity: UI_ERROR_SEVERITIES.BUSINESS,
- error: {
- error: error,
- message: error.message || error,
- title: error.message || error,
- },
- };
- getErrorOrchestrator().handleError(options);
- }
- }
-
- addUpgraingProgress() {
- const { id, version, upgrading, managerVersion } = this.props;
-
- if (version === '.' || version === managerVersion) {
- return;
- } else if (upgrading === true) {
- /* this.interval = setInterval(() => this.checkUpgrade(id), 30000); */
- return (
-
-
-
- );
- }
- }
-
- render() {
- const { version } = this.props;
- let upgrading = this.addUpgraingProgress();
-
- return (
-
- {version}
-
- {upgrading}
-
- );
- }
-}
diff --git a/plugins/main/public/controllers/agent/components/register-agent-service.ts b/plugins/main/public/controllers/agent/components/register-agent-service.ts
deleted file mode 100644
index bf453797b7..0000000000
--- a/plugins/main/public/controllers/agent/components/register-agent-service.ts
+++ /dev/null
@@ -1,218 +0,0 @@
-import { WzRequest } from '../../../react-services/wz-request';
-import { ServerAddressOptions } from '../register-agent/steps';
-
-type Protocol = 'TCP' | 'UDP';
-
-type RemoteItem = {
- connection: 'syslog' | 'secure';
- ipv6: 'yes' | 'no';
- protocol: Protocol[];
- allowed_ips?: string[];
- queue_size?: string;
-};
-
-type RemoteConfig = {
- name: string;
- isUdp: boolean | null;
- haveSecureConnection: boolean | null;
-};
-
-/**
- * Get the cluster status
- */
-export const clusterStatusResponse = async (): Promise
=> {
- const clusterStatus = await WzRequest.apiReq('GET', '/cluster/status', {});
- if (
- clusterStatus.data.data.enabled === 'yes' &&
- clusterStatus.data.data.running === 'yes'
- ) {
- // Cluster mode
- return true;
- } else {
- // Manager mode
- return false;
- }
-};
-
-/**
- * Get the remote configuration from api
- */
-async function getRemoteConfiguration(nodeName: string): Promise {
- let config: RemoteConfig = {
- name: nodeName,
- isUdp: false,
- haveSecureConnection: false,
- };
-
- try {
- const clusterStatus = await clusterStatusResponse();
- let result;
- if (clusterStatus) {
- result = await WzRequest.apiReq(
- 'GET',
- `/cluster/${nodeName}/configuration/request/remote`,
- {},
- );
- } else {
- result = await WzRequest.apiReq(
- 'GET',
- '/manager/configuration/request/remote',
- {},
- );
- }
- const items = ((result.data || {}).data || {}).affected_items || [];
- const remote = items[0]?.remote;
- if (remote) {
- const remoteFiltered = remote.filter((item: RemoteItem) => {
- return item.connection === 'secure';
- });
-
- remoteFiltered.length > 0
- ? (config.haveSecureConnection = true)
- : (config.haveSecureConnection = false);
-
- let protocolsAvailable: Protocol[] = [];
- remote.forEach((item: RemoteItem) => {
- // get all protocols available
- item.protocol.forEach(protocol => {
- protocolsAvailable = protocolsAvailable.concat(protocol);
- });
- });
-
- config.isUdp =
- getRemoteProtocol(protocolsAvailable) === 'UDP' ? true : false;
- }
- return config;
- }catch(error){
- return config;
- }
-}
-
-/**
- * Get the remote protocol available from list of protocols
- * @param protocols
- */
-function getRemoteProtocol(protocols: Protocol[]) {
- if (protocols.length === 1) {
- return protocols[0];
- } else {
- return !protocols.includes('TCP') ? 'UDP' : 'TCP';
- }
-}
-
-/**
- * Get the remote configuration from nodes registered in the cluster and decide the protocol to setting up in deploy agent param
- * @param nodeSelected
- * @param defaultServerAddress
- */
-async function getConnectionConfig(
- nodeSelected: ServerAddressOptions,
- defaultServerAddress?: string,
-) {
- const nodeName = nodeSelected?.label;
- const nodeIp = nodeSelected?.value;
- if(!defaultServerAddress){
- if(nodeSelected.nodetype !== 'custom'){
- const remoteConfig = await getRemoteConfiguration(nodeName);
- return { serverAddress: nodeIp, udpProtocol: remoteConfig.isUdp, connectionSecure: remoteConfig.haveSecureConnection };
- }else{
- return { serverAddress: nodeName, udpProtocol: false, connectionSecure: true };
- }
- } else {
- return {
- serverAddress: defaultServerAddress,
- udpProtocol: false,
- connectionSecure: true,
- };
- }
-}
-
-type NodeItem = {
- name: string;
- ip: string;
- type: string;
-};
-
-type NodeResponse = {
- data: {
- data: {
- affected_items: NodeItem[];
- };
- };
-};
-
-/**
- * Get the list of the cluster nodes and parse it into a list of options
- */
-export const getNodeIPs = async (): Promise => {
- return await WzRequest.apiReq('GET', '/cluster/nodes', {});
-};
-
-/**
- * Get the list of the manager and parse it into a list of options
- */
-export const getManagerNode = async (): Promise => {
- const managerNode = await WzRequest.apiReq('GET', '/manager/api/config', {});
- return managerNode?.data?.data?.affected_items?.map(item => ({
- label: item.node_name,
- value: item.node_api_config.host,
- nodetype: 'master',
- })) || [];
-};
-
-/**
- * Parse the nodes list from the API response to a format that can be used by the EuiComboBox
- * @param nodes
- */
-export const parseNodesInOptions = (
- nodes: NodeResponse,
-): ServerAddressOptions[] => {
- return nodes.data.data.affected_items.map((item: NodeItem) => ({
- label: item.name,
- value: item.ip,
- nodetype: item.type,
- }));
-};
-
-/**
- * Get the list of the cluster nodes from API and parse it into a list of options
- */
-export const fetchClusterNodesOptions = async (): Promise<
- ServerAddressOptions[]
-> => {
- const clusterStatus = await clusterStatusResponse();
- if (clusterStatus) {
- // Cluster mode
- // Get the cluster nodes
- const nodes = await getNodeIPs();
- return parseNodesInOptions(nodes);
- } else {
- // Manager mode
- // Get the manager node
- return await getManagerNode();
- }
-};
-
-/**
- * Get the master node data from the list of cluster nodes
- * @param nodeIps
- */
-export const getMasterNode = (
- nodeIps: ServerAddressOptions[],
-): ServerAddressOptions[] => {
- return nodeIps.filter(nodeIp => nodeIp.nodetype === 'master');
-};
-
-/**
- * Get the remote configuration from manager
- * This function get the config from manager mode or cluster mode
- */
-export const getMasterRemoteConfiguration = async () => {
- const nodes = await fetchClusterNodesOptions();
- const masterNode = getMasterNode(nodes);
- return await getRemoteConfiguration(masterNode[0].label);
-}
-
-
-
-export { getConnectionConfig, getRemoteConfiguration };
diff --git a/plugins/main/public/controllers/agent/components/register-agent.js b/plugins/main/public/controllers/agent/components/register-agent.js
deleted file mode 100644
index 37395e6ea6..0000000000
--- a/plugins/main/public/controllers/agent/components/register-agent.js
+++ /dev/null
@@ -1,2291 +0,0 @@
-/*
- * Wazuh app - React component for registering agents.
- * Copyright (C) 2015-2022 Wazuh, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Find more information about this on the LICENSE file.
- */
-import React, { Component, Fragment } from 'react';
-import { version } from '../../../../package.json';
-import { WazuhConfig } from '../../../react-services/wazuh-config';
-import {
- EuiSteps,
- EuiTabbedContent,
- EuiFlexGroup,
- EuiFlexItem,
- EuiPanel,
- EuiComboBox,
- EuiFieldText,
- EuiText,
- EuiCodeBlock,
- EuiTitle,
- EuiButtonEmpty,
- EuiCopy,
- EuiPage,
- EuiPageBody,
- EuiCallOut,
- EuiSpacer,
- EuiProgress,
- EuiIcon,
- EuiSwitch,
- EuiLink,
- EuiFormRow,
- EuiForm,
-} from '@elastic/eui';
-import { WzRequest } from '../../../react-services/wz-request';
-import { withErrorBoundary } from '../../../components/common/hocs';
-import { UI_LOGGER_LEVELS } from '../../../../common/constants';
-import { UI_ERROR_SEVERITIES } from '../../../react-services/error-orchestrator/types';
-import { getErrorOrchestrator } from '../../../react-services/common-services';
-import { webDocumentationLink } from '../../../../common/services/web_documentation';
-import {
- architectureButtons,
- architectureButtonsi386,
- architecturei386Andx86_64,
- versionButtonsRaspbian,
- versionButtonsSuse,
- versionButtonsOracleLinux,
- versionButtonFedora,
- architectureButtonsSolaris,
- architectureButtonsWithPPC64LE,
- architectureButtonsAix,
- architectureButtonsHpUx,
- versionButtonAmazonLinux,
- versionButtonsRedHat,
- versionButtonsCentos,
- architectureButtonsMacos,
- osPrincipalButtons,
- versionButtonsDebian,
- versionButtonsUbuntu,
- versionButtonsWindows,
- versionButtonsMacOS,
- versionButtonsOpenSuse,
- versionButtonsSolaris,
- versionButtonsAix,
- versionButtonsHPUX,
- versionButtonAlpine,
- architectureButtonsWithPPC64LEAlpine,
-} from '../wazuh-config';
-import './register-agent.scss';
-import WzManagerAddressInput from '../register-agent/steps/wz-manager-address';
-import { getMasterRemoteConfiguration } from './register-agent-service';
-import { PrincipalButtonGroup } from './wz-accordion';
-import RegisterAgentButtonGroup from '../register-agent/register-agent-button-group';
-import '../../../styles/common.scss';
-
-export const RegisterAgent = withErrorBoundary(
- class RegisterAgent extends Component {
- constructor(props) {
- super(props);
- this.wazuhConfig = new WazuhConfig();
- this.configuration = this.wazuhConfig.getConfig();
- this.addToVersion = '-1';
-
- this.state = {
- status: 'incomplete',
- selectedOS: '',
- selectedSYS: '',
- neededSYS: false,
- selectedArchitecture: '',
- selectedVersion: '',
- version: '',
- wazuhVersion: '',
- serverAddress: '',
- agentName: '',
- agentNameError: false,
- badCharacters: [],
- wazuhPassword: '',
- groups: [],
- selectedGroup: [],
- defaultServerAddress: '',
- udpProtocol: false,
- showPassword: false,
- showProtocol: true,
- connectionSecure: true,
- isAccordionOpen: false,
- };
- this.restartAgentCommand = {
- rpm: this.systemSelector(),
- cent: this.systemSelector(),
- deb: this.systemSelector(),
- ubu: this.systemSelector(),
- oraclelinux: this.systemSelector(),
- macos: this.systemSelectorWazuhControlMacos(),
- win: this.systemSelectorNet(),
- };
- }
-
- async componentDidMount() {
- try {
- this.setState({ loading: true });
- const wazuhVersion = await this.props.getWazuhVersion();
- let wazuhPassword = '';
- let hidePasswordInput = false;
- this.getEnrollDNSConfig();
- await this.getRemoteConfig();
- let authInfo = await this.getAuthInfo();
- const needsPassword = (authInfo.auth || {}).use_password === 'yes';
- if (needsPassword) {
- wazuhPassword =
- this.configuration['enrollment.password'] ||
- authInfo['authd.pass'] ||
- '';
- if (wazuhPassword) {
- hidePasswordInput = true;
- }
- }
- const groups = await this.getGroups();
- this.setState({
- needsPassword,
- hidePasswordInput,
- versionButtonsRedHat,
- versionButtonsCentos,
- versionButtonsDebian,
- versionButtonsUbuntu,
- versionButtonsWindows,
- versionButtonsMacOS,
- versionButtonsOpenSuse,
- versionButtonsSolaris,
- versionButtonAmazonLinux,
- versionButtonsSuse,
- versionButtonsAix,
- versionButtonsHPUX,
- versionButtonsOracleLinux,
- versionButtonsRaspbian,
- versionButtonFedora,
- architectureButtons,
- architectureButtonsi386,
- architecturei386Andx86_64,
- architectureButtonsSolaris,
- architectureButtonsAix,
- architectureButtonsHpUx,
- architectureButtonsMacos,
- architectureButtonsWithPPC64LE,
- wazuhPassword,
- wazuhVersion,
- groups,
- loading: false,
- });
- } catch (error) {
- this.setState({
- wazuhVersion: version,
- loading: false,
- });
- const options = {
- context: `${RegisterAgent.name}.componentDidMount`,
- level: UI_LOGGER_LEVELS.ERROR,
- severity: UI_ERROR_SEVERITIES.BUSINESS,
- display: true,
- store: false,
- error: {
- error: error,
- message: error.message || error,
- title: error.name || error,
- },
- };
- getErrorOrchestrator().handleError(options);
- }
- }
-
- getEnrollDNSConfig = () => {
- const serverAddress = this.configuration['enrollment.dns'] || '';
- this.setState({ defaultServerAddress: serverAddress });
- };
-
- getRemoteConfig = async () => {
- const remoteConfig = await getMasterRemoteConfiguration();
- if (remoteConfig) {
- this.setState({
- haveUdpProtocol: remoteConfig.isUdp,
- haveConnectionSecure: remoteConfig.haveSecureConnection,
- udpProtocol: remoteConfig.isUdp,
- connectionSecure: remoteConfig.haveSecureConnection,
- });
- }
- };
-
- async getAuthInfo() {
- try {
- const result = await WzRequest.apiReq(
- 'GET',
- '/agents/000/config/auth/auth',
- {},
- );
- return (result.data || {}).data || {};
- } catch (error) {
- this.setState({ gotErrorRegistrationServiceInfo: true });
- throw new Error(error);
- }
- }
-
- selectOS(os) {
- this.setState({
- selectedOS: os,
- selectedVersion: '',
- selectedArchitecture: '',
- selectedSYS: '',
- });
- }
-
- systemSelector() {
- if (
- this.state.selectedVersion === 'redhat7' ||
- this.state.selectedVersion === 'amazonlinux2022' ||
- this.state.selectedVersion === 'centos7' ||
- this.state.selectedVersion === 'suse11' ||
- this.state.selectedVersion === 'suse12' ||
- this.state.selectedVersion === 'oraclelinux5' ||
- this.state.selectedVersion === 'oraclelinux6' ||
- this.state.selectedVersion === '22' ||
- this.state.selectedVersion === 'amazonlinux2' ||
- this.state.selectedVersion === 'debian8' ||
- this.state.selectedVersion === 'debian9' ||
- this.state.selectedVersion === 'debian10' ||
- this.state.selectedVersion === 'busterorgreater' ||
- this.state.selectedVersion === 'ubuntu15' ||
- this.state.selectedVersion === 'leap15'
- ) {
- return 'sudo systemctl daemon-reload\nsudo systemctl enable wazuh-agent\nsudo systemctl start wazuh-agent';
- } else if (
- this.state.selectedVersion === 'redhat5' ||
- this.state.selectedVersion === 'redhat6' ||
- this.state.selectedVersion === 'centos5' ||
- this.state.selectedVersion === 'centos6' ||
- this.state.selectedVersion === 'amazonlinux1' ||
- this.state.selectedVersion === 'debian7' ||
- this.state.selectedVersion === 'ubuntu14'
- ) {
- return 'service wazuh-agent start';
- } else {
- return '';
- }
- }
-
- systemSelectorNet() {
- if (
- this.state.selectedVersion === 'windowsxp' ||
- this.state.selectedVersion === 'windowsserver2008' ||
- this.state.selectedVersion === 'windows7'
- ) {
- return 'NET START Wazuh';
- } else {
- return '';
- }
- }
-
- systemSelectorWazuhControlMacos() {
- if (this.state.selectedVersion == 'sierra') {
- return 'sudo /Library/Ossec/bin/wazuh-control start';
- } else {
- return '';
- }
- }
-
- systemSelectorWazuhControl() {
- if (
- this.state.selectedVersion === 'solaris10' ||
- this.state.selectedVersion === 'solaris11' ||
- this.state.selectedVersion === '6.1 TL9' ||
- this.state.selectedVersion === '3.12.12'
- ) {
- return '/var/ossec/bin/wazuh-control start';
- } else {
- return '';
- }
- }
-
- systemSelectorInitD() {
- if (this.state.selectedVersion === '11.31') {
- return '/sbin/init.d/wazuh-agent start';
- } else {
- return '';
- }
- }
-
- selectSYS(sys) {
- this.setState({ selectedSYS: sys });
- }
-
- setServerAddress(serverAddress) {
- this.setState({ serverAddress });
- }
-
- setAgentName(event) {
- const validation = /^[a-z0-9-_.]+$/i;
- if (
- (validation.test(event.target.value) &&
- event.target.value.length >= 2) ||
- event.target.value.length <= 0
- ) {
- this.setState({
- agentName: event.target.value,
- agentNameError: false,
- badCharacters: [],
- });
- } else {
- let badCharacters = event.target.value
- .split('')
- .map(char => char.replace(validation, ''))
- .join('');
- badCharacters = badCharacters
- .split('')
- .map(char => char.replace(/\s/, 'whitespace'));
- const characters = [...new Set(badCharacters)];
- this.setState({
- agentName: event.target.value,
- badCharacters: characters,
- agentNameError: true,
- });
- }
- }
-
- setGroupName(selectedGroup) {
- this.setState({ selectedGroup });
- }
-
- setArchitecture(selectedArchitecture) {
- this.setState({ selectedArchitecture });
- }
-
- setVersion(selectedVersion) {
- this.setState({ selectedVersion, selectedArchitecture: '' });
- }
-
- setWazuhPassword(event) {
- this.setState({ wazuhPassword: event.target.value });
- }
-
- setShowPassword(event) {
- this.setState({ showPassword: event.target.checked });
- }
-
- obfuscatePassword(text) {
- let obfuscate = '';
- const regex = /WAZUH_REGISTRATION_PASSWORD=?\040?\'(.*?)\'[\"| ]/gm;
- const match = regex.exec(text);
- const password = match[1];
- if (password) {
- [...password].forEach(() => (obfuscate += '*'));
- text = text.replace(password, obfuscate);
- }
- return text;
- }
-
- async getGroups() {
- try {
- const result = await WzRequest.apiReq('GET', '/groups', {});
- return result.data.data.affected_items.map(item => ({
- label: item.name,
- id: item.name,
- }));
- } catch (error) {
- throw new Error(error);
- }
- }
-
- optionalDeploymentVariables() {
- const escapeQuotes = value => value.replace(/'/g, "\\'");
- let deployment =
- this.state.serverAddress &&
- `WAZUH_MANAGER='${escapeQuotes(this.state.serverAddress)}' `;
- if (this.state.selectedOS == 'win') {
- deployment += `WAZUH_REGISTRATION_SERVER='${escapeQuotes(
- this.state.serverAddress,
- )}' `;
- }
-
- if (this.state.needsPassword) {
- deployment += `WAZUH_REGISTRATION_PASSWORD='${escapeQuotes(
- this.state.wazuhPassword,
- )}' `;
- }
-
- if (this.state.udpProtocol) {
- deployment += "WAZUH_PROTOCOL='UDP' ";
- }
-
- if (this.state.selectedGroup.length) {
- deployment += `WAZUH_AGENT_GROUP='${this.state.selectedGroup
- .map(item => item.label)
- .join(',')}' `;
- }
-
- return deployment;
- }
-
- agentNameVariable() {
- let agentName = `WAZUH_AGENT_NAME='${this.state.agentName}' `;
- if (this.state.selectedArchitecture && this.state.agentName !== '') {
- return agentName;
- } else {
- return '';
- }
- }
-
- resolveRPMPackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case 'redhat5-i386':
- return `https://packages.wazuh.com/4.x/yum5/i386/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.el5.i386.rpm`;
- case 'redhat5-x86_64':
- return `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.el5.x86_64.rpm`;
- case 'redhat6-i386':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.i386.rpm`;
- case 'redhat6-aarch64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aarch64.rpm`;
- case 'redhat6-x86_64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- case 'redhat6-armhf':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.armv7hl.rpm`;
- case 'redhat7-i386':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.i386.rpm`;
- case 'redhat7-aarch64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aarch64.rpm`;
- case 'redhat7-x86_64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- case 'redhat7-armhf':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.armv7hl.rpm`;
- case 'redhat7-powerpc':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.ppc64le.rpm`;
- default:
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- }
- }
-
- resolveAlpinePackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case '3.12.12-i386':
- return 'https://packages.wazuh.com/key/alpine-devel%40wazuh.com-633d7457.rsa.pub && echo "https://packages.wazuh.com/4.x/alpine/v3.12/main"';
- case '3.12.12-aarch64':
- return 'https://packages.wazuh.com/key/alpine-devel%40wazuh.com-633d7457.rsa.pub && echo "https://packages.wazuh.com/4.x/alpine/v3.12/main"';
- case '3.12.12-x86_64':
- return 'https://packages.wazuh.com/key/alpine-devel%40wazuh.com-633d7457.rsa.pub && echo "https://packages.wazuh.com/4.x/alpine/v3.12/main"';
- case '3.12.12-x86':
- return 'https://packages.wazuh.com/key/alpine-devel%40wazuh.com-633d7457.rsa.pub && echo "https://packages.wazuh.com/4.x/alpine/v3.12/main"';
- case '3.12.12-armhf':
- return 'https://packages.wazuh.com/key/alpine-devel%40wazuh.com-633d7457.rsa.pub && echo "https://packages.wazuh.com/4.x/alpine/v3.12/main"';
- case '3.12.12-powerpc':
- return 'https://packages.wazuh.com/key/alpine-devel%40wazuh.com-633d7457.rsa.pub && echo "https://packages.wazuh.com/4.x/alpine/v3.12/main"';
- default:
- return 'https://packages.wazuh.com/key/alpine-devel%40wazuh.com-633d7457.rsa.pub && echo "https://packages.wazuh.com/4.x/alpine/v3.12/main"';
- }
- }
-
- resolveORACLELINUXPackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case 'oraclelinux5-i386':
- return `https://packages.wazuh.com/4.x/yum5/i386/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.el5.i386.rpm`;
- case 'oraclelinux5-x86_64':
- return `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.el5.x86_64.rpm`;
- case 'oraclelinux6-i386':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.i386.rpm`;
- case 'oraclelinux6-aarch64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aarch64.rpm`;
- case 'oraclelinux6-x86_64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- case 'oraclelinux6-armhf':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.armv7hl.rpm`;
- default:
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- }
- }
-
- resolveCENTPackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case 'centos5-i386':
- return `https://packages.wazuh.com/4.x/yum5/i386/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.el5.i386.rpm`;
- case 'centos5-x86_64':
- return `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.el5.x86_64.rpm`;
- case 'centos6-i386':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.i386.rpm`;
- case 'centos6-aarch64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aarch64.rpm`;
- case 'centos6-x86_64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- case 'centos6-armhf':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.armv7hl.rpm`;
- case 'centos7-i386':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.i386.rpm`;
- case 'centos7-aarch64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aarch64.rpm`;
- case 'centos7-x86_64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- case 'centos7-armhf':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.armv7hl.rpm`;
- case 'centos7-powerpc':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.ppc64le.rpm`;
- default:
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- }
- }
-
- resolveSUSEPackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case 'suse11-i386':
- return `https://packages.wazuh.com/4.x/yum5/i386/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.el5.i386.rpm`;
- case 'suse11-x86_64':
- return `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.el5.x86_64.rpm`;
- case 'suse12-i386':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.i386.rpm`;
- case 'suse12-aarch64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aarch64.rpm`;
- case 'suse12-x86_64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- case 'suse12-armhf':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.armv7hl.rpm`;
- case 'suse12-powerpc':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.ppc64le.rpm`;
- default:
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- }
- }
-
- resolveFEDORAPachage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case '22-i386':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.i386.rpm`;
- case '22-aarch64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aarch64.rpm`;
- case '22-x86_64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- case '22-armhf':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.armv7hl.rpm`;
- case '22-powerpc':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.ppc64le.rpm`;
- default:
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- }
- }
-
- resolveAMAZONLPackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case 'amazonlinux1-i386':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.i386.rpm`;
- case 'amazonlinux1-aarch64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aarch64.rpm`;
- case 'amazonlinux1-x86_64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- case 'amazonlinux1-armhf':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.armv7hl.rpm`;
- case 'amazonlinux2-i386':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.i386.rpm`;
- case 'amazonlinux2-aarch64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aarch64.rpm`;
- case 'amazonlinux2-x86_64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- case 'amazonlinux2-armhf':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.armv7hl.rpm`;
- case 'amazonlinux2022-i386':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.i386.rpm`;
- case 'amazonlinux2022-aarch64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aarch64.rpm`;
- case 'amazonlinux2022-x86_64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- case 'amazonlinux2022-armhf':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.armv7hl.rpm`;
- default:
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- }
- }
-
- resolveDEBPackage() {
- switch (`${this.state.selectedArchitecture}`) {
- case 'i386':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_i386.deb`;
- case 'aarch64':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_arm64.deb`;
- case 'armhf':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_armhf.deb`;
- case 'x86_64':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_amd64.deb`;
- case 'powerpc':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_ppc64el.deb`;
- default:
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_amd64.deb`;
- }
- }
-
- resolveRASPBIANPackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case 'busterorgreater-i386':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_i386.deb`;
- case 'busterorgreater-aarch64':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_arm64.deb`;
- case 'busterorgreater-armhf':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_armhf.deb`;
- case 'busterorgreater-x86_64':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_amd64.deb`;
- case 'busterorgreater-powerpc':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_ppc64el.deb`;
- default:
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_amd64.deb`;
- }
- }
-
- resolveUBUNTUPackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case 'ubuntu14-i386':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_i386.deb`;
- case 'ubuntu14-aarch64':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_arm64.deb`;
- case 'ubuntu14-armhf':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_armhf.deb`;
- case 'ubuntu14-x86_64':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_amd64.deb`;
- case 'ubuntu15-i386':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_i386.deb`;
- case 'ubuntu15-aarch64':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_arm64.deb`;
- case 'ubuntu15-armhf':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_armhf.deb`;
- case 'ubuntu15-x86_64':
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_amd64.deb`;
- default:
- return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}${this.addToVersion}_amd64.deb`;
- }
- }
-
- resolveOPENSUSEPackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case 'leap15-i386':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.i386.rpm`;
- case 'leap15-aarch64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aarch64.rpm`;
- case 'leap15-x86_64':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- case 'leap15-armhf':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.armv7hl.rpm`;
- case 'leap15-powerpc':
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.ppc64le.rpm`;
- default:
- return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- }
- }
-
- resolveSOLARISPackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case 'solaris10-i386':
- return `https://packages.wazuh.com/4.x/solaris/i386/10/wazuh-agent_v${this.state.wazuhVersion}-sol10-i386.pkg`;
- case 'solaris10-sparc':
- return `https://packages.wazuh.com/4.x/solaris/sparc/10/wazuh-agent_v${this.state.wazuhVersion}-sol10-sparc.pkg`;
- case 'solaris11-i386':
- return `https://packages.wazuh.com/4.x/solaris/i386/11/wazuh-agent_v${this.state.wazuhVersion}-sol11-i386.p5p`;
- case 'solaris11-sparc':
- return `https://packages.wazuh.com/4.x/solaris/sparc/11/wazuh-agent_v${this.state.wazuhVersion}-sol11-sparc.p5p`;
- default:
- return `https://packages.wazuh.com/4.x/solaris/sparc/11/wazuh-agent_v${this.state.wazuhVersion}-sol11-sparc.p5p`;
- }
- }
-
- resolveAIXPackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case '6.1 TL9-powerpc':
- return `https://packages.wazuh.com/4.x/aix/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aix.ppc.rpm`;
- default:
- return `https://packages.wazuh.com/4.x/aix/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.aix.ppc.rpm`;
- }
- }
-
- resolveHPPackage() {
- switch (
- `${this.state.selectedVersion}-${this.state.selectedArchitecture}`
- ) {
- case '11.31-itanium2':
- return `https://packages.wazuh.com/4.x/hp-ux/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}-hpux-11v3-ia64.tar`;
- default:
- return `https://packages.wazuh.com/4.x/hp-ux/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}-hpux-11v3-ia64.tar`;
- }
- }
-
- optionalPackages() {
- switch (this.state.selectedOS) {
- case 'rpm':
- return this.resolveRPMPackage();
- case 'cent':
- return this.resolveCENTPackage();
- case 'deb':
- return this.resolveDEBPackage();
- case 'ubu':
- return this.resolveUBUNTUPackage();
- case 'open':
- return this.resolveOPENSUSEPackage();
- case 'sol':
- return this.resolveSOLARISPackage();
- case 'aix':
- return this.resolveAIXPackage();
- case 'hp':
- return this.resolveHPPackage();
- case 'amazonlinux':
- return this.resolveAMAZONLPackage();
- case 'fedora':
- return this.resolveFEDORAPachage();
- case 'oraclelinux':
- return this.resolveORACLELINUXPackage();
- case 'suse':
- return this.resolveSUSEPackage();
- case 'raspbian':
- return this.resolveRASPBIANPackage();
- case 'alpine':
- return this.resolveAlpinePackage();
- default:
- return `https://packages.wazuh.com/4.x/yum/x86_64/wazuh-agent-${this.state.wazuhVersion}${this.addToVersion}.x86_64.rpm`;
- }
- }
-
- checkMissingOSSelection() {
- if (!this.state.selectedOS) {
- return ['Operating system'];
- }
- switch (this.state.selectedOS) {
- case 'rpm':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'cent':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'deb':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'ubu':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'win':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'macos':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'open':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'sol':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'aix':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'hp':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'amazonlinux':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'fedora':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'oraclelinux':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'suse':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'raspbian':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- case 'alpine':
- return [
- ...(!this.state.selectedVersion ? ['OS version'] : []),
- ...(this.state.selectedVersion && !this.state.selectedArchitecture
- ? ['OS architecture']
- : []),
- ];
- default:
- return [];
- }
- }
-
- getHighlightCodeLanguage(selectedSO) {
- if (selectedSO.toLowerCase() === 'win') {
- return 'powershell';
- } else {
- return 'bash';
- }
- }
-
- render() {
- const appVersionMajorDotMinor = this.state.wazuhVersion
- .split('.')
- .slice(0, 2)
- .join('.');
- const urlCheckConnectionDocumentation = webDocumentationLink(
- 'user-manual/agents/agent-connection.html',
- appVersionMajorDotMinor,
- );
-
- const urlWazuhAgentEnrollment = webDocumentationLink(
- 'user-manual/agent-enrollment/index.html',
- appVersionMajorDotMinor,
- );
-
- const urlWindowsPackage = `https://packages.wazuh.com/4.x/windows/wazuh-agent-${this.state.wazuhVersion}-1.msi`;
- const missingOSSelection = this.checkMissingOSSelection();
- const warningForAgentName =
- 'The agent name must be unique. It can’t be changed once the agent has been enrolled.';
-
- const agentName = (
-
-
- The deployment sets the endpoint hostname as the agent name by
- default. Optionally, you can set the agent name below.
-
- Assign an agent name
-
-
- ` "${char}"`)}
- ${this.state.badCharacters.length <= 1 ? 'is' : 'are'}
- not valid. Allowed characters are A-Z, a-z, ".", "-", "_"`,
- ]}
- >
- this.setAgentName(event)}
- />
-
-
-
-
-
- );
- const groupInput = (
- <>
- {!this.state.groups.length && (
- <>
-
- >
- )}
- >
- );
-
- const agentGroup = (
-
- Select one or more existing groups
- {
- this.setGroupName(group);
- }}
- isDisabled={!this.state.groups.length}
- isClearable={true}
- data-test-subj='demoComboBox'
- />
-
- );
- const passwordInput = (
- this.setWazuhPassword(event)}
- />
- );
-
- const codeBlock = {
- zIndex: '100',
- };
-
- /*** macOS installation script customization ***/
-
- // Set macOS installation script with environment variables
- const macOSInstallationOptions =
- `${this.optionalDeploymentVariables()}${this.agentNameVariable()}`
- .replace(/\' ([a-zA-Z])/g, "' && $1") // Separate environment variables with &&
- .replace(/\"/g, '\\"') // Escape double quotes
- .trim();
-
- // If no variables are set, the echo will be empty
- const macOSInstallationSetEnvVariablesScript = macOSInstallationOptions
- ? `sudo echo "${macOSInstallationOptions}" > /tmp/wazuh_envs && `
- : ``;
-
- // Merge environment variables with installation script
- const macOSInstallationScript = `curl -so wazuh-agent.pkg https://packages.wazuh.com/4.x/macos/wazuh-agent-${this.state.wazuhVersion}-1.${this.state.selectedArchitecture}.pkg && ${macOSInstallationSetEnvVariablesScript}sudo installer -pkg ./wazuh-agent.pkg -target /`;
-
- /*** end macOS installation script customization ***/
-
- const customTexts = {
- rpmText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
- alpineText: `wget -O /etc/apk/keys/alpine-devel@wazuh.com-633d7457.rsa.pub ${this.optionalPackages()} >> /etc/apk/repositories && \
-apk update && \
-apk add wazuh-agent=${this.state.wazuhVersion}-r1`,
- centText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
- debText: `curl -so wazuh-agent.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}dpkg -i ./wazuh-agent.deb`,
- ubuText: `curl -so wazuh-agent.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}dpkg -i ./wazuh-agent.deb`,
- macosText: macOSInstallationScript,
- winText:
- this.state.selectedVersion == 'windowsxp' ||
- this.state.selectedVersion == 'windowsserver2008'
- ? `msiexec.exe /i wazuh-agent-${
- this.state.wazuhVersion
- }-1.msi /q ${this.optionalDeploymentVariables()}${this.agentNameVariable()}`
- : `Invoke-WebRequest -Uri https://packages.wazuh.com/4.x/windows/wazuh-agent-${
- this.state.wazuhVersion
- }-1.msi -OutFile \${env:tmp}\\wazuh-agent.msi; msiexec.exe /i \${env:tmp}\\wazuh-agent.msi /q ${this.optionalDeploymentVariables()}${this.agentNameVariable()}`,
- openText: `sudo rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}zypper install -y ${this.optionalPackages()}`,
- solText: `sudo curl -so ${
- this.state.selectedVersion == 'solaris11'
- ? 'wazuh-agent.p5p'
- : 'wazuh-agent.pkg'
- } ${this.optionalPackages()} && ${
- this.state.selectedVersion == 'solaris11'
- ? 'pkg install -g wazuh-agent.p5p wazuh-agent'
- : 'pkgadd -d wazuh-agent.pkg'
- }`,
- aixText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}rpm -ivh ${this.optionalPackages()}`,
- hpText: `cd / && sudo curl -so wazuh-agent.tar ${this.optionalPackages()} && sudo groupadd wazuh && sudo useradd -G wazuh wazuh && sudo tar -xvf wazuh-agent.tar`,
- amazonlinuxText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
- fedoraText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
- oraclelinuxText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
- suseText: `sudo rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}zypper install -y ${this.optionalPackages()}`,
- raspbianText: `curl -so wazuh-agent.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}dpkg -i ./wazuh-agent.deb`,
- };
-
- const field = `${this.state.selectedOS}Text`;
- const text = customTexts[field];
- const language = this.getHighlightCodeLanguage(this.state.selectedOS);
- const warningUpgrade =
- 'If the installer finds another Wazuh agent in the system, it will upgrade it preserving the configuration.';
- const textAndLinkToCheckConnectionDocumentation = (
-
- To verify the connection with the Wazuh server, please follow this{' '}
-
- document.
-
-
- );
-
- const warningCommand = (
- <>
-
- Please
- download
- the package from our repository and copy it to the Windows system
- where you are going to install it. Then run the following command to
- perform the installation:
-
- >
- );
-
- const windowsAdvice = this.state.selectedOS === 'win' && (
- <>
-
-
-
-
- You will need administrator privileges to perform this
- installation.
-
-
-
- PowerShell 3.0 or greater is required.
-
-
-
- Keep in mind you need to run this command in a Windows PowerShell
- terminal.
-
-
-
- >
- );
- const restartAgentCommand =
- this.restartAgentCommand[this.state.selectedOS];
- const onTabClick = selectedTab => {
- this.selectSYS(selectedTab.id);
- };
-
- const calloutErrorRegistrationServiceInfo = this.state
- .gotErrorRegistrationServiceInfo ? (
-
- ) : null;
-
- const guide = (
-
- {this.state.gotErrorRegistrationServiceInfo ? (
-
- ) : (
- this.state.selectedOS && (
-
- {this.state.agentName.length > 0 ? (
-
- You can use this command to install and enroll the Wazuh
- agent.
-
- ) : (
-
- You can use this command to install and enroll the Wazuh
- agent in one or more hosts.
-
- )}
-
-
- {!this.state.connectionSecure && (
- <>
-
- {/** Warning connection NO SECURE */}
-
- Warning: there's no{' '}
-
- secure protocol configured
- {' '}
- and agents will not be able to communicate with the
- manager.
- >
- }
- iconType='iInCircle'
- />
- {/** END Warning connection NO SECURE */}
- >
- )}
-
- {windowsAdvice}
- {['windowsxp', 'windowsserver2008'].includes(
- this.state.selectedVersion,
- ) && (
- <>
-
-
- >
- )}
-
-
- {this.state.wazuhPassword &&
- !this.state.showPassword &&
- !['sol', 'hp', 'alpine'].includes(this.state.selectedOS)
- ? this.obfuscatePassword(text)
- : text}
-
-
- {copy => (
-
- )}
-
-
- {this.state.selectedVersion == 'solaris10' ||
- this.state.selectedVersion == 'solaris11' ? (
- <>
-
- Might require some extra installation{' '}
-
- steps
-
- .
-
- }
- >
-
-
- After installing the agent, you need to enroll it in
- the Wazuh server. Check the Wazuh agent enrollment{' '}
-
- Wazuh agent enrollment
- {' '}
- section to learn more.
-
- }
- >
- >
- ) : this.state.selectedVersion == '6.1 TL9' ? (
- <>
-
- Might require some extra installation{' '}
-
- steps
-
- .
-
- }
- >
-
- >
- ) : this.state.selectedVersion == '11.31' ? (
- <>
-
- Might require some extra installation{' '}
-
- steps
-
- .
-
- }
- >
-
-
- After installing the agent, you need to enroll it in
- the Wazuh server. Check the Wazuh agent enrollment{' '}
-
- Wazuh agent enrollment{' '}
-
- section to learn more.
-
- }
- >
- >
- ) : this.state.selectedVersion == '3.12.12' ? (
- <>
-
- Might require some extra installation{' '}
-
- steps
-
- .
-
- }
- >
-
-
- After installing the agent, you need to enroll it in
- the Wazuh server. Check the Wazuh agent enrollment{' '}
-
- Wazuh agent enrollment{' '}
-
- section to learn more.
-
- }
- >
- >
- ) : this.state.selectedVersion == 'debian7' ||
- this.state.selectedVersion == 'debian8' ||
- this.state.selectedVersion == 'debian9' ||
- this.state.selectedVersion == 'debian10' ? (
- <>
-
- Might require some extra installation{' '}
-
- steps
-
- .
-
- }
- >
-
- >
- ) : (
- ''
- )}
- {this.state.needsPassword &&
- !['sol', 'hp', 'alpine'].includes(this.state.selectedOS) ? (
- this.setShowPassword(active)}
- />
- ) : (
- ''
- )}
-
-
- )
- )}
-
- );
-
- const tabSysV = [
- {
- id: 'sysV',
- name: 'SysV Init',
- content: (
-
-
-
-
-
- {this.systemSelector()}
-
-
- {copy => (
-
- )}
-
-
-
- {textAndLinkToCheckConnectionDocumentation}
-
-
- ),
- },
- ];
-
- const tabSystemD = [
- {
- id: 'systemd',
- name: 'Systemd',
- content: (
-
-
-
-
-
- {this.systemSelector()}
-
-
- {copy => (
-
- )}
-
-
-
- {textAndLinkToCheckConnectionDocumentation}
-
-
- ),
- },
- ];
-
- const tabNet = [
- {
- id: 'NET',
- name: 'NET',
- content: (
-
-
-
-
-
- {this.systemSelectorNet()}
-
-
- {copy => (
-
- )}
-
-
-
- {textAndLinkToCheckConnectionDocumentation}
-
-
- ),
- },
- ];
-
- const tabWazuhControlMacos = [
- {
- id: 'Wazuh-control-macos',
- name: 'Wazuh-control-macos',
- content: (
-
-
-
-
-
- {this.systemSelectorWazuhControlMacos()}
-
-
- {copy => (
-
- )}
-
-
-
- {textAndLinkToCheckConnectionDocumentation}
-
-
- ),
- },
- ];
-
- const tabWazuhControl = [
- {
- id: 'Wazuh-control',
- name: 'Wazuh-control',
- content: (
-
-
-
-
-
- {this.systemSelectorWazuhControl()}
-
-
- {copy => (
-
- )}
-
-
-
- {textAndLinkToCheckConnectionDocumentation}
-
-
- ),
- },
- ];
-
- const tabInitD = [
- {
- id: 'Init.d',
- name: 'Init.d',
- content: (
-
-
-
-
-
- {this.systemSelectorInitD()}
-
-
- {copy => (
-
- )}
-
-
-
- {textAndLinkToCheckConnectionDocumentation}
-
-
- ),
- },
- ];
-
- const onChangeServerAddress = async nodeSelected => {
- this.setState({
- serverAddress: nodeSelected,
- udpProtocol: this.state.haveUdpProtocol,
- connectionSecure: this.state.haveConnectionSecure,
- });
- };
-
- const steps = [
- {
- title: 'Choose the operating system',
- children: (
- this.selectOS(os)}
- />
- ),
- },
- ...(this.state.selectedOS == 'rpm'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'oraclelinux'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'raspbian'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'amazonlinux'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'cent'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'fedora'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'deb'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'ubu'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'win'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'macos'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'suse'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'open'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'sol'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'aix'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'hp'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedOS == 'alpine'
- ? [
- {
- title: 'Choose the version',
- children: (
- this.setVersion(version)}
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedVersion == 'centos5' ||
- this.state.selectedVersion == 'redhat5' ||
- this.state.selectedVersion == 'oraclelinux5' ||
- this.state.selectedVersion == 'suse11'
- ? [
- {
- title: 'Choose the architecture',
- children: (
-
- this.setArchitecture(architecture)
- }
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedVersion == 'leap15'
- ? [
- {
- title: 'Choose the architecture',
- children: (
-
- this.setArchitecture(architecture)
- }
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedVersion == '3.12.12'
- ? [
- {
- title: 'Choose the architecture',
- children: (
-
- this.setArchitecture(architecture)
- }
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedVersion == 'centos6' ||
- this.state.selectedVersion == 'oraclelinux6' ||
- this.state.selectedVersion == 'amazonlinux1' ||
- this.state.selectedVersion == 'redhat6' ||
- this.state.selectedVersion == 'amazonlinux2022' ||
- this.state.selectedVersion == 'amazonlinux2' ||
- this.state.selectedVersion == 'debian7' ||
- this.state.selectedVersion == 'debian8' ||
- this.state.selectedVersion == 'ubuntu14' ||
- this.state.selectedVersion == 'ubuntu15'
- ? [
- {
- title: 'Choose the architecture',
- children: (
-
- this.setArchitecture(architecture)
- }
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedVersion == 'centos7' ||
- this.state.selectedVersion == 'redhat7' ||
- this.state.selectedVersion == 'suse12' ||
- this.state.selectedVersion == '22' ||
- this.state.selectedVersion == 'debian9' ||
- this.state.selectedVersion == 'busterorgreater'
- ? [
- {
- title: 'Choose the architecture',
- children: (
-
- this.setArchitecture(architecture)
- }
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedVersion == 'windowsxp' ||
- this.state.selectedVersion == 'windowsserver2008' ||
- this.state.selectedVersion == 'windows7'
- ? [
- {
- title: 'Choose the architecture',
- children: (
-
- this.setArchitecture(architecture)
- }
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedVersion == 'sierra'
- ? [
- {
- title: 'Choose the architecture',
- children: (
-
- this.setArchitecture(architecture)
- }
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedVersion == 'solaris10' ||
- this.state.selectedVersion == 'solaris11'
- ? [
- {
- title: 'Choose the architecture',
- children: (
-
- this.setArchitecture(architecture)
- }
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedVersion == '6.1 TL9'
- ? [
- {
- title: 'Choose the architecture',
- children: (
-
- this.setArchitecture(architecture)
- }
- />
- ),
- },
- ]
- : []),
- ...(this.state.selectedVersion == '11.31'
- ? [
- {
- title: 'Choose the architecture',
- children: (
-
- this.setArchitecture(architecture)
- }
- />
- ),
- },
- ]
- : []),
- ...(!(
- this.state.selectedOS == 'hp' ||
- this.state.selectedOS == 'sol' ||
- this.state.selectedOS == 'alpine'
- )
- ? [
- {
- title: 'Wazuh server address',
- children: (
-
-
-
- ),
- },
- ]
- : []),
- ...(!(
- !this.state.needsPassword ||
- this.state.hidePasswordInput ||
- !!['solaris10', 'solaris11', '11.31', '3.12.12'].includes(
- this.state.selectedVersion,
- )
- )
- ? [
- {
- title: 'Wazuh password',
- children: {passwordInput} ,
- },
- ]
- : []),
- ...(!(
- this.state.selectedOS == 'hp' ||
- this.state.selectedOS == 'sol' ||
- this.state.selectedOS == 'alpine'
- )
- ? [
- {
- title: 'Optional settings',
- children: (
-
- {agentName}
- {groupInput}
- {agentGroup}
-
- ),
- },
- ]
- : []),
- {
- title: 'Install and enroll the agent',
- children: this.state.gotErrorRegistrationServiceInfo ? (
- calloutErrorRegistrationServiceInfo
- ) : this.state.agentNameError &&
- !['hp', 'sol', 'alpine'].includes(this.state.selectedOS) ? (
-
- ) : missingOSSelection.length ? (
-
- ) : (
- {guide}
- ),
- },
- ...(this.state.selectedOS == 'rpm' ||
- this.state.selectedOS == 'cent' ||
- this.state.selectedOS == 'suse' ||
- this.state.selectedOS == 'fedora' ||
- this.state.selectedOS == 'oraclelinux' ||
- this.state.selectedOS == 'amazonlinux' ||
- this.state.selectedOS == 'deb' ||
- this.state.selectedOS == 'raspbian' ||
- this.state.selectedOS == 'ubu' ||
- this.state.selectedOS == 'win' ||
- this.state.selectedOS == 'macos' ||
- this.state.selectedOS == 'open' ||
- this.state.selectedOS == 'sol' ||
- this.state.selectedOS == 'aix' ||
- this.state.selectedOS == 'hp' ||
- this.state.selectedOS == 'alpine' ||
- this.state.selectedOS == ''
- ? [
- {
- title: 'Start the agent',
- children: this.state.gotErrorRegistrationServiceInfo ? (
- calloutErrorRegistrationServiceInfo
- ) : this.state.agentNameError &&
- !['hp', 'sol', 'alpine'].includes(this.state.selectedOS) ? (
-
- ) : missingOSSelection.length ? (
-
- ) : (
-
- ),
- },
- ]
- : []),
- ...(!missingOSSelection.length &&
- this.state.selectedOS !== 'rpm' &&
- this.state.selectedOS !== 'deb' &&
- this.state.selectedOS !== 'cent' &&
- this.state.selectedOS !== 'ubu' &&
- this.state.selectedOS !== 'win' &&
- this.state.selectedOS !== 'macos' &&
- this.state.selectedOS !== 'open' &&
- this.state.selectedOS !== 'sol' &&
- this.state.selectedOS !== 'aix' &&
- this.state.selectedOS !== 'hp' &&
- this.state.selectedOS !== 'amazonlinux' &&
- this.state.selectedOS !== 'fedora' &&
- this.state.selectedOS !== 'oraclelinux' &&
- this.state.selectedOS !== 'suse' &&
- this.state.selectedOS !== 'raspbian' &&
- this.state.selectedOS !== 'alpine' &&
- restartAgentCommand
- ? [
- {
- title: 'Start the agent',
- children: this.state.gotErrorRegistrationServiceInfo ? (
- calloutErrorRegistrationServiceInfo
- ) : (
-
-
-
-
- {restartAgentCommand}
-
-
- {copy => (
-
- )}
-
-
-
-
- ),
- },
- ]
- : []),
- ];
-
- return (
-
-
-
-
-
-
-
-
-
- Deploy a new agent
-
-
-
- {this.props.hasAgents() && (
- this.props.addNewAgent(false)}
- iconType='cross'
- >
- Close
-
- )}
- {!this.props.hasAgents() && (
- this.props.reload()}
- iconType='refresh'
- >
- Refresh
-
- )}
-
-
-
- {this.state.loading && (
- <>
-
-
-
-
- >
- )}
- {!this.state.loading && (
-
-
-
- )}
-
-
-
-
-
-
- );
- }
- },
-);
diff --git a/plugins/main/public/controllers/agent/components/register-agent.scss b/plugins/main/public/controllers/agent/components/register-agent.scss
deleted file mode 100644
index e19973cad7..0000000000
--- a/plugins/main/public/controllers/agent/components/register-agent.scss
+++ /dev/null
@@ -1,14 +0,0 @@
-.registerAgent{
- min-height: calc(100vh - 100px);
- background: #fafbfd;
- .euiButtonGroup__buttons {
- display: grid;
- grid-template-columns: repeat(5, 1fr);
- grid-gap: 10px;
- padding: 0 3px;
- box-shadow: none;
- }
- .euiButtonGroup--medium .euiButtonGroupButton:not(:first-child), .euiButtonGroup--small .euiButtonGroupButton:not(:first-child) {
- margin-left: 0 !important;
- }
-}
\ No newline at end of file
diff --git a/plugins/main/public/controllers/agent/components/register-agent.test.js b/plugins/main/public/controllers/agent/components/register-agent.test.js
deleted file mode 100644
index 9d8b76ff23..0000000000
--- a/plugins/main/public/controllers/agent/components/register-agent.test.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import React from 'react';
-import { render, waitFor } from '@testing-library/react';
-import { RegisterAgent } from '../components/register-agent'
-
-// mocked getErrorOrchestrator
-const mockedGetErrorOrchestrator = {
- handleError: jest.fn(),
- };
-
- jest.mock('../../../react-services/common-services', () => {
- return {
- getErrorOrchestrator: () => mockedGetErrorOrchestrator,
- };
- });
-
-describe('RegisterAgent', () => {
- it('mount - RegisterAgent', async() => {
- const getWazuhVersion = jest.fn();
- const getCurrentApiAddress = jest.fn();
- const addNewAgent = jest.fn();
- const reload = jest.fn();
-
- const props = {
- hasAgents: true,
- getWazuhVersion,
- getCurrentApiAddress,
- addNewAgent,
- reload,
- };
- const { debug } = render( );
- debug()
- });
-});
diff --git a/plugins/main/public/controllers/agent/components/wz-accordion.tsx b/plugins/main/public/controllers/agent/components/wz-accordion.tsx
deleted file mode 100644
index f2e72ed167..0000000000
--- a/plugins/main/public/controllers/agent/components/wz-accordion.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import React, { useState } from 'react';
-import {
- EuiPanel,
- EuiSpacer,
- EuiAccordion,
- EuiButtonGroup,
- htmlIdGenerator,
-} from '@elastic/eui';
-import { osButtons } from '../wazuh-config';
-
-export const PrincipalButtonGroup = ({
- legend,
- options,
- idSelected,
- onChange,
-}) => {
- return (
- <>
-
-
-
-
-
- >
- );
-};
-
-export const WzAccordion = ({ children }) => {
- const [isAccordionOpen, setIsAccordionOpen] = useState(false);
- const rightArrowAccordionId = htmlIdGenerator('wz-accordion')();
- return (
- setIsAccordionOpen(isOpen)}
- className={'action-btn-td'}
- >
-
-
- {children}
-
-
- );
-};
diff --git a/plugins/main/public/controllers/agent/index.js b/plugins/main/public/controllers/agent/index.js
index 51a445bb00..960ac79295 100644
--- a/plugins/main/public/controllers/agent/index.js
+++ b/plugins/main/public/controllers/agent/index.js
@@ -9,30 +9,28 @@
*
* Find more information about this on the LICENSE file.
*/
-import { AgentsPreviewController } from './agents-preview';
import { AgentsController } from './agents';
-import { RegisterAgent } from '../../controllers/register-agent/containers/register-agent/register-agent';
+import { RegisterAgent } from '../../components/endpoints-summary/register-agent/containers/register-agent/register-agent';
import { ExportConfiguration } from './components/export-configuration';
import { AgentsWelcome } from '../../components/common/welcome/agents-welcome';
import { Mitre } from '../../components/overview';
-import { AgentsPreview } from './components/agents-preview';
-import { AgentsTable } from './components/agents-table';
+import { AgentsTable } from '../../components/endpoints-summary/table/agents-table';
import { MainModule } from '../../components/common/modules/main';
import { MainSyscollector } from '../../components/agents/syscollector/main';
import { MainAgentStats } from '../../components/agents/stats';
import { getAngularModule } from '../../kibana-services';
+import { MainEndpointsSummary } from '../../components/endpoints-summary';
const app = getAngularModule();
app
.controller('agentsController', AgentsController)
- .controller('agentsPreviewController', AgentsPreviewController)
.value('RegisterAgent', RegisterAgent)
.value('ExportConfiguration', ExportConfiguration)
.value('AgentsWelcome', AgentsWelcome)
- .value('AgentsPreview', AgentsPreview)
.value('Mitre', Mitre)
.value('AgentsTable', AgentsTable)
.value('MainSyscollector', MainSyscollector)
.value('MainAgentStats', MainAgentStats)
- .value('MainModule', MainModule);
+ .value('MainModule', MainModule)
+ .value('MainEndpointsSummary', MainEndpointsSummary);
diff --git a/plugins/main/public/controllers/agent/register-agent/__snapshots__/register-agent-button-group.test.tsx.snap b/plugins/main/public/controllers/agent/register-agent/__snapshots__/register-agent-button-group.test.tsx.snap
deleted file mode 100644
index 2d214a76d1..0000000000
--- a/plugins/main/public/controllers/agent/register-agent/__snapshots__/register-agent-button-group.test.tsx.snap
+++ /dev/null
@@ -1,138 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`RegisterAgentButtonGroup should render correctly 1`] = `
-Object {
- "asFragment": [Function],
- "baseElement":
-
-
-
- Test legend
-
-
-
-
-
-
- test
-
-
-
-
-
-
- ,
- "container":
-
-
- Test legend
-
-
-
-
-
-
- test
-
-
-
-
-
-
,
- "debug": [Function],
- "findAllByAltText": [Function],
- "findAllByDisplayValue": [Function],
- "findAllByLabelText": [Function],
- "findAllByPlaceholderText": [Function],
- "findAllByRole": [Function],
- "findAllByTestId": [Function],
- "findAllByText": [Function],
- "findAllByTitle": [Function],
- "findByAltText": [Function],
- "findByDisplayValue": [Function],
- "findByLabelText": [Function],
- "findByPlaceholderText": [Function],
- "findByRole": [Function],
- "findByTestId": [Function],
- "findByText": [Function],
- "findByTitle": [Function],
- "getAllByAltText": [Function],
- "getAllByDisplayValue": [Function],
- "getAllByLabelText": [Function],
- "getAllByPlaceholderText": [Function],
- "getAllByRole": [Function],
- "getAllByTestId": [Function],
- "getAllByText": [Function],
- "getAllByTitle": [Function],
- "getByAltText": [Function],
- "getByDisplayValue": [Function],
- "getByLabelText": [Function],
- "getByPlaceholderText": [Function],
- "getByRole": [Function],
- "getByTestId": [Function],
- "getByText": [Function],
- "getByTitle": [Function],
- "queryAllByAltText": [Function],
- "queryAllByDisplayValue": [Function],
- "queryAllByLabelText": [Function],
- "queryAllByPlaceholderText": [Function],
- "queryAllByRole": [Function],
- "queryAllByTestId": [Function],
- "queryAllByText": [Function],
- "queryAllByTitle": [Function],
- "queryByAltText": [Function],
- "queryByDisplayValue": [Function],
- "queryByLabelText": [Function],
- "queryByPlaceholderText": [Function],
- "queryByRole": [Function],
- "queryByTestId": [Function],
- "queryByText": [Function],
- "queryByTitle": [Function],
- "rerender": [Function],
- "unmount": [Function],
-}
-`;
diff --git a/plugins/main/public/controllers/agent/register-agent/register-agent-button-group.test.tsx b/plugins/main/public/controllers/agent/register-agent/register-agent-button-group.test.tsx
deleted file mode 100644
index 88c8582390..0000000000
--- a/plugins/main/public/controllers/agent/register-agent/register-agent-button-group.test.tsx
+++ /dev/null
@@ -1,111 +0,0 @@
-import React from 'react';
-import '@testing-library/jest-dom';
-import { render } from '@testing-library/react';
-import RegisterAgentButtonGroup from './register-agent-button-group';
-
-jest.mock(
- '../../../../../../node_modules/@elastic/eui/lib/services/accessibility/html_id_generator',
- () => ({
- htmlIdGenerator: () => () => 'htmlId',
- })
-);
-
-
-describe('RegisterAgentButtonGroup', () => {
- it('should render correctly', () => {
- const buttonsOpts = [{ id: 'test', label: 'test' }];
- const wrapper = render(
- {}}
- />,
- );
- expect(wrapper).toMatchSnapshot();
- });
-
- it('should render the label text', () => {
- const buttonsOpts = [{ id: 'test', label: 'test' }];
- const { getByText } = render(
- {}}
- />,
- );
- expect(getByText('Test legend')).toBeInTheDocument();
- });
-
- it('should auto select button when the group have only one button in options list', () => {
- const mockedOnChange = jest.fn();
- const buttonsOpts = [{ id: 'test', label: 'test' }];
- render(
- ,
- );
- expect(mockedOnChange).toBeCalledWith(buttonsOpts[0].id);
- });
-
- it('should auto select button when the group have an option with the default property in true', () => {
- const mockedOnChange = jest.fn();
- const buttonsOpts = [
- { id: 'test', label: 'test' },
- { id: 'auto-selected', label: 'test2', default: true },
- ];
- render(
- ,
- );
- expect(mockedOnChange).toBeCalledWith(buttonsOpts[1].id);
- });
-
- it('should auto select the first button when the group have more than one option with the default property in true', () => {
- const mockedOnChange = jest.fn();
- const buttonsOpts = [
- { id: 'test', label: 'test' },
- { id: 'auto-selected', label: 'test2', default: true },
- { id: 'auto-selected2', label: 'test3', default: true },
- ];
- render(
- ,
- );
- expect(mockedOnChange).toBeCalledWith(buttonsOpts[1].id);
- });
-
- it('should render the correct number of buttons defined in the options received', () => {
- const mockedOnChange = jest.fn();
- const buttonsOpts = [
- { id: 'test', label: 'test' },
- { id: 'test2', label: 'test2' },
- { id: 'test3', label: 'test3' },
- ];
- const { getByText, getByRole } = render(
- ,
- );
-
- buttonsOpts.forEach((button) => {
- expect(getByText(button.label)).toBeInTheDocument();
- })
- });
-
-});
diff --git a/plugins/main/public/controllers/agent/register-agent/register-agent-button-group.tsx b/plugins/main/public/controllers/agent/register-agent/register-agent-button-group.tsx
deleted file mode 100644
index bf7b40546e..0000000000
--- a/plugins/main/public/controllers/agent/register-agent/register-agent-button-group.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { EuiButtonGroup } from '@elastic/eui';
-import React, { useEffect } from 'react';
-
-interface RegisterAgentButtonGroupProps {
- legend: string;
- options: Array<{id: string, label: string, default?: boolean}>;
- idSelected: string;
- onChange: (value: string) => void;
-}
-
-export default function RegisterAgentButtonGroup({
- legend,
- options,
- idSelected,
- onChange,
-}: RegisterAgentButtonGroupProps) {
-
- useEffect(() => {
- setDefaultOptions();
- }, []);
-
- useEffect(() => {
- setDefaultOptions();
- }, [options, idSelected])
-
- /**
- * Set default option
- * Autoselect option when there is only one option
- * Autoselect option when an option have default property in true
- */
- const setDefaultOptions = () => {
- if(!idSelected){ // prevent autoselect every time the options change
- if (options.length === 1) {
- idSelected = options[0].id;
- onChange(options[0].id);
- }else if(options.filter(item => item.default).length > 0){
- const defaultOption = options.filter(item => item.default)[0].id
- idSelected = defaultOption;
- onChange(defaultOption);
- }
- }
- };
-
- return (
-
- );
-}
diff --git a/plugins/main/public/controllers/agent/register-agent/steps/__snapshots__/server-address.test.tsx.snap b/plugins/main/public/controllers/agent/register-agent/steps/__snapshots__/server-address.test.tsx.snap
deleted file mode 100644
index 5326643f51..0000000000
--- a/plugins/main/public/controllers/agent/register-agent/steps/__snapshots__/server-address.test.tsx.snap
+++ /dev/null
@@ -1,84 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Server Address Combobox should match snapshot 1`] = `
-
-
-
- This is the address the agent uses to communicate with the Wazuh server. It can be an IP address or a fully qualified domain name (FQDN).
-
-
-
-
-`;
diff --git a/plugins/main/public/controllers/agent/register-agent/steps/index.ts b/plugins/main/public/controllers/agent/register-agent/steps/index.ts
deleted file mode 100644
index 5732aed9ae..0000000000
--- a/plugins/main/public/controllers/agent/register-agent/steps/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './server-address';
\ No newline at end of file
diff --git a/plugins/main/public/controllers/agent/register-agent/steps/server-address.test.tsx b/plugins/main/public/controllers/agent/register-agent/steps/server-address.test.tsx
deleted file mode 100644
index ce3e8c513e..0000000000
--- a/plugins/main/public/controllers/agent/register-agent/steps/server-address.test.tsx
+++ /dev/null
@@ -1,221 +0,0 @@
-import React from 'react';
-import { render, fireEvent } from '@testing-library/react';
-import '@testing-library/jest-dom';
-import { act } from 'react-dom/test-utils';
-import ServerAddress from './server-address';
-import * as registerAgentsUtils from '../../components/register-agent-service';
-
-jest.mock('../../../../kibana-services', () => ({
- ...(jest.requireActual('../../../../kibana-services') as object),
- getHttp: jest.fn().mockReturnValue({
- basePath: {
- get: () => {
- return 'http://localhost:5601';
- },
- prepend: url => {
- return `http://localhost:5601${url}`;
- },
- },
- }),
- getCookies: jest.fn().mockReturnValue({
- set: (name, value, options) => {
- return true;
- },
- get: () => {
- return '{}';
- },
- remove: () => {
- return;
- },
- }),
-}));
-
-const mockedNodesIps = [
- {
- name: 'master-node',
- type: 'master',
- version: '4.x',
- ip: 'wazuh-master',
- },
- {
- name: 'worker1',
- type: 'worker',
- version: '4.x',
- ip: '172.26.0.7',
- },
- {
- name: 'worker2',
- type: 'worker',
- version: '4.x',
- ip: '172.26.0.6',
- },
-];
-
-const mockedClusterNodes = {
- data: {
- data: {
- affected_items: mockedNodesIps,
- total_affected_items: mockedNodesIps.length,
- total_failed_items: 0,
- failed_items: [],
- },
- message: 'All selected nodes information was returned',
- error: 0,
- },
-};
-
-const promiseFetchOptions = Promise.resolve(
- registerAgentsUtils.parseNodesInOptions(mockedClusterNodes),
-);
-const mockedFetchOptions = () => promiseFetchOptions;
-
-describe('Server Address Combobox', () => {
- afterEach(() => {
- jest.clearAllMocks();
- });
-
- it('should render correctly', () => {
- const { container } = render(
- {}}
- fetchOptions={() =>
- Promise.resolve(
- registerAgentsUtils.parseNodesInOptions(mockedClusterNodes),
- )
- }
- />,
- );
- expect(container).toBeInTheDocument();
- });
-
- it('should match snapshot', () => {
- const { container } = render(
- {}} fetchOptions={mockedFetchOptions} />,
- );
- expect(container).toMatchSnapshot();
- });
-
- it('should set default combobox value and disable input when defaultValue is defined', async () => {
- const onChangeMocked = jest.fn();
- const { container, getByText, getByRole } = render(
- ,
- );
-
- await act(async () => {
- await promiseFetchOptions;
- expect(onChangeMocked).toBeCalledTimes(1);
- expect(onChangeMocked).toBeCalledWith([
- { label: 'default-dns', value: 'default-dns', nodetype: 'custom' },
- ]);
- expect(getByText('default-dns')).toBeInTheDocument();
- expect(getByRole('textbox')).toHaveAttribute('disabled');
- expect(container).toBeInTheDocument();
- });
- });
-
- it('should set node type master like default value when combobox is initiliazed and not have defaultValue', async () => {
- const { container, getByText } = render(
- {}} fetchOptions={mockedFetchOptions} />,
- );
-
- await act(async () => {
- await promiseFetchOptions; // waiting for the combobox items are loaded
- expect(getByText('master-node')).toBeInTheDocument();
- expect(container).toBeInTheDocument();
- });
- });
-
- it('should render the correct number of options', async () => {
- const { getByRole, findByText } = render(
- {}} fetchOptions={mockedFetchOptions} />,
- );
-
- await act(async () => {
- await promiseFetchOptions; // waiting for the combobox items are loaded
- fireEvent.click(getByRole('button', { name: 'Clear input' }));
- await findByText(`${mockedNodesIps[0].name}:${mockedNodesIps[0].ip}`);
- await findByText(`${mockedNodesIps[1].name}:${mockedNodesIps[1].ip}`);
- await findByText(`${mockedNodesIps[2].name}:${mockedNodesIps[2].ip}`);
- });
- });
-
- it('should allow only single selection', async () => {
- const onChangeMocked = jest.fn();
- const { getByRole, getByText, findByText } = render(
- ,
- );
- await act(async () => {
- await promiseFetchOptions; // waiting for the combobox items are loaded
- fireEvent.click(getByRole('button', { name: 'Clear input' }));
- const serverAddresInput = getByRole('textbox');
- fireEvent.change(serverAddresInput, { target: { value: 'first-typed' } });
- fireEvent.keyDown(serverAddresInput, { key: 'Enter', code: 'Enter' });
- fireEvent.change(serverAddresInput, { target: { value: 'last-typed' } });
- fireEvent.keyDown(serverAddresInput, { key: 'Enter', code: 'Enter' });
- expect(onChangeMocked).toHaveBeenLastCalledWith([
- { label: 'last-typed', value: 'last-typed', nodetype: 'custom' },
- ]);
- expect(getByText('last-typed')).toBeInTheDocument();
- });
- });
-
- it('should return EMPTY parsed Node IPs when options are not selected', async () => {
- const onChangeMocked = jest.fn();
- const { getByRole, container } = render(
- ,
- );
- await act(async () => {
- await promiseFetchOptions; // waiting for the combobox items are loaded
- fireEvent.click(getByRole('button', { name: 'Clear input' }));
- expect(onChangeMocked).toBeCalledTimes(2);
- expect(onChangeMocked).toBeCalledWith([]);
- expect(container).toBeInTheDocument();
- });
- });
-
- it('should allow create customs options when user type and trigger enter key', async () => {
- const onChangeMocked = jest.fn();
-
- const { getByRole } = render(
- ,
- );
- await act(async () => {
- await promiseFetchOptions; // waiting for the combobox items are loaded
- fireEvent.change(getByRole('textbox'), {
- target: { value: 'custom-ip-dns' },
- });
- fireEvent.keyDown(getByRole('textbox'), { key: 'Enter', code: 'Enter' });
- expect(onChangeMocked).toBeCalledTimes(2);
- expect(onChangeMocked).toHaveBeenNthCalledWith(2, [
- { label: 'custom-ip-dns', value: 'custom-ip-dns', nodetype: 'custom' },
- ]);
- });
- });
-
- it('should show "node.name:node.ip" in the combobox options', async () => {
- const { getByRole, getByText } = render(
- {}} fetchOptions={mockedFetchOptions} />,
- );
- await act(async () => {
- await promiseFetchOptions; // waiting for the combobox items are loaded
- fireEvent.click(getByRole('button', { name: 'Clear input' }));
- });
-
- mockedNodesIps.forEach(nodeItem => {
- expect(getByText(`${nodeItem.name}:${nodeItem.ip}`)).toBeInTheDocument();
- });
- });
-});
diff --git a/plugins/main/public/controllers/agent/register-agent/steps/server-address.tsx b/plugins/main/public/controllers/agent/register-agent/steps/server-address.tsx
deleted file mode 100644
index 8c23073f36..0000000000
--- a/plugins/main/public/controllers/agent/register-agent/steps/server-address.tsx
+++ /dev/null
@@ -1,170 +0,0 @@
-import {
- EuiComboBox,
- EuiComboBoxOptionOption,
- EuiHighlight,
- EuiText,
-} from '@elastic/eui';
-import React, { useEffect, useState } from 'react';
-import { UI_LOGGER_LEVELS } from '../../../../../common/constants';
-import { getErrorOrchestrator } from '../../../../react-services/common-services';
-import { UI_ERROR_SEVERITIES } from '../../../../react-services/error-orchestrator/types';
-import { getMasterNode } from '../../components/register-agent-service';
-
-type Props = {
- onChange: (value: EuiComboBoxOptionOption[]) => void;
- fetchOptions: () => Promise[]>;
- defaultValue?: string;
-};
-
-export type ServerAddressOptions = EuiComboBoxOptionOption & {
- nodetype?: string;
-};
-
-const ServerAddress = (props: Props) => {
- const { onChange, fetchOptions, defaultValue } = props;
- const [nodeIPs, setNodeIPs] = useState([]);
- const [selectedNodeIPs, setSelectedNodeIPs] = useState<
- ServerAddressOptions[]
- >([]);
- const [isLoading, setIsLoading] = useState(false);
- const [isDisabled, setIsDisabled] = useState(false);
-
- useEffect(() => {
- initialize();
- }, []);
-
- /**
- * Fetches the node IPs (options) and sets the state
- */
- const initialize = async () => {
- if (!fetchOptions) {
- throw new Error('fetchOptions is required');
- }
- try {
- setIsLoading(true);
- await setDefaultValue();
- setIsLoading(false);
- } catch (error) {
- setIsLoading(false);
- const options = {
- context: `${ServerAddress.name}.initialize`,
- level: UI_LOGGER_LEVELS.ERROR,
- severity: UI_ERROR_SEVERITIES.BUSINESS,
- display: true,
- store: false,
- error: {
- error: error,
- message: error.message || error,
- title: error.name || error,
- },
- };
- getErrorOrchestrator().handleError(options);
- }
- };
-
- /**
- * Sets the default value of server address
- */
- const setDefaultValue = async () => {
- if (defaultValue) {
- const defaultNode = [{ label: defaultValue, value: defaultValue, nodetype: 'custom' }];
- handleOnChange(defaultNode);
- setIsDisabled(true);
- } else {
- setIsDisabled(false);
- const nodeIps = await fetchOptions();
- setNodeIPs(nodeIps);
- const defaultNode = getMasterNode(nodeIps);
- if (defaultNode.length > 0) {
- handleOnChange(defaultNode);
- }
- }
- };
-
- /**
- * Handles the change of the selected node IP
- * @param value
- */
- const handleOnChange = (value: EuiComboBoxOptionOption[]) => {
- setSelectedNodeIPs(value);
- onChange(value);
- };
-
- /**
- * Handle the render of the custom options in the combobox list
- * @param option
- * @param searchValue
- * @param contentClassName
- */
- const handleRenderOption = (
- option: EuiComboBoxOptionOption,
- inputValue: string,
- contentClassName: string,
- ) => {
- const { label, value } = option;
- return (
-
- {`${label}:${value}`}
-
- );
- };
-
- /**
- * Handle the interaction when the user enter a option that is not in the list
- * Creating new options in the list and selecting it
- * @param inputValue
- * @param options
- */
- const handleOnCreateOption = (
- inputValue: string,
- options: ServerAddressOptions[] = [],
- ) => {
- if (!inputValue) {
- return;
- }
-
- const normalizedSearchValue = inputValue.trim().toLowerCase();
- if (!normalizedSearchValue) {
- return;
- }
-
- const newOption = {
- value: inputValue,
- label: inputValue,
- nodetype: 'custom',
- };
- // Create the option if it doesn't exist.
- if (
- options.findIndex(
- (option: ServerAddressOptions) =>
- option.label.trim().toLowerCase() === normalizedSearchValue,
- ) === -1
- ) {
- setNodeIPs([...nodeIPs, newOption]);
- }
- // Select the option.
- handleOnChange([newOption]);
- };
-
- return (
-
-
- This is the address the agent uses to communicate with the Wazuh server. It can be an IP address or a fully qualified domain name (FQDN).
-
- handleOnCreateOption(sv, fo)}
- />
-
- );
-};
-
-export default ServerAddress;
diff --git a/plugins/main/public/controllers/agent/register-agent/steps/wz-manager-address.tsx b/plugins/main/public/controllers/agent/register-agent/steps/wz-manager-address.tsx
deleted file mode 100644
index 8bfd679e2f..0000000000
--- a/plugins/main/public/controllers/agent/register-agent/steps/wz-manager-address.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import React, { memo, useCallback, useEffect, useState } from 'react';
-import { EuiText, EuiFieldText } from '@elastic/eui';
-
-type Props = {
- onChange: (value: string) => void;
- defaultValue?: string;
-};
-
-const WzManagerAddressInput = (props: Props) => {
- const { onChange, defaultValue } = props;
- const [value, setValue] = useState('');
-
- useEffect(() => {
- if (defaultValue) {
- setValue(defaultValue);
- onChange(defaultValue);
- } else {
- setValue('');
- onChange('');
- }
- }, []);
- /**
- * Handles the change of the selected node IP
- * @param value
- */
- const handleOnChange = (event: React.ChangeEvent) => {
- const { value } = event.target;
- onChange(value);
- setValue(value);
- };
- return (
-
-
- This is the address the agent uses to communicate with the Wazuh server.
- It can be an IP address or a fully qualified domain name (FQDN).
-
-
-
- );
-};
-
-export default WzManagerAddressInput;
diff --git a/plugins/main/public/controllers/agent/wazuh-config/index.ts b/plugins/main/public/controllers/agent/wazuh-config/index.ts
deleted file mode 100644
index 70b345bf8e..0000000000
--- a/plugins/main/public/controllers/agent/wazuh-config/index.ts
+++ /dev/null
@@ -1,420 +0,0 @@
-const architectureButtons = [
- {
- id: 'i386',
- label: 'i386',
- },
- {
- id: 'x86_64',
- label: 'x86_64',
- default: true,
- },
- {
- id: 'armhf',
- label: 'armhf',
- },
- {
- id: 'aarch64',
- label: 'aarch64',
- },
-];
-
-const architectureButtonsWithPPC64LE = [
- {
- id: 'i386',
- label: 'i386',
- },
- {
- id: 'x86_64',
- label: 'x86_64',
- default: true,
- },
- {
- id: 'armhf',
- label: 'armhf',
- },
- {
- id: 'aarch64',
- label: 'aarch64',
- },
- {
- id: 'powerpc',
- label: 'PowerPC',
- },
-];
-
-const architectureButtonsWithPPC64LEAlpine = [
- {
- id: 'i386',
- label: 'i386',
- },
- {
- id: 'x86',
- label: 'x86',
- },
- {
- id: 'x86_64',
- label: 'x86_64',
- default: true,
- },
- {
- id: 'armhf',
- label: 'armhf',
- },
- {
- id: 'aarch64',
- label: 'aarch64',
- },
- {
- id: 'powerpc',
- label: 'PowerPC',
- },
-];
-
-const architectureButtonsi386 = [
- {
- id: 'i386/x86_64',
- label: 'i386/x86_64',
- },
-];
-
-const architecturei386Andx86_64 = [
- {
- id: 'i386',
- label: 'i386',
- },
- {
- id: 'x86_64',
- label: 'x86_64',
- default: true,
- },
-];
-
-const architectureButtonsSolaris = [
- {
- id: 'i386',
- label: 'i386',
- default: true,
- },
- {
- id: 'sparc',
- label: 'SPARC',
- },
-];
-
-const architectureButtonsMacos = [
- {
- id: 'intel64',
- label: 'Intel',
- },
- {
- id: 'arm64',
- label: 'Apple silicon',
- },
-];
-
-const architectureButtonsAix = [
- {
- id: 'powerpc',
- label: 'PowerPC',
- },
-];
-
-const architectureButtonsHpUx = [
- {
- id: 'itanium2',
- label: 'Itanium2',
- },
-];
-
-const versionButtonAmazonLinux = [
- {
- id: 'amazonlinux1',
- label: 'Amazon Linux 1',
- },
- {
- id: 'amazonlinux2',
- label: 'Amazon Linux 2',
- },
- {
- id: 'amazonlinux2022',
- label: 'Amazon Linux 2022',
- default: true,
- },
-];
-
-const versionButtonsRedHat = [
- {
- id: 'redhat5',
- label: 'Red Hat 5',
- },
- {
- id: 'redhat6',
- label: 'Red Hat 6',
- },
- {
- id: 'redhat7',
- label: 'Red Hat 7 +',
- default: true,
- },
-];
-
-const versionButtonsCentos = [
- {
- id: 'centos5',
- label: 'CentOS 5',
- },
- {
- id: 'centos6',
- label: 'CentOS 6',
- },
- {
- id: 'centos7',
- label: 'CentOS 7 +',
- default: true,
- },
-];
-
-const versionButtonsDebian = [
- {
- id: 'debian7',
- label: 'Debian 7',
- },
- {
- id: 'debian8',
- label: 'Debian 8',
- },
- {
- id: 'debian9',
- label: 'Debian 9 +',
- default: true,
- },
-];
-
-const versionButtonFedora = [
- {
- id: '22',
- label: 'Fedora 22 +',
- },
-];
-
-const versionButtonsUbuntu = [
- {
- id: 'ubuntu14',
- label: 'Ubuntu 14',
- },
- {
- id: 'ubuntu15',
- label: 'Ubuntu 15 +',
- default: true,
- },
-];
-
-const versionButtonsWindows = [
- {
- id: 'windowsxp',
- label: 'Windows XP',
- },
- {
- id: 'windowsserver2008',
- label: 'Windows Server 2008',
- },
- {
- id: 'windows7',
- label: 'Windows 7 +',
- default: true,
- },
-];
-
-const versionButtonsSuse = [
- {
- id: 'suse11',
- label: 'SUSE 11',
- },
- {
- id: 'suse12',
- label: 'SUSE 12',
- default: true,
- },
-];
-
-const versionButtonsMacOS = [
- {
- id: 'sierra',
- label: 'macOS Sierra +',
- },
-];
-
-const versionButtonsOpenSuse = [
- {
- id: 'leap15',
- label: 'openSUSE Leap 15 +',
- },
-];
-
-const versionButtonsSolaris = [
- {
- id: 'solaris10',
- label: 'Solaris 10',
- },
- {
- id: 'solaris11',
- label: 'Solaris 11',
- default: true,
- },
-];
-
-const versionButtonsAix = [
- {
- id: '6.1 TL9',
- label: 'AIX 6.1 TL9 +',
- },
-];
-
-const versionButtonsHPUX = [
- {
- id: '11.31',
- label: 'HP-UX 11.31 +',
- },
-];
-
-const versionButtonsOracleLinux = [
- {
- id: 'oraclelinux5',
- label: 'Oracle Linux 5',
- },
- {
- id: 'oraclelinux6',
- label: 'Oracle Linux 6 +',
- default: true,
- },
-];
-
-const versionButtonsRaspbian = [
- {
- id: 'busterorgreater',
- label: 'Raspbian Buster or greater',
- },
-];
-
-const versionButtonAlpine = [
- {
- id: '3.12.12',
- label: '3.12.12 +',
- },
-];
-
-/**
- * Order the OS Buttons Alphabetically by label
- * @param a
- * @param b
- * @returns
- */
-const orderOSAlphabetically = (a, b) => {
- if (a.label.toUpperCase() < b.label.toUpperCase()) {
- return -1;
- }
- if (a.label.toUpperCase() > b.label.toUpperCase()) {
- return 1;
- }
- return 0;
-};
-
-const osPrincipalButtons = [
- {
- id: 'rpm',
- label: 'Red Hat Enterprise Linux',
- },
- {
- id: 'cent',
- label: 'CentOS',
- },
- {
- id: 'ubu',
- label: 'Ubuntu',
- },
- {
- id: 'win',
- label: 'Windows',
- },
- {
- id: 'macos',
- label: 'macOS',
- },
-];
-
-const osButtons = [
- {
- id: 'deb',
- label: 'Debian',
- },
- {
- id: 'open',
- label: 'openSUSE',
- },
- {
- id: 'sol',
- label: 'Solaris',
- },
- {
- id: 'aix',
- label: 'AIX',
- },
- {
- id: 'hp',
- label: 'HP-UX',
- },
- {
- id: 'amazonlinux',
- label: 'Amazon Linux',
- },
- {
- id: 'fedora',
- label: 'Fedora',
- },
- {
- id: 'oraclelinux',
- label: 'Oracle Linux',
- },
- {
- id: 'suse',
- label: 'SUSE',
- },
- {
- id: 'raspbian',
- label: 'Raspbian OS',
- },
- {
- id: 'alpine',
- label: 'Alpine',
- },
-].sort(orderOSAlphabetically);
-
-export {
- architectureButtons,
- architecturei386Andx86_64,
- versionButtonsRaspbian,
- versionButtonsSuse,
- architectureButtonsWithPPC64LE,
- versionButtonsOracleLinux,
- versionButtonFedora,
- versionButtonsRedHat,
- versionButtonsCentos,
- versionButtonAlpine,
- architectureButtonsMacos,
- osButtons,
- osPrincipalButtons,
- versionButtonsDebian,
- versionButtonsUbuntu,
- versionButtonAmazonLinux,
- versionButtonsWindows,
- versionButtonsMacOS,
- versionButtonsOpenSuse,
- versionButtonsSolaris,
- versionButtonsAix,
- versionButtonsHPUX,
- architectureButtonsi386,
- architectureButtonsSolaris,
- architectureButtonsAix,
- architectureButtonsHpUx,
- architectureButtonsWithPPC64LEAlpine,
-};
diff --git a/plugins/main/public/controllers/register-agent/containers/register-agent/register-agent.tsx b/plugins/main/public/controllers/register-agent/containers/register-agent/register-agent.tsx
deleted file mode 100644
index 8ae23213cd..0000000000
--- a/plugins/main/public/controllers/register-agent/containers/register-agent/register-agent.tsx
+++ /dev/null
@@ -1,242 +0,0 @@
-import React, { useState, useEffect } from 'react';
-import {
- EuiFlexGroup,
- EuiFlexItem,
- EuiPanel,
- EuiTitle,
- EuiButtonEmpty,
- EuiPage,
- EuiPageBody,
- EuiSpacer,
- EuiProgress,
- EuiButton,
-} from '@elastic/eui';
-import { WzRequest } from '../../../../react-services/wz-request';
-import { UI_LOGGER_LEVELS } from '../../../../../common/constants';
-import { UI_ERROR_SEVERITIES } from '../../../../react-services/error-orchestrator/types';
-import { ErrorHandler } from '../../../../react-services/error-management';
-import { getMasterRemoteConfiguration } from '../../../agent/components/register-agent-service';
-import './register-agent.scss';
-import { Steps } from '../steps/steps';
-import { InputForm } from '../../../../components/common/form';
-import { getGroups } from '../../services/register-agent-services';
-import { useForm } from '../../../../components/common/form/hooks';
-import { FormConfiguration } from '../../../../components/common/form/types';
-import { useSelector } from 'react-redux';
-import { withReduxProvider } from '../../../../components/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';
-
-interface IRegisterAgentProps {
- getWazuhVersion: () => Promise;
- hasAgents: () => Promise;
- addNewAgent: (agent: any) => Promise;
- reload: () => void;
-}
-
-export const RegisterAgent = withReduxProvider(
- ({
- getWazuhVersion,
- hasAgents,
- addNewAgent,
- reload,
- }: IRegisterAgentProps) => {
- const configuration = useSelector(
- (state: { appConfig: { data: any } }) => state.appConfig.data,
- );
- const [wazuhVersion, setWazuhVersion] = useState('');
- const [haveUdpProtocol, setHaveUdpProtocol] = useState(
- false,
- );
- const [loading, setLoading] = useState(false);
- const [wazuhPassword, setWazuhPassword] = useState('');
- const [groups, setGroups] = useState([]);
- const [needsPassword, setNeedsPassword] = useState(false);
-
- const initialFields: FormConfiguration = {
- operatingSystemSelection: {
- type: 'custom',
- initialValue: '',
- component: props => {
- return ;
- },
- options: {
- groups,
- },
- },
- serverAddress: {
- type: 'text',
- initialValue: configuration['enrollment.dns'] || '',
- validate: validateServerAddress,
- },
- agentName: {
- type: 'text',
- initialValue: '',
- validate: validateAgentName,
- },
-
- agentGroups: {
- type: 'custom',
- initialValue: [],
- component: props => {
- return ;
- },
- options: {
- groups,
- },
- },
- };
-
- const form = useForm(initialFields);
-
- const getRemoteConfig = async () => {
- const remoteConfig = await getMasterRemoteConfiguration();
- if (remoteConfig) {
- setHaveUdpProtocol(remoteConfig.isUdp);
- }
- };
-
- const getAuthInfo = async () => {
- try {
- const result = await WzRequest.apiReq(
- 'GET',
- '/agents/000/config/auth/auth',
- {},
- );
- return (result.data || {}).data || {};
- } catch (error) {
- ErrorHandler.handleError(error);
- }
- };
-
- useEffect(() => {
- const fetchData = async () => {
- try {
- const wazuhVersion = await getWazuhVersion();
- await getRemoteConfig();
- const authInfo = await getAuthInfo();
- // get wazuh password configuration
- let wazuhPassword = '';
- const needsPassword = (authInfo.auth || {}).use_password === 'yes';
- if (needsPassword) {
- wazuhPassword =
- configuration['enrollment.password'] ||
- authInfo['authd.pass'] ||
- '';
- }
- const groups = await getGroups();
- setNeedsPassword(needsPassword);
- setWazuhPassword(wazuhPassword);
- setWazuhVersion(wazuhVersion);
- setGroups(groups);
- setLoading(false);
- } catch (error) {
- setWazuhVersion(wazuhVersion);
- setLoading(false);
- const options = {
- context: 'RegisterAgent',
- level: UI_LOGGER_LEVELS.ERROR,
- severity: UI_ERROR_SEVERITIES.BUSINESS,
- display: true,
- store: false,
- error: {
- error: error,
- message: error.message || error,
- title: error.name || error,
- },
- };
- ErrorHandler.handleError(error, options);
- }
- };
-
- fetchData();
- }, []);
-
- const osCard = (
-
- );
-
- return (
-
-
-
-
-
-
-
- {hasAgents() ? (
- addNewAgent(false)}
- iconType='cross'
- >
- Close
-
- ) : (
- reload()}
- iconType='refresh'
- >
- Refresh
-
- )}
-
-
-
-
-
- Deploy new agent
-
-
-
-
-
- {loading ? (
- <>
-
-
-
-
- >
- ) : (
-
-
-
- )}
-
-
- reload()}
- >
- Close
-
-
-
-
-
-
-
-
-
- );
- },
-);
diff --git a/plugins/main/public/services/routes.js b/plugins/main/public/services/routes.js
index 835b81ab2f..06107272ca 100644
--- a/plugins/main/public/services/routes.js
+++ b/plugins/main/public/services/routes.js
@@ -20,6 +20,7 @@ import { settingsWizard, getSavedSearch, getIp, getWzConfig } from './resolves';
// HTML templates
import healthCheckTemplate from '../templates/health-check/health-check.html';
import agentsTemplate from '../templates/agents/dashboards.html';
+import agentDeployTemplate from '../templates/agents/deploy/agent-deploy.html';
import agentsPrevTemplate from '../templates/agents-prev/agents-prev.html';
import managementTemplate from '../templates/management/management.html';
import overviewTemplate from '../templates/visualize/dashboards.html';
@@ -109,6 +110,12 @@ app.config($routeProvider => {
resolve: { wzConfig, ip },
outerAngularWrapperRoute: true,
})
+ .when('/agents-preview/deploy', {
+ template: agentDeployTemplate,
+ resolve: { enableWzMenu, nestedResolve, ip, savedSearch },
+ reloadOnSearch: false,
+ outerAngularWrapperRoute: true,
+ })
.when('/agents/:agent?/:tab?/:tabView?', {
template: agentsTemplate,
resolve: { enableWzMenu, nestedResolve, ip, savedSearch },
diff --git a/plugins/main/public/templates/agents-prev/agents-prev.html b/plugins/main/public/templates/agents-prev/agents-prev.html
index 573720fea4..30b3efb16c 100644
--- a/plugins/main/public/templates/agents-prev/agents-prev.html
+++ b/plugins/main/public/templates/agents-prev/agents-prev.html
@@ -1,76 +1 @@
-
-
-
-
-
-
-
-
-
-
-
-
{{ ctrl.errorInit || 'Internal error' }}
-
-
-
-
- Refresh
-
-
-
-
-
-
-
-
-
+
diff --git a/plugins/main/public/templates/agents/deploy/agent-deploy.html b/plugins/main/public/templates/agents/deploy/agent-deploy.html
new file mode 100644
index 0000000000..34c5544c9e
--- /dev/null
+++ b/plugins/main/public/templates/agents/deploy/agent-deploy.html
@@ -0,0 +1 @@
+
diff --git a/plugins/main/public/templates/visualize/dashboards.html b/plugins/main/public/templates/visualize/dashboards.html
index 1dff0934c2..73bd108f15 100644
--- a/plugins/main/public/templates/visualize/dashboards.html
+++ b/plugins/main/public/templates/visualize/dashboards.html
@@ -1,138 +1,99 @@
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
{{reportStatus}}
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
{{reportStatus}}
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+