Skip to content

Commit

Permalink
Change new vulnerabilities inventory table (#6047)
Browse files Browse the repository at this point in the history
* Add data grid hook

* Add doc viewer component and hook

* Add ui utils components

* Add new vuls inventory component

* Add vuls inventory in module rendering

* Add full height container

* Add inventory table columns

* Remove columns fields filter by keyword type
  • Loading branch information
Machi3mfl authored Oct 25, 2023
1 parent 4bacf97 commit f083c95
Show file tree
Hide file tree
Showing 11 changed files with 751 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const ModulesDefaults = {
EventsTab,
],
buttons: ['settings'],
availableFor: ['manager', 'agent'],
availableFor: ['manager'],
},
mitre: {
init: 'dashboard',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.discoverNoResults {
display: flex;
align-items: center;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import './loading_spinner.scss';
import React from 'react';
import { EuiTitle, EuiPanel, EuiEmptyPrompt, EuiLoadingSpinner } from '@elastic/eui';
import { FormattedMessage } from '@osd/i18n/react';

export function LoadingSpinner() {
return (
<EuiPanel hasBorder={false} hasShadow={false} color="transparent" className="discoverNoResults">
<EuiEmptyPrompt
icon={<EuiLoadingSpinner data-test-subj="loadingSpinner" size="xl" />}
title={
<EuiTitle size="s" data-test-subj="loadingSpinnerText">
<h2>
<FormattedMessage id="discover.searchingTitle" defaultMessage="Searching" />
</h2>
</EuiTitle>
}
/>
</EuiPanel>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React, { Fragment } from 'react';
import { FormattedMessage, I18nProvider } from '@osd/i18n/react';

import {
EuiCallOut,
EuiCode,
EuiDescriptionList,
EuiLink,
EuiPanel,
EuiSpacer,
EuiText,
} from '@elastic/eui';

interface Props {
timeFieldName?: string;
queryLanguage?: string;
}

export const DiscoverNoResults = ({ timeFieldName, queryLanguage }: Props) => {
let timeFieldMessage;

if (timeFieldName) {
timeFieldMessage = (
<Fragment>
<EuiSpacer size="xl" />

<EuiText>
<h2 data-test-subj="discoverNoResultsTimefilter">
<FormattedMessage
id="discover.noResults.expandYourTimeRangeTitle"
defaultMessage="Expand your time range"
/>
</h2>

<p>
<FormattedMessage
id="discover.noResults.queryMayNotMatchTitle"
defaultMessage="One or more of the indices you&rsquo;re looking at contains a date field. Your query may
not match anything in the current time range, or there may not be any data at all in
the currently selected time range. You can try changing the time range to one which contains data."
/>
</p>
</EuiText>
</Fragment>
);
}

let luceneQueryMessage;

if (queryLanguage === 'lucene') {
const searchExamples = [
{
description: <EuiCode>200</EuiCode>,
title: (
<EuiText>
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.anyField200StatusCodeExampleTitle"
defaultMessage="Find requests that contain the number 200, in any field"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:200</EuiCode>,
title: (
<EuiText>
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.statusField200StatusCodeExampleTitle"
defaultMessage="Find 200 in the status field"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:[400 TO 499]</EuiCode>,
title: (
<EuiText>
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.400to499StatusCodeExampleTitle"
defaultMessage="Find all status codes between 400-499"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:[400 TO 499] AND extension:PHP</EuiCode>,
title: (
<EuiText>
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.400to499StatusCodeWithPhpExtensionExampleTitle"
defaultMessage="Find status codes 400-499 with the extension php"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:[400 TO 499] AND (extension:php OR extension:html)</EuiCode>,
title: (
<EuiText>
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.400to499StatusCodeWithPhpOrHtmlExtensionExampleTitle"
defaultMessage="Find status codes 400-499 with the extension php or html"
/>
</strong>
</EuiText>
),
},
];

luceneQueryMessage = (
<Fragment>
<EuiSpacer size="xl" />

<EuiText>
<h3>
<FormattedMessage
id="discover.noResults.searchExamples.refineYourQueryTitle"
defaultMessage="Refine your query"
/>
</h3>

<p>
<FormattedMessage
id="discover.noResults.searchExamples.howTosearchForWebServerLogsDescription"
defaultMessage="The search bar at the top uses OpenSearch&rsquo;s support for Lucene {queryStringSyntaxLink}.
Here are some examples of how you can search for web server logs that have been parsed into a few fields."
/>
</p>
</EuiText>

<EuiSpacer size="m" />

<EuiDescriptionList type="column" listItems={searchExamples} />

<EuiSpacer size="xl" />
</Fragment>
);
}

return (
<I18nProvider>
<EuiPanel hasBorder={false} hasShadow={false} color="transparent">
<EuiCallOut
title={
<FormattedMessage
id="discover.noResults.searchExamples.noResultsMatchSearchCriteriaTitle"
defaultMessage="No results match your search criteria"
/>
}
color="warning"
iconType="help"
data-test-subj="discoverNoResults"
/>
{timeFieldMessage}
{luceneQueryMessage}
</EuiPanel>
</I18nProvider>
);
};
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VULNERABILITIES_INDEX_PATTERN_ID = 'wazuh-inventory-cve'
export const VULNERABILITIES_INDEX_PATTERN_ID = 'wazuh-states-vulnerabilities';
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { EuiDataGridColumn } from "@elastic/eui";

export const inventoryTableDefaultColumns: EuiDataGridColumn[] = [
{
id: '@timestamp',
displayAsText: 'Timestamp',
},
{
id: 'package.name',
displayAsText: 'Name',
},
{
id: 'package.version',
displayAsText: 'Version',
},
{
id: 'package.architecture',
displayAsText: 'Architecture',
},
{
id: 'vulnerability.severity',
displayAsText: 'Severity',
},
{
id: 'vulnerability.id',
displayAsText: 'Id',
},
{
id: 'vulnerability.score.version',
displayAsText: 'Score version',
},
{
id: 'vulnerability.score.base',
displayAsText: 'Score',
},
{
id: 'event.created',
displayAsText: 'Detected time',
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.vulsInventoryContainer {
height: calc(100vh - 104px);
}


.headerIsExpanded .vulsInventoryContainer {
height: calc(100vh - 153px);
}
Loading

0 comments on commit f083c95

Please sign in to comment.