Skip to content

Commit

Permalink
Add vulnerability detection card in agent overview (#7085)
Browse files Browse the repository at this point in the history
* Add top packages component

* Add vuls severity stat component

* Create vuls panel

* Add vuls panel in agent overview

* Update CHANGELOG

* Apply prettier

* Fix responsive behavior

* Apply prettier

* Change vuls panel style

* Use vuls data source in agent overview panel

* Move vuls panel

* Change redirect in hoc

* Remove unnecessary redirect

* Add HOC to create pattern if not exist

* Apply prettier

* Remove unused imports

Co-authored-by: Guido Modarelli <[email protected]>

* Remove unused imports

Co-authored-by: Guido Modarelli <[email protected]>

* Remove unused code

* Apply prettier

* Resolve conflicts in agents-welcome

* Change agents management menu icon

---------

Co-authored-by: Chantal Belén kelm <[email protected]>
Co-authored-by: Guido Modarelli <[email protected]>
Co-authored-by: Federico Rodriguez <[email protected]>
  • Loading branch information
4 people authored Oct 29, 2024
1 parent bd44194 commit 11cb294
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 101 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Support for Wazuh 4.10.0
- Added sample data for YARA [#6964](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6964)
- Added a custom filter and visualization for vulnerability.under_evaluation field [#6968](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6968) [#7044](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7044) [#7046](https://github.com/wazuh/wazuh-dashboard-plugins/issues/7046)
- Add vulnerabilities card to agent details page [#7058](https://github.com/wazuh/wazuh-dashboard-plugins/issues/7058)
- Added an "Agents management" menu and moved the sections: "Endpoint Groups" and "Endpoint Summary" which changed its name to "Summary".[#7112](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7112)
- Added ability to filter from File Integrity Monitoring registry inventory [#7119](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7119)
- Added new field columns and ability to select the visible fields in the File Integrity Monitoring Files and Registry tables [#7119](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7119)
Expand Down
134 changes: 56 additions & 78 deletions plugins/main/public/components/common/welcome/agents-welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { EventsCount } from './dashboard/events-count';
import { IntlProvider } from 'react-intl';
import { ButtonExploreAgent } from '../../wz-agent-selector/button-explore-agent';
import NavigationService from '../../../react-services/navigation-service';
import VulsPanel from './components/vuls_panel/vuls_welcome_panel';
import { AgentTabs } from '../../endpoints-summary/agent/agent-tabs';

export const AgentsWelcome = compose(
Expand Down Expand Up @@ -391,8 +392,8 @@ export const AgentsWelcome = compose(
renderMitrePanel() {
return (
<Fragment>
<EuiPanel paddingSize='m' height={{ height: 300 }}>
<EuiFlexGroup gutterSize='s'>
<EuiPanel paddingSize='m'>
<EuiFlexGroup gutterSize='s' responsive={false}>
<EuiFlexItem>
<h2 className='embPanel__title wz-headline-title'>
<EuiText size='xs'>
Expand Down Expand Up @@ -452,96 +453,73 @@ export const AgentsWelcome = compose(

render() {
const title = this.renderTitle();
const responsiveGroupDirection =
this.state.widthWindow < 1150 ? 'column' : 'row';

return (
<IntlProvider locale='en'>
<div className='wz-module wz-module-welcome'>
<div className='wz-module-header-agent-wrapper'>
<div className='wz-module-header-agent-main'>{title}</div>
</div>
<EuiPage>
<EuiPageBody component='div'>
<div className='wz-module-header-nav'>
<div className='wz-module-agents-padding-responsive'>
<EuiPage>
<EuiPageBody component='div'>
<AgentInfo
agent={this.props.agent}
isCondensed={false}
hideActions={true}
{...this.props}
></AgentInfo>
</div>
<EuiFlexGroup>
<EuiFlexItem />
<EuiFlexItem
style={{
alignItems: 'flex-end',
marginTop: 10,
marginBottom: 10,
}}
>
{' '}
{/* TODO: Replace with SearchBar and replace implementation to get the time range in AgentView component*/}
<WzDatePicker condensed={true} onTimeChange={() => {}} />
</EuiFlexItem>
</EuiFlexGroup>
{(this.state.widthWindow < 1150 && (
<Fragment>
<EuiFlexGroup wrap>
<EuiFlexItem
key={'Wazuh-App-Agents-Welcome-MITRE-Top-Tactics'}
>
{this.renderMitrePanel()}
</EuiFlexItem>
{this.renderCompliancePanel()}
</EuiFlexGroup>
<EuiSpacer size='m' />
<EuiFlexGroup>
<FimEventsTable agent={this.props.agent} />
</EuiFlexGroup>
<EuiSpacer size='m' />
<EuiFlexGroup>
<EuiFlexItem
key={'Wazuh-App-Agents-Welcome-Events-Evolution'}
>
{' '}
{/* Events count evolution */}
{this.renderEventCountVisualization()}
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size='m' />
<EuiFlexGroup>
<EuiFlexItem>{this.renderSCALastScan()}</EuiFlexItem>
</EuiFlexGroup>
</Fragment>
)) || (
<Fragment>
<EuiFlexGroup>
<EuiFlexItem>
<EuiFlexGroup>
<EuiFlexItem
key={'Wazuh-App-Agents-Welcome-MITRE-Top-Tactics'}
>
{this.renderMitrePanel()}
</EuiFlexItem>
<EuiFlexGroup>
<EuiFlexItem />
<EuiFlexItem
style={{
alignItems: 'flex-end',
marginTop: 10,
marginBottom: 10,
}}
>
{' '}
{/* TODO: Replace with SearchBar and replace implementation to get the time range in AgentView component*/}
<WzDatePicker condensed={true} onTimeChange={() => {}} />
</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexGroup direction={responsiveGroupDirection}>
<EuiFlexItem
key={'Wazuh-App-Agents-Welcome-Events-Evolution'}
grow={3}
>
{this.renderEventCountVisualization()}
</EuiFlexItem>
<EuiFlexItem grow={3}>
<EuiFlexGroup>
<EuiFlexItem
key={'Wazuh-App-Agents-Welcome-MITRE-Top-Tactics'}
grow={3}
>
{this.renderMitrePanel()}
</EuiFlexItem>
<EuiFlexItem grow={3}>
{this.renderCompliancePanel()}
</EuiFlexGroup>
</EuiFlexItem>
<FimEventsTable agent={this.props.agent} />
</EuiFlexGroup>
<EuiSpacer size='l' />
<EuiFlexGroup>
<EuiFlexItem
key={'Wazuh-App-Agents-Welcome-Events-Evolution'}
>
{' '}
{/* Events count evolution */}
{this.renderEventCountVisualization()}
</EuiFlexItem>
<EuiFlexItem>{this.renderSCALastScan()}</EuiFlexItem>
</EuiFlexGroup>
</Fragment>
)}
</EuiPageBody>
</EuiPage>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size='l' />
<EuiFlexGroup direction={responsiveGroupDirection}>
<EuiFlexItem>
<VulsPanel agent={this.props.agent} />
</EuiFlexItem>
<EuiFlexItem>{this.renderSCALastScan()}</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size='l' />
<EuiFlexGroup>
<FimEventsTable agent={this.props.agent} />
</EuiFlexGroup>
</EuiPageBody>
</EuiPage>
</div>
</div>
</IntlProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function FimEventsTable({ agent }) {
<EuiFlexItem>
<EuiPanel paddingSize='m'>
<EuiFlexItem>
<EuiFlexGroup>
<EuiFlexGroup responsive={false}>
<EuiFlexItem>
<EuiText size='xs'>
<h2>FIM: Recent events</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export { FimEventsTable, useTimeFilter } from './fim_events_table';
export { ScaScan } from './sca_scan';
export { MitreTopTactics } from './mitre_top';
export { RequirementVis } from './requirement_vis';
export { VulsTopPackageTable } from './top_packages_table';
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Wazuh app - React component building the welcome screen of an agent.
* version, OS, registration date, last keep alive.
*
* 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.
*/

export { VulsTopPackageTable, useTimeFilter } from './top_packages_table';
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Wazuh app - React component building the welcome screen of an agent.
* version, OS, registration date, last keep alive.
*
* 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, { useState, useEffect } from 'react';
import {
EuiBasicTable,
EuiFlexItem,
EuiPanel,
EuiSpacer,
EuiText,
EuiFlexGroup,
} from '@elastic/eui';
// @ts-ignore
import { getDataPlugin } from '../../../../../kibana-services';
import { vulnerabilityDetection } from '../../../../../utils/applications';
import {
PatternDataSourceFilterManager,
FILTER_OPERATOR,
} from '../../../data-source';
import { WzLink } from '../../../../../components/wz-link/wz-link';

export function VulsTopPackageTable({ agentId, items, indexPatternId }) {
const [sort, setSort] = useState({
field: 'doc_count',
direction: 'desc',
});

const columns = [
{
field: 'key',
name: 'Package',
sortable: true,
render: field => (
<WzLink
appId={vulnerabilityDetection.id}
path={`/overview?tab=vuls&tabView=dashboard&agentId=${agentId}&_g=${PatternDataSourceFilterManager.filtersToURLFormat(
[
PatternDataSourceFilterManager.createFilter(
FILTER_OPERATOR.IS,
`package.name`,
field,
indexPatternId,
),
],
)}`}
>
{field}
</WzLink>
),
},
{
field: 'doc_count',
name: 'Count',
sortable: true,
truncateText: true,
width: '100px',
},
];

return (
<EuiPanel paddingSize='s'>
<EuiFlexGroup>
<EuiFlexItem>
<EuiText size='xs'>
<h2>Top 5 Packages</h2>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size='s' />
<EuiBasicTable
items={items}
columns={columns}
loading={false}
sorting={{ sort }}
onChange={e => setSort(e.sort)}
itemId='top-packages-table'
noItemsMessage='No recent events'
/>
</EuiPanel>
);
}
Loading

0 comments on commit 11cb294

Please sign in to comment.