Skip to content

Commit

Permalink
Merge 4.9.0 into master (#6767)
Browse files Browse the repository at this point in the history
Merge 4.9.0 into master
  • Loading branch information
asteriscos authored Jun 13, 2024
2 parents 0f5952f + e58ab80 commit dc08c3d
Show file tree
Hide file tree
Showing 285 changed files with 7,804 additions and 13,620 deletions.
19 changes: 14 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Added AngularJS dependencies [#6145](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6145)
- Added a migration task to setup the configuration using a configuration file [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337)
- Improve fleet management by adding 'Edit Agent Groups' and 'Upgrade Agents' actions, as well as a filter to show only outdated agents [#6250](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6250) [#6476](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6476) [#6274](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6274) [#6501](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6501) [#6529](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6529) [#6648](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6648)
- Added propagation of updates from the table to dashboard visualizations in Endpoints summary [#6460](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6460)
- Added propagation of updates from the table to dashboard visualizations in Endpoints summary [#6460](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6460) [#6737](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6737)
- Handle index pattern selector on new discover [#6499](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6499)
- Added macOS log collector tab [#6545](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6545)
- Add ability to disable the edition of configuration through API endpoints and UI [#6557](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6557)
Expand All @@ -25,9 +25,9 @@ All notable changes to the Wazuh app project will be documented in this file.
- Added ability to open the report file or Reporting application from the toast message [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558)
- Added support for agents to Office 365 [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558)

### Changed
### Changed

- Removed embedded discover [#6120](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6120) [#6235](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6235) [#6254](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6254) [#6285](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6285) [#6288](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6288) [#6290](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6290) [#6289](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6289) [#6286](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6286) [#6275](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6275) [#6287](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6297](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6297) [#6291](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6459](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6459) [#6434](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6434) [#6504](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6504) [#6649](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6649) [#6506](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6506) [#6537](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6537) [#6528](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6528) [#6675](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6675) [#6674](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6674) [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558) [#6685](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6685) [#6691](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6691) [#6712](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6712)
- Removed embedded discover [#6120](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6120) [#6235](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6235) [#6254](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6254) [#6285](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6285) [#6288](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6288) [#6290](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6290) [#6289](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6289) [#6286](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6286) [#6275](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6275) [#6287](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6297](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6297) [#6291](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6459](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6459) [#6434](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6434) [#6504](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6504) [#6649](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6649) [#6506](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6506) [#6537](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6537) [#6528](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6528) [#6675](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6675) [#6674](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6674) [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558) [#6685](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6685) [#6691](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6691) [#6712](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6712) [#6734](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6734) [#6746](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6746) [#6752](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6752) [#6753](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6753) [#6756](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6756)
- Allow editing groups for an agent from Endpoints Summary [#6250](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6250)
- Change how the configuration is managed in the backend side [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337) [#6519](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6519) [#6573](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6573)
- Change the view of API is down and check connection to Server APIs application [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337)
Expand All @@ -47,14 +47,17 @@ All notable changes to the Wazuh app project will be documented in this file.
- Upgraded versions of `follow-redirects` and `es5-ext` [#6626](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6626)
- Changed agent log collector socket API response controller component [#6660](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6660)
- Improve margins and paddins in the Events, Inventory and Control tabs [#6708](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6708)
- Refactored the search bar to correctly handle fixed and user-added filters [#6716](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6716)
- Refactored the search bar to correctly handle fixed and user-added filters [#6716](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6716) [#6755](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6755)
- Generate URL with predefined filters [#6745](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6745)
- Migrated AngularJS routing to ReactJS [#6689](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6689)

### Fixed

- Fixed the scripted fields disappear when the fields of the events index pattern was refreshed [#6237](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6237)
- Fixed an error of malformed table row on the generation of PDF reports [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558)
- Fixed the sample alerts scripts to generate valid IP ranges and file hashes [#6667](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6667)
- Fixed cronjob max seconds interval validation [#6730](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6730)
- Fixed styles in small height viewports [#6747](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6747)

### Removed

Expand All @@ -67,7 +70,13 @@ All notable changes to the Wazuh app project will be documented in this file.
- Removed legacy discover references and methods [#6646](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6646)
- Removed custom EuiSuggestItem component in favor of OUI's native component [#6714](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6714)

## Wazuh v4.8.0 - OpenSearch Dashboards 2.10.0 - Revision 11
## Wazuh v4.8.1 - OpenSearch Dashboards 2.10.0 - Revision 00

### Added

- Support for Wazuh 4.8.1

## Wazuh v4.8.0 - OpenSearch Dashboards 2.10.0 - Revision 12

### Added

Expand Down
40 changes: 40 additions & 0 deletions plugins/main/docs/mount-application.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Mount application

The application mounts a ReactJS application into the HTML element provided by the parameters received on the `mount` method of the Wazuh dashboard application. The application could be wrapped in the root level with some contexts as `I18nProvider` and Redux provider to these are accessibles from any component in the tree:

```ts
// plugin.ts
{
mount: async (params: AppMountParameters) => {
try {
// Load application bundle
const { renderApp } = await import('./application');
const unmount = await renderApp(params);
return () => {
unmount();
};
} catch (error) {
console.debug(error);
}
},
}

```

```tsx
// application.ts
export async function renderApp(params) {
/* Load or initiate the dependencies, async styles, etc... */

const deps = {}; // dependencies
ReactDOM.render(
<I18nProvider>
<Provider store={store}>
<Application {...deps} />
</Provider>
</I18nProvider>,
params.element,
);
return () => ReactDOM.unmountComponentAtNode(params.element);
}
```
137 changes: 137 additions & 0 deletions plugins/main/docs/routing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
## Navigation

Due we need to do some redirections to routes that are defined in services that are decoupled of the navigation, we need to use some service that has the context of the navigation. This is done though the `NavigationService`.

The `NavigationService` is responsible to manage the navigation of the same application and navigate to others applications and is created with a reference to a new history we create before mount the application. This services is using for navigating instead of using the interfaces provided by the `react-router-dom`

```ts
NavigationService.getInstance(history);
```

## Routing

The `Application` component defines the layout of the application under the router provided by `react-router-dom`.

The routing of the application is based on path names and search parameters. This architecture is inherited from the old routing based on AngularJS that was using the application.

```tsx
// app-router
import { Router, Switch, Route } from 'react-router-dom';

const Application = () => {
// general states or effects

return (
<Router history={history}>
{/* General components that could be always displayed in all views or conditionally */}
<Switch>
<Route path={'/health-check'} exact render={HealthCheck}></Route>
{/* Rest of routes */}
<Switch>
<Router>
)
}
```

### Routing based on search parameters

Some views are managed depending on the search parameters ( `tab=syscollector` ), and the current version of `react-router-dom` that is `v5` is unable to re-render components when the search parameters change. To cover this requirement, we use a custom routing components/hooks/HOCs that have a similar interface to the provided by the `react-router-dom`.

- Components with similar interface that provided by `react-router-dom`
- Switch: find the first Route that matches the search paramerts or render the Redirect if this is included
- Route: define the route match parameters to render the component
- Redirect: redirect to another "route" based on search parameters

```tsx
import { Switch, Route, Redict } from '../router-search';

const Security = () => {
return (
<Switch>
<Route path='?tab=users'>
<Users></Users>
</Route>
<Route path='?tab=roles'>
<Roles></Roles>
</Route>
<Route path='?tab=policies'>
<Policies></Policies>
</Route>
<Route path='?tab=roleMapping'>
<>
{allowRunAs !== undefined &&
allowRunAs !==
getWazuhCorePlugin().API_USER_STATUS_RUN_AS.ENABLED &&
isNotRunAs(allowRunAs)}
<RolesMapping></RolesMapping>
</>
</Route>
<Redirect to='?tab=users'></Redirect>
</Switch>
);
};
```

The `path` property of the `Route` component allows to define a variable value for a search parameter, using the `:` at the beggining of the search parameter definition using the syntax: `?<parameter_name>=:value`. The `:value` defines the value for `<parameter_name>` search parameter is variable. The name of the `value` is unused. To access to the value of the `<parameter_name>` search parameter, use the `render` property of the `Route` component.Example:

```tsx
class RegistryTable extends Coomponent {
render() {
return (
<div>
{registryTable}
<Switch>
<Route
path='?file=:file'
render={({ search: { file } }) => (
<FlyoutDetail
fileName={file}
agentId={this.props.agent.id}
closeFlyout={() => this.closeFlyout()}
view='inventory'
{...this.props}
/>
)}
></Route>
</Switch>
</div>
);
}
}
```

- hooks:
- useRouterSearch: returns the search parameters

```tsx
import { useRouterSearch } from '../use-router-search';
export const Component = () => {
// Get the tab search parameter
const { tab } = useRouterSearch();
return <></>;
};
```

```tsx
import { useRouterSearch } from '../use-router-search';
export const Component = () => {
// Get the tab search parameter and use a value as default if this is undefined
const { tab = 'welcome' } = useRouterSearch();
return <></>;
};
```

- HOCs:
- withRouterSearch: inject the search parameters through the `search` property

```tsx
import { withRouterSearch } from '../with-router-search';
export const Component = withRouterSearch(({ search }) => {
// search property has the searh parameters

if (search.tab === 'value') {
// any logic
}
return <></>;
});
```
2 changes: 1 addition & 1 deletion plugins/main/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
],
"server": true,
"ui": true
}
}
10 changes: 1 addition & 9 deletions plugins/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
"prebuild": "node scripts/generate-build-version"
},
"dependencies": {
"angular": "^1.8.2",
"angular-animate": "1.8.3",
"angular-material": "1.2.5",
"angular-sanitize": "^1.8.0",
"axios": "^1.6.1",
"install": "^0.13.0",
"js2xmlparser": "^5.0.0",
Expand All @@ -76,10 +72,6 @@
"@types/node-cron": "^2.0.3",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"angular-aria": "^1.8.0",
"angular-route": "^1.8.0",
"angular-mocks": "^1.8.2",
"ngreact": "^0.5.1",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "3.5.5",
Expand All @@ -94,4 +86,4 @@
"redux-mock-store": "^1.5.4",
"swagger-client": "^3.19.11"
}
}
}
103 changes: 103 additions & 0 deletions plugins/main/public/app-router.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import React, { useEffect } from 'react';
import { Router, Route, Switch, Redirect } from 'react-router-dom';
import { ToolsRouter } from './components/tools/tools-router';
import { getWazuhCorePlugin, getWzMainParams } from './kibana-services';
import { updateCurrentPlatform } from './redux/actions/appStateActions';
import { useDispatch } from 'react-redux';
import { checkPluginVersion } from './utils';
import { WzAuthentication, loadAppConfig } from './react-services';
import { WzMenuWrapper } from './components/wz-menu/wz-menu-wrapper';
import { WzAgentSelectorWrapper } from './components/wz-agent-selector/wz-agent-selector-wrapper';
import { ToastNotificationsModal } from './components/notifications/modal';
import { WzUpdatesNotification } from './components/wz-updates-notification';
import { HealthCheck } from './components/health-check';
import { WzBlankScreen } from './components/wz-blank-screen/wz-blank-screen';
import { RegisterAgent } from './components/endpoints-summary/register-agent/containers/register-agent/register-agent';
import { MainEndpointsSummary } from './components/endpoints-summary';
import { AgentView } from './components/endpoints-summary/agent';
import WzManagement from './controllers/management/components/management/management-provider';
import { Overview } from './components/overview/overview';
import { Settings } from './components/settings';
import { WzSecurity } from './components/security';
import $ from 'jquery';
import NavigationService from './react-services/navigation-service';

export function Application(props) {
const dispatch = useDispatch();
const navigationService = NavigationService.getInstance();
const history = navigationService.getHistory();

useEffect(() => {
// Get the dashboard security
getWazuhCorePlugin()
.dashboardSecurity.fetchCurrentPlatform()
.then(item => {
dispatch(updateCurrentPlatform(item));
})
.catch(() => {});

// Init the process of refreshing the user's token when app starts.
checkPluginVersion().finally(() => {
WzAuthentication.refresh();
});

// Load the app state
loadAppConfig();

// TODO: Replace this with document insteat
// Bind deleteExistentToken on Log out component.
$('.euiHeaderSectionItem__button, .euiHeaderSectionItemButton').on(
'mouseleave',
function () {
// opendistro
$('button:contains(Log out)').on('click', function () {
WzAuthentication.deleteExistentToken();
});
},
);
}, []);

return (
<Router history={history}>
<div className='wazuhNotReadyYet'></div>
{/* TODO: The plugins/main/public/components/wz-menu/wz-menu.js defines a portal to mount here. We could avoid the usage of the React portal and render the component instead*/}
<WzMenuWrapper />
<ToastNotificationsModal /> {/* TODO: check if this is being used */}
<WzAgentSelectorWrapper />
<WzUpdatesNotification />
<Switch>
<Route path={'/health-check'} exact render={HealthCheck}></Route>
<Route
path={'/agents-preview/deploy'}
exact
render={RegisterAgent}
></Route>
<Route path={'/agents'} exact render={AgentView}></Route>
<Route
path={'/agents-preview/'}
exact
render={MainEndpointsSummary}
></Route>
<Route path={'/manager'} exact render={WzManagement}></Route>
<Route
path={'/overview'}
exact
render={props => <Overview {...props} />}
></Route>
<Route path={'/settings'} exact render={Settings}></Route>
<Route path={'/security'} exact render={WzSecurity}></Route>
<Route
path={'/wazuh-dev'}
exact
render={props => <ToolsRouter {...props} />}
></Route>
<Route
path={'/blank-screen'}
exact
render={props => <WzBlankScreen {...props} />}
></Route>
<Redirect from='/' to={getWzMainParams()} />
</Switch>
</Router>
);
}
Loading

0 comments on commit dc08c3d

Please sign in to comment.