Skip to content

Commit

Permalink
Merge pull request #1998 from deepfence/inbound-outbound-ips
Browse files Browse the repository at this point in the history
Show inbound and outbound ips individually on connections table
  • Loading branch information
manV authored Feb 29, 2024
2 parents 64ed529 + 3dd9454 commit e5e60b6
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
2 changes: 2 additions & 0 deletions deepfence_frontend/apps/dashboard/api-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -12795,6 +12795,7 @@
"active": { "type": "boolean" },
"cloud_provider": { "type": "string" },
"compliance_percentage": { "type": "number" },
"host_node_id": { "type": "string" },
"last_scan_id": { "type": "string" },
"last_scan_status": { "type": "string" },
"node_id": { "type": "string" },
Expand Down Expand Up @@ -13147,6 +13148,7 @@
"type": "object",
"properties": {
"count": { "type": "integer" },
"ips": { "type": "array", "items": {}, "nullable": true },
"node_id": { "type": "string" },
"node_name": { "type": "string" }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export interface ModelCloudNodeAccountInfo {
* @memberof ModelCloudNodeAccountInfo
*/
compliance_percentage?: number;
/**
*
* @type {string}
* @memberof ModelCloudNodeAccountInfo
*/
host_node_id?: string;
/**
*
* @type {string}
Expand Down Expand Up @@ -97,6 +103,7 @@ export function ModelCloudNodeAccountInfoFromJSONTyped(json: any, ignoreDiscrimi
'active': !exists(json, 'active') ? undefined : json['active'],
'cloud_provider': !exists(json, 'cloud_provider') ? undefined : json['cloud_provider'],
'compliance_percentage': !exists(json, 'compliance_percentage') ? undefined : json['compliance_percentage'],
'host_node_id': !exists(json, 'host_node_id') ? undefined : json['host_node_id'],
'last_scan_id': !exists(json, 'last_scan_id') ? undefined : json['last_scan_id'],
'last_scan_status': !exists(json, 'last_scan_status') ? undefined : json['last_scan_status'],
'node_id': !exists(json, 'node_id') ? undefined : json['node_id'],
Expand All @@ -118,6 +125,7 @@ export function ModelCloudNodeAccountInfoToJSON(value?: ModelCloudNodeAccountInf
'active': value.active,
'cloud_provider': value.cloud_provider,
'compliance_percentage': value.compliance_percentage,
'host_node_id': value.host_node_id,
'last_scan_id': value.last_scan_id,
'last_scan_status': value.last_scan_status,
'node_id': value.node_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export interface ModelConnection {
* @memberof ModelConnection
*/
count?: number;
/**
*
* @type {Array<any>}
* @memberof ModelConnection
*/
ips?: Array<any> | null;
/**
*
* @type {string}
Expand Down Expand Up @@ -59,6 +65,7 @@ export function ModelConnectionFromJSONTyped(json: any, ignoreDiscriminator: boo
return {

'count': !exists(json, 'count') ? undefined : json['count'],
'ips': !exists(json, 'ips') ? undefined : json['ips'],
'node_id': !exists(json, 'node_id') ? undefined : json['node_id'],
'node_name': !exists(json, 'node_name') ? undefined : json['node_name'],
};
Expand All @@ -74,6 +81,7 @@ export function ModelConnectionToJSON(value?: ModelConnection | null): any {
return {

'count': value.count,
'ips': value.ips,
'node_id': value.node_id,
'node_name': value.node_name,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,33 @@ export const ConnectionsTable = ({
},
]);

const expandedConnections = useMemo(() => {
const newConnections: ModelConnection[] = [];
connections.forEach((connection) => {
const ipsMap: Record<string, number> = {};
if (connection.ips?.length) {
connection.ips.forEach((ip) => {
if (ipsMap[ip]) {
ipsMap[ip] += 1;
} else {
ipsMap[ip] = 1;
}
});
Object.keys(ipsMap).forEach((ip) => {
newConnections.push({
...connection,
node_id: ip,
node_name: ip,
count: ipsMap[ip],
});
});
} else {
newConnections.push(connection);
}
});
return newConnections;
}, [connections]);

const columns = useMemo(() => {
return [
columnHelper.accessor('node_name', {
Expand Down Expand Up @@ -324,7 +351,7 @@ export const ConnectionsTable = ({
/>
<Table
columns={columns}
data={connections}
data={expandedConnections}
size="compact"
enablePagination
pageSize={10}
Expand Down

0 comments on commit e5e60b6

Please sign in to comment.