Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance rework vulnerabilities inventory flyout #3908

Merged
merged 6 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions public/components/agents/vuls/inventory/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ export class Details extends Component {
},
{
field: 'last_full_scan',
name: 'Last Full Scan',
name: 'Last full scan',
icon: 'clock',
link: false,
transformValue: formatUIDate
},
{
field: 'last_partial_scan',
name: 'Last Partial Scan',
name: 'Last partial scan',
icon: 'clock',
link: false,
transformValue: formatUIDate
Expand Down Expand Up @@ -451,6 +451,7 @@ export class Details extends Component {
{ field: 'rule.description', label: 'Description' },
{ field: 'rule.level', label: 'Level' },
{ field: 'rule.id', label: 'Rule ID' },
{ field: 'data.vulnerability.status', label: 'Status', width: '20%' },
]}
includeFilters="vulnerability"
implicitFilters={implicitFilters}
Expand Down
6 changes: 5 additions & 1 deletion public/components/common/modules/discover/discover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const Discover = compose(
initialFilters: object[];
query?: { language: 'kuery' | 'lucene'; query: string };
type?: any;
rowDetailsFields?: string[];
updateTotalHits: Function;
includeFilters?: string;
initialColumns: ColumnDefinition[];
Expand Down Expand Up @@ -323,6 +324,8 @@ export const Discover = compose(

toggleDetails = (item) => {
const itemIdToExpandedRowMap = { ...this.state.itemIdToExpandedRowMap };
const { rowDetailsFields } = this.props;

if (itemIdToExpandedRowMap[item._id]) {
delete itemIdToExpandedRowMap[item._id];
this.setState({ itemIdToExpandedRowMap });
Expand All @@ -336,6 +339,7 @@ export const Discover = compose(
addFilter={(filter) => this.addFilter(filter)}
addFilterOut={(filter) => this.addFilterOut(filter)}
toggleColumn={(id) => this.addColumn(id)}
rowDetailsFields={rowDetailsFields}
/>
</div>
);
Expand Down Expand Up @@ -474,7 +478,7 @@ export const Discover = compose(
const columns = columnsList.map((item) => {
if (item === 'icon') {
return {
width: '25px',
width: '2.3%',
isExpander: true,
render: (item) => {
return (
Expand Down
15 changes: 14 additions & 1 deletion public/components/common/modules/discover/row-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class RowDetails extends Component {
},
syscheck: Object
}
rowDetailsFields?: string[]
}

constructor(props) {
Expand Down Expand Up @@ -94,6 +95,15 @@ export class RowDetails extends Component {

const paths = (obj = {}, head = '') => {
return Object.entries(obj)
.sort(([keyA], [keyB]) => {
if (keyA > keyB) {
return 1;
} else if (keyA < keyB) {
return -1;
} else {
return 0;
};
})
.reduce((product, [key, value]) => {
let fullPath = addDelimiter(head, key)
return isObject(value) ?
Expand Down Expand Up @@ -146,7 +156,10 @@ export class RowDetails extends Component {


renderRows() {
const fieldsToShow = ['agent', 'cluster', 'manager', 'rule', 'decoder', 'syscheck', 'full_log', 'location'];
// By default show all available fields, otherwise show the fields specified in rowDetailsFields string array
const fieldsToShow = this.props.rowDetailsFields?.length ?
this.props.rowDetailsFields.sort() : Object.keys(this.props.item).sort();

var rows: any[] = [];
const isString = val => typeof val === 'string';
for (var i = 0; i < fieldsToShow.length; i++) {
Expand Down