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

Added filters of integrations in table column #1863

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isEmpty } from 'lodash-es';
import { has, isEmpty } from 'lodash-es';
import { useMemo } from 'react';
import { useParams } from 'react-router-dom';
import { createColumnHelper, Dropdown, DropdownItem, Tooltip } from 'ui-components';
Expand Down Expand Up @@ -545,6 +545,61 @@ export const useIntegrationTableColumn = (
maxSize: 75,
}),
...getDynamicTableColumns(),
columnHelper.display({
id: 'filters',
enableSorting: false,
cell: ({ row }) => {
const displayFilters: {
severities?: string[];
statuses?: string[];
node_ids?: Array<{ node_id: string; node_type: string }> | null;
custom_fields?: string[];
} = {};
const filters = row.original.filters;
const containFilter = filters?.fields_filters?.contains_filter;
const filterIn = containFilter?.filter_in;
const hasSeverity = has(filterIn, 'cve_severity');
const hasStatus = has(filterIn, 'status');
if (filters?.node_ids && filters?.node_ids.length) {
displayFilters.node_ids = filters?.node_ids;
}

if (hasSeverity) {
displayFilters.severities = filterIn?.['cve_severity'] ?? [];
} else if (hasStatus) {
displayFilters.statuses = filterIn?.['status'] ?? [];
}

const configs = row.original.config;
const customFields = configs?.custom_fields;

if (customFields) {
displayFilters.custom_fields = customFields;
}

if (isEmpty(displayFilters)) {
return '-';
}

return (
<Tooltip
content={
<pre className="text-p7 text-text-input-value h-[300px] overflow-auto">
{JSON.stringify(displayFilters, null, 2)}
</pre>
}
triggerAsChild
>
<div className="w-full truncate">{JSON.stringify(displayFilters)}</div>
</Tooltip>
);
},
header: () => 'Filter',
minSize: 65,
size: 70,
maxSize: 80,
enableResizing: true,
}),
];
return columns;
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ const possibleScanMap: PossibleScanMapType = {
aws: [cloudComplianceScanData],
gcp: [cloudComplianceScanData],
azure: [cloudComplianceScanData],
aws_org: [cloudComplianceScanData],
gcp_org: [cloudComplianceScanData],
azure_org: [cloudComplianceScanData],
host: [vulnerabilityScanData, complianceScanData, secretScanData, malwareScanData],
kubernetes_cluster: [
vulnerabilityScanData,
Expand All @@ -99,14 +102,26 @@ const logoAndTextMap = (
title: `Amazon Web Service Account${count > 1 ? 's' : ''}`,
logo: <CloudLine />,
},
aws_org: {
title: `Amazon Web Service Account${count > 1 ? 's' : ''}`,
logo: <CloudLine />,
},
gcp: {
title: `Google Cloud Service Account${count > 1 ? 's' : ''}`,
logo: <CloudLine />,
},
gcp_org: {
title: `Google Cloud Service Account${count > 1 ? 's' : ''}`,
logo: <CloudLine />,
},
azure: {
title: `Azure Web Service Account${count > 1 ? 's' : ''}`,
logo: <CloudLine />,
},
azure_org: {
title: `Azure Web Service Account${count > 1 ? 's' : ''}`,
logo: <CloudLine />,
},
host: {
title: `Linux Host${count > 1 ? 's' : ''}`,
logo: <HostIcon />,
Expand Down
Loading