Skip to content

Commit

Permalink
Merge branch '4.8.0' into 6095-Visualizations-with-different-colors
Browse files Browse the repository at this point in the history
  • Loading branch information
chantal-kelm authored Nov 16, 2023
2 parents f61e9b6 + 2d4f2a0 commit 236a227
Show file tree
Hide file tree
Showing 49 changed files with 1,677 additions and 1,331 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/dev-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ jobs:
path: 'wazuh/plugins/wazuh-check-updates',
container_path: 'wazuh-check-updates',
},
{
name: 'Wazuh Core',
path: 'wazuh/plugins/wazuh-core',
container_path: 'wazuh-core',
},
]

steps:
Expand Down
17 changes: 11 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ All notable changes to the Wazuh app project will be documented in this file.
- Added the ssl_agent_ca configuration to the SSL Settings form [#6083](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6083)
- Added global vulnerabilities dashboards [#5896](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5896)
- Added an agent selector to the IT Hygiene application [#5840](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5840)
- Added query results limit when the search exceed 10000 hits [#6106](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6106)

### Changed

- Moved the plugin menu to platform applications into the side menu [#5840](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5840)
- Changed dashboards. [#6035](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6035)
- Change the display order of tabs in all modules. [#6067](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6067)
- Upgraded the `axios` dependency to `1.6.1` [#5062](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5062)

### Fixed

Expand All @@ -27,18 +31,19 @@ All notable changes to the Wazuh app project will be documented in this file.
- Removed the `disabled_roles` and `customization.logo.sidebar` settings [#5840](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5840)
- Removed the ability to configure the visibility of modules and removed `extensions.*` settings [#5840](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5840)

### Changed

- Changed dashboards. [#6035](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6035)
- Change the display order of tabs in all modules. [#6067](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6067)

## Wazuh v4.7.1 - OpenSearch Dashboards 2.8.0 - Revision 00

### Added

- Support for Wazuh 4.7.1

## Wazuh v4.7.0 - OpenSearch Dashboards 2.8.0 - Revision 01
### Fixed

- Fixed problem when using non latin characters in the username [#6076](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6076)
- Fixed UI crash on retrieving log collection configuration for macos agent. [#6104](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6104)
- Fixed incorrect validation of the agent name on the Deploy new agent window [#6105](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6105)

## Wazuh v4.7.0 - OpenSearch Dashboards 2.8.0 - Revision 03

### Added

Expand Down
274 changes: 135 additions & 139 deletions RELEASING.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions plugins/main/common/api-info/endpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -8146,6 +8146,14 @@
"default": false
}
},
{
"name": "distinct",
"description": "Look for distinct values.",
"schema": {
"type": "boolean",
"default": false
}
},
{
"name": "gateway",
"description": "Filter by network gateway",
Expand Down
10 changes: 4 additions & 6 deletions plugins/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,15 @@
"test:ui:runner": "node ../../scripts/functional_test_runner.js",
"test:server": "plugin-helpers test:server",
"test:browser": "plugin-helpers test:browser",
"test:jest": "node scripts/jest",
"test:jest": "node scripts/jest --runInBand",
"test:jest:runner": "node scripts/runner test",
"generate:api-data": "node scripts/generate-api-data.js --spec https://raw.githubusercontent.com/wazuh/wazuh/$(node -e \"console.log(require('./package.json').version.split('.').splice(0,2).join('.'))\")/api/api/spec/spec.yaml --output file --output-directory common/api-info --display-configuration",
"release:bump": "node scripts/release/bump --manifest-package package.json --manifest-plugin opensearch_dashboards.json --manifest-changelog ../../CHANGELOG.md",
"release:tag": "node scripts/release/tag --manifest-package package.json --manifest-changelog ../../CHANGELOG.md",
"generate:api-data": "node scripts/generate-api-data.js --spec https://raw.githubusercontent.com/wazuh/wazuh/$(node -e \"console.log(require('./package.json').version)\")/api/api/spec/spec.yaml --output file --output-directory common/api-info --display-configuration",
"prebuild": "node scripts/generate-build-version"
},
"dependencies": {
"angular-animate": "1.8.3",
"angular-material": "1.2.5",
"axios": "^1.3.4",
"axios": "^1.6.1",
"install": "^0.13.0",
"js2xmlparser": "^5.0.0",
"json2csv": "^4.1.2",
Expand Down Expand Up @@ -85,4 +83,4 @@
"redux-mock-store": "^1.5.4",
"swagger-client": "^3.19.11"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { EuiDataGridColumn } from "@elastic/eui";

export const MAX_ENTRIES_PER_QUERY = 10000;

export const inventoryTableDefaultColumns: EuiDataGridColumn[] = [
{
id: 'package.name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ import {
EuiFlyoutHeader,
EuiTitle,
EuiButtonEmpty,
EuiCallOut,
EuiSpacer
} from '@elastic/eui';
import { IndexPattern } from '../../../../../../../../src/plugins/data/common';
import { SearchResponse } from '../../../../../../../../src/core/server';
import DocViewer from '../../doc_viewer/doc_viewer';
import { DiscoverNoResults } from '../../common/components/no_results';
import { LoadingSpinner } from '../../common/components/loading_spinner';
import { useDataGrid } from '../../data_grid/use_data_grid';
import { inventoryTableDefaultColumns } from './config';
import { MAX_ENTRIES_PER_QUERY, inventoryTableDefaultColumns } from './config';
import { useDocViewer } from '../../doc_viewer/use_doc_viewer';
import './inventory.scss';
import { VULNERABILITIES_INDEX_PATTERN_ID } from '../../common/constants';
import { search, exportSearchToCSV } from './inventory_service';
import { ErrorHandler, ErrorFactory, HttpError } from '../../../../../react-services/error-management';
import { withErrorBoundary } from '../../../../common/hocs';
import { HitsCounter } from '../../../../../kibana-integrations/discover/application/components/hits_counter/hits_counter';
import { formatNumWithCommas } from '../../../../../kibana-integrations/discover/application/helpers';

const InventoryVulsComponent = () => {
const { searchBarProps } = useSearchBarConfiguration({
Expand All @@ -40,6 +44,7 @@ const InventoryVulsComponent = () => {
const [inspectedHit, setInspectedHit] = useState<any>(undefined);
const [indexPattern, setIndexPattern] = useState<IndexPattern | undefined>(undefined);
const [isSearching, setIsSearching] = useState<boolean>(false);
const [isExporting, setIsExporting] = useState<boolean>(false);

const onClickInspectDoc = useMemo(() => (index: number) => {
const rowClicked = results.hits.hits[index];
Expand Down Expand Up @@ -77,22 +82,20 @@ const InventoryVulsComponent = () => {
useEffect(() => {
if (!isLoading) {
setIndexPattern(indexPatterns?.[0] as IndexPattern);
try {
search({
indexPattern: indexPatterns?.[0] as IndexPattern,
filters,
query,
pagination,
sorting
}).then((results) => {
setResults(results);
setIsSearching(false);
});
}catch(error){
const searchError = ErrorFactory.create(HttpError, { error, message: 'Error searching vulnerabilities' })
search({
indexPattern: indexPatterns?.[0] as IndexPattern,
filters,
query,
pagination,
sorting
}).then((results) => {
setResults(results);
setIsSearching(false);
}).catch((error) => {
const searchError = ErrorFactory.create(HttpError, { error, message: 'Error fetching vulnerabilities' })
ErrorHandler.handleError(searchError);
setIsSearching(false);
}
})
}
}, [JSON.stringify(searchBarProps), JSON.stringify(pagination), JSON.stringify(sorting)]);

Expand All @@ -111,10 +114,13 @@ const InventoryVulsComponent = () => {
sorting
}
try {
setIsExporting(true);
await exportSearchToCSV(params);
}catch(error){
} catch (error) {
const searchError = ErrorFactory.create(HttpError, { error, message: 'Error downloading csv report' })
ErrorHandler.handleError(searchError);
}finally{
setIsExporting(false);
}
}

Expand All @@ -127,56 +133,70 @@ const InventoryVulsComponent = () => {
grow
>
<>
{isLoading ?
<LoadingSpinner /> :
<SearchBar
appName='inventory-vuls'
{...searchBarProps}
{isLoading ?
<LoadingSpinner /> :
<SearchBar
appName='inventory-vuls'
{...searchBarProps}
showDatePicker={false}
showQueryInput={true}
showQueryBar={true}
/>}
{isSearching ?
/>}
{isSearching ?
<LoadingSpinner /> : null}
{!isLoading && !isSearching && results?.hits?.total === 0 ?
{!isLoading && !isSearching && results?.hits?.total === 0 ?
<DiscoverNoResults timeFieldName={timeField} queryLanguage={''} /> : null}
{!isLoading && !isSearching && results?.hits?.total > 0 ?
<EuiDataGrid
{...dataGridProps}
{!isLoading && !isSearching && results?.hits?.total > 0 ? (
<EuiDataGrid
{...dataGridProps}
toolbarVisibility={{
additionalControls: (
<EuiButtonEmpty
disabled={results?.hits?.total === 0}
size="xs"
iconType="exportAction"
color="primary"
className="euiDataGrid__controlBtn"
onClick={onClickExportResults}>
Export Formated
</EuiButtonEmpty>
),
<>
<HitsCounter
hits={results?.hits?.total}
showResetButton={false}
onResetQuery={() => { }}
tooltip={results?.hits?.total && results?.hits?.total > MAX_ENTRIES_PER_QUERY ? {
ariaLabel: 'Warning',
content: `The query results has exceeded the limit of 10,000 hits. To provide a better experience the table only shows the first ${formatNumWithCommas(MAX_ENTRIES_PER_QUERY)} hits.`,
iconType: 'alert',
position: 'top'
} : undefined}
/>
<EuiButtonEmpty
disabled={results?.hits?.total === 0}
size="xs"
iconType="exportAction"
color="primary"
isLoading={isExporting}
className="euiDataGrid__controlBtn"
onClick={onClickExportResults}>
Export Formated
</EuiButtonEmpty>
</>
)
}}
/> : null}
{inspectedHit && (
<EuiFlyout onClose={() => setInspectedHit(undefined)} size="m">
<EuiFlyoutHeader>
<EuiTitle>
<h2>Document Details</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiFlexGroup direction="column">
<EuiFlexItem>
<DocViewer
{...docViewerProps} />
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlyoutBody>
</EuiFlyout>
)}
</>
</EuiPageTemplate>
</IntlProvider>
/>) : null}
{inspectedHit && (
<EuiFlyout onClose={() => setInspectedHit(undefined)} size="m">
<EuiFlyoutHeader>
<EuiTitle>
<h2>Document Details</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiFlexGroup direction="column">
<EuiFlexItem>
<DocViewer
{...docViewerProps} />
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlyoutBody>
</EuiFlyout>
)}
</>
</EuiPageTemplate>
</IntlProvider >
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getPlugins } from '../../../../../kibana-services';
import { IndexPattern, Filter, OpenSearchQuerySortValue } from "../../../../../../../../src/plugins/data/public";
import * as FileSaver from '../../../../../services/file-saver';
import { beautifyDate } from "../../../../agents/vuls/inventory/lib";
import { MAX_ENTRIES_PER_QUERY } from "./config";


interface SearchParams {
Expand All @@ -22,9 +23,11 @@ interface SearchParams {
};
}


export const search = async (params: SearchParams): Promise<SearchResponse> => {
export const search = async (params: SearchParams): Promise<SearchResponse | void> => {
const { indexPattern, filters = [], query, pagination, sorting, fields } = params;
if(!indexPattern){
return;
}
const data = getPlugins().data;
const searchSource = await data.search.searchSource.create();
const fromField = (pagination?.pageIndex || 0) * (pagination?.pageSize || 100);
Expand All @@ -43,11 +46,18 @@ export const search = async (params: SearchParams): Promise<SearchResponse> => {
.setField('index', indexPattern)

// add fields
if (fields && Array.isArray(fields) && fields.length > 0)
if (fields && Array.isArray(fields) && fields.length > 0){
searchParams.setField('fields', fields);
}
try{
return await searchParams.fetch();
}catch(error){
if(error.body){
throw error.body;
}
throw error;
}


return await searchParams.fetch();
};


Expand Down Expand Up @@ -99,7 +109,7 @@ export const getFieldFormatted = (rowIndex, columnId, indexPattern, rowsParsed)
}

export const exportSearchToCSV = async (params: SearchParams): Promise<void> => {
const DEFAULT_MAX_SIZE_PER_CALL = 10000;
const DEFAULT_MAX_SIZE_PER_CALL = 1000;
const { indexPattern, filters = [], query, sorting, fields, pagination } = params;
// when the pageSize is greater than the default max size per call (10000)
// then we need to paginate the search
Expand All @@ -112,7 +122,7 @@ export const exportSearchToCSV = async (params: SearchParams): Promise<void> =>
let searchResults;
if (mustPaginateSearch) {
// paginate the search
while (hitsCount < totalHits) {
while (hitsCount < totalHits &&  hitsCount < MAX_ENTRIES_PER_QUERY) {
const searchParams = {
indexPattern,
filters,
Expand All @@ -131,10 +141,11 @@ export const exportSearchToCSV = async (params: SearchParams): Promise<void> =>
}
} else {
searchResults = await search(params);
allHits = searchResults.hits.hits;
}

const resultsFields = fields;
const data = searchResults.hits.hits.map((hit) => {
const data = allHits.map((hit) => {
// check if the field type is a date
const dateFields = indexPattern.fields.getByType('date');
const dateFieldsNames = dateFields.map((field) => field.name);
Expand Down Expand Up @@ -178,6 +189,6 @@ export const exportSearchToCSV = async (params: SearchParams): Promise<void> =>
);

if (blobData) {
FileSaver?.saveAs(blobData, 'vulnerabilities_inventory.csv');
FileSaver?.saveAs(blobData, `vulnerabilities_inventory-${new Date().toISOString()}.csv`);
}
}
Loading

0 comments on commit 236a227

Please sign in to comment.