Skip to content

Commit 48c5519

Browse files
juankaromojsanchez91victorst79pablotr9Joanes04
authored
Redesign of Integrity monitoring (#2174)
* Fixed removed filters when delete the inputValue * added flyout in table * fixed failed merge * Code Cleaning * testing action to open flyout * Fix flyout * Minor fix * Added the new badge contextMenu * Update flyout with current selected file * Fixed problem with press enter event * Changes in component props for agent requests * Add flyout with file details * Added the edit form to the filter badges * finished state table and added registry table * Refactoring wz-search-badges * Load discover * Added suggest values to the editFilter form * Load discover and bridge to Dashboard * Fix Error message * Fix first time loading * hide tabs with 0 registry or files * Added reporting * added spinner loading for files and registry in states * Redirect to agent page * Spinner in loader events * Windows registry table * Finished logic of FIM searchBar * Revert DatePicker in q Filter * Revert changes in table.tsx * Link discover time service with the datePicker * Add file details and discover * Divided filterBar props between files and registry * Styles * Responsive headers * Refresh alerts when a new file is selected * Fix styles for long text values * Fix the commonlyUsedRanges and add the recentlyUsedRanges * Add loading section * Fixed margin between the filter and date pickers * Resend filters when are defined on create wzSearchBar * Refactor sections * Fix imports * Popover style * Added placeholder text * Show the search Suggestions when input is empty * Add agentId prop to the filterBar * View event in events from detail * Created new component WzDatePicker * Added styles * Close and reopen flyout to load a new file * Show info message when no syscheck data was found * Fix Elasticsearch query to maintain data range * Fix discover section and add date picker * Add margin botton to the badges * hidden some filters in windows view * Removed comments * Quick fix * Remmove DatePicker from fim state view * Welcome screen reorganize * Add accordion for file details * Add mtime and date filter * change width columns * change width columns * Fix the sort error * Refactor file detail * fix sort columns request * Redesign agent-info * fixed column sort * Selected implicit fields in Events * Files details improvements * Remove innecesary code and refactoring * Add a space between the searchBar and datePicker * Add index pattern to Elasticsearch queries * Open details flyout from events * Open details flyout from events * Open rule from events * States for SCA * Styles for SCA * Refactor modules * Add the kibana searchBar to discover component * Styles of file details * Add the Kibana SearchBar to Discover component * Styles of file details * Clear undesired fields discover * Clear and refactor main modules * Removed unnecessary code * Linked datePicker with the timeFilter service * Clear styles of agents headers * Redesign Details * Added a method to link the output of the search bar to the state * Refactor main * Added compliance modules * Added all agents modules * Changes in modules * Removed unused import * Fixed the history search of the Kibana SearchBar * Fixed the z-index of the edit filter popOver * Fix settings * Fix loading discover * Fix filters on custom discover * Fix reporting * Clean discover * InitFilters update filters within the component * Discover bar styles * Fix flyout loading component * Clicking on suggest item focuses on the inputRef * Fixed bad import on production * Flyout styles * Do not open flyout if the file doesn't exist * Show error when API fails * Fix discover message * SCA checks condition * Improves performance and fixes storage service * Fixed setState on unmounted component * Implicit filters refactor * implicit filter fix * Add link to filter from details * Fix merge * Fix link filters from details * update code * Clean watchers * Refactor code * Configurations * Saved the filters on localStorage * policy monitoring, system auditing and sca configuration only show their configurations in new module view * Remove props in visualize * Set OwnFocus property to EuiFlyout * Fixed console error * Fix styles * Fixed console error by div inside a p element * Fixed console error by duplicate key * Removed of unnecessary imports * Refactor details * External link to rule * Display message when monitoring is not configured * Adapt dark mode * Fix console error invalid prop `column[0]` * Fix console error invalid prop `queryLanguage` * Select index pattern from configuration * Add overlay mask on open flyout * Handle ReactPortal * Fixed no reset pageIndex value on change filters * Blocked empty search values * Show quick filter links only in state view * Prevent error on update state on unmount RowDetail * Improves the design and editing experience of filters * Fix perm field * FIxed error on select obsolute dates * extensions in wazuh-registry * Fix console error, invalid prop pagination * Fix console error, invalid prop `titleColor` * Fix console error p inside p * Fix API/IP selectors in WzMenu * style correction * Remove chart `?` * Fix extensions in wazuh registry * Fix settings section initial tab * Fix non refresh when update time in the flyout * Create new FilterManager service for our discover * Load dashboard correctly when refreshing page from Discover * Fixed the error removing items when updating the time * Fix agent info details * current file if does not exists * Fix pinned filters * Fix discover error * Fix management selected tab * Select current overview tab on refresh * Remove discover flick when opening the app * Download csv fim * Fixes and improves the performance of the links in the events view * Fix console error, state update on an unmounted component states * Fix console error, state update on an unmounted component EventsFim * Disable report button when no results and when loading a report * Fix console error, invalid prop value on columns * Fix agent-preview links * Fix console error, state update on an unmounted component sca/States * Fix console error, state update on an unmounted component AgentsPreview * Fix console error, state update on an unmounted component AgentsTable * Fix ruleset table error * Fix typo * Fixed bad value for prod `sortable` in component sca/state * Fix console error, the iconSize prop is invalid * Fix csv timeout Co-authored-by: Jose Sanchez <josesanxez@gmail.com> Co-authored-by: victorst79 <victorst79@gmail.com> Co-authored-by: Pablo <pablotr9@correo.ugr.es> Co-authored-by: Alberto Andújar <josealbertoandujar@gmail.com> Co-authored-by: Desvelao <iamdesvelao@gmail.com>
1 parent 524e5cb commit 48c5519

File tree

117 files changed

+5405
-1238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+5405
-1238
lines changed

.i18nrc.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"paths": {
3+
"wazuh": "public"
4+
},
5+
"exclude": [
6+
],
7+
"translations": [
8+
]
9+
}

public/app.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ app.config([
9090
}
9191
]);
9292

93-
app.run(function () {
93+
app.run(['$injector', function (_$injector) {
9494
chrome
9595
.setRootTemplate(`
9696
<react-component name="WzMenuWrapper" props="" />
@@ -99,6 +99,7 @@ app.run(function () {
9999
`)
100100
.setRootController(() => require('./app'));
101101
changeWazuhNavLogo();
102-
});
102+
app.$injector = _$injector;
103+
}]);
103104

104105

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/*
2+
* Wazuh app - Integrity monitoring components
3+
* Copyright (C) 2015-2020 Wazuh, Inc.
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 2 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* Find more information about this on the LICENSE file.
11+
*/
12+
13+
import React, { Component } from 'react';
14+
import { FlyoutDetail } from './states/flyout';
15+
import { ModulesHelper } from '../../common/modules/modules-helper'
16+
import { EuiOverlayMask } from '@elastic/eui';
17+
18+
19+
export class EventsFim extends Component {
20+
_isMount = false;
21+
state: {
22+
isFlyoutVisible: Boolean,
23+
currentFile: string,
24+
fetchStatus: 'loading' | 'complete',
25+
rows: number
26+
};
27+
props!: {
28+
[key: string]: any
29+
}
30+
modulesHelper: ModulesHelper;
31+
fetchWatch!: any;
32+
33+
constructor(props) {
34+
super(props);
35+
this.state = {
36+
isFlyoutVisible: false,
37+
currentFile: '',
38+
fetchStatus: 'loading',
39+
rows: 0
40+
};
41+
this.modulesHelper = ModulesHelper;
42+
this.getRowsField.bind(this);
43+
}
44+
45+
async componentDidMount() {
46+
this._isMount = true;
47+
const scope = await this.modulesHelper.getDiscoverScope();
48+
this.fetchWatch = scope.$watchCollection('fetchStatus',
49+
() => {
50+
const {fetchStatus} = this.state;
51+
if (fetchStatus !== scope.fetchStatus){
52+
const rows = scope.fetchStatus === 'complete' ? scope.rows.length : 0;
53+
this._isMount && this.setState({fetchStatus: scope.fetchStatus, rows})
54+
}
55+
});
56+
}
57+
58+
shouldComponentUpdate(nextProps, nextState) {
59+
const {fetchStatus, isFlyoutVisible, rows} = this.state;
60+
if (nextState.isFlyoutVisible !== isFlyoutVisible ){
61+
return true;
62+
}
63+
if (nextState.fetchStatus !== fetchStatus){
64+
return true;
65+
}
66+
if (nextState.rows !== rows) {
67+
return true;
68+
}
69+
return false;
70+
}
71+
72+
componentDidUpdate() {
73+
const {fetchStatus, rows} = this.state;
74+
if(fetchStatus === 'complete' && rows){
75+
this.getRowsField();
76+
}
77+
}
78+
79+
componentWillUnmount() {
80+
this._isMount = false;
81+
if (this.fetchWatch) this.fetchWatch();
82+
}
83+
84+
getRowsField = async () => {
85+
const indices: number[] = [];
86+
const { rows } = this.state;
87+
if (!rows) {
88+
this.setState({elements:[]})
89+
return;
90+
}
91+
if (!document)
92+
this.getRowsField();
93+
const cols = document.querySelectorAll(`.kbn-table thead th`);
94+
if (!(cols || []).length) {
95+
setTimeout(this.getRowsField, 10);
96+
}
97+
cols.forEach((col, idx) => {
98+
if (['syscheck.path', 'rule.id'].includes(col.textContent || '')) {
99+
indices.push(idx + 1);
100+
}
101+
});
102+
let query = '';
103+
indices.forEach((position, idx) => {
104+
query += `.kbn-table tbody tr td:nth-child(${position}) div`
105+
if (idx !== indices.length - 1) {
106+
query += ', ';
107+
}
108+
});
109+
if (query){
110+
const elements = document.querySelectorAll(query);
111+
elements.forEach((element, idx) => {
112+
const text = element.textContent;
113+
if (idx % 2){
114+
element.childNodes.forEach(child => {
115+
if (child.nodeName === 'SPAN'){
116+
const link = document.createElement('a')
117+
link.setAttribute('href', `#/manager/rules?tab=rules&redirectRule=${text}`)
118+
link.setAttribute('target', '_blank')
119+
link.setAttribute('style', 'minWidth: 55, display: "block"');
120+
link.textContent = text
121+
child.replaceWith(link)
122+
}
123+
})
124+
} else {
125+
element.childNodes.forEach(child => {
126+
if (child.nodeName === 'SPAN'){
127+
const link = document.createElement('a')
128+
link.onclick = () => this.showFlyout(text);
129+
link.textContent = text
130+
child.replaceWith(link);
131+
}
132+
})
133+
}
134+
})
135+
}
136+
}
137+
138+
showFlyout(file) {
139+
if (file !== " - ") {
140+
//if a flyout is opened, we close it and open a new one, so the components are correctly updated on start.
141+
this.setState({ isFlyoutVisible: true, currentFile: file });
142+
}
143+
}
144+
145+
closeFlyout() {
146+
this.setState({ isFlyoutVisible: false, currentFile: false });
147+
}
148+
149+
render() {
150+
return (
151+
this.state.isFlyoutVisible &&
152+
<EuiOverlayMask
153+
// @ts-ignore
154+
onClick={(e:Event) => {e.target.className === 'euiOverlayMask' && this.closeFlyout() }} >
155+
<FlyoutDetail
156+
fileName={this.state.currentFile}
157+
agentId={this.props.agent.id}
158+
closeFlyout={() => this.closeFlyout()}
159+
type='file'
160+
view='events'
161+
{...this.props}/>
162+
</EuiOverlayMask>
163+
)
164+
}
165+
}

public/components/agents/fim/index.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Wazuh app - Integrity monitoring components
3+
* Copyright (C) 2015-2020 Wazuh, Inc.
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 2 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* Find more information about this on the LICENSE file.
11+
*/
12+
13+
export { MainFim } from './main';
14+
export { States} from './states';

public/components/agents/fim/main.tsx

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React, { Component } from 'react';
2+
import { States } from './index';
3+
import '../../common/modules/module.less';
4+
5+
export class MainFim extends Component {
6+
constructor(props) {
7+
super(props);
8+
}
9+
10+
11+
render() {
12+
const { selectView } = this.props;
13+
if (selectView) {
14+
return (
15+
<div>
16+
{selectView === 'states' &&
17+
<States {...this.props}
18+
/>}
19+
</div>
20+
);
21+
} else {
22+
return false;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)