diff --git a/deepfence_frontend/apps/dashboard/api-spec.json b/deepfence_frontend/apps/dashboard/api-spec.json index c40afbe122..c609a0a31e 100644 --- a/deepfence_frontend/apps/dashboard/api-spec.json +++ b/deepfence_frontend/apps/dashboard/api-spec.json @@ -627,6 +627,62 @@ "security": [{ "bearer_token": [] }] } }, + "/deepfence/complete/container": { + "post": { + "tags": ["Completion"], + "summary": "Get Completion for Container fields", + "description": "Complete Container info", + "operationId": "completeContainerInfo", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CompletionCompletionNodeFieldReq" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CompletionCompletionNodeFieldRes" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ApiDocsBadRequestResponse" } + } + } + }, + "401": { "description": "Unauthorized" }, + "403": { "description": "Forbidden" }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ApiDocsFailureResponse" } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ApiDocsFailureResponse" } + } + } + } + }, + "security": [{ "bearer_token": [] }] + } + }, "/deepfence/complete/host": { "post": { "tags": ["Completion"], @@ -683,6 +739,62 @@ "security": [{ "bearer_token": [] }] } }, + "/deepfence/complete/pod": { + "post": { + "tags": ["Completion"], + "summary": "Get Completion for Pod fields", + "description": "Complete Pod info", + "operationId": "completePodInfo", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CompletionCompletionNodeFieldReq" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CompletionCompletionNodeFieldRes" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ApiDocsBadRequestResponse" } + } + } + }, + "401": { "description": "Unauthorized" }, + "403": { "description": "Forbidden" }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ApiDocsFailureResponse" } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ApiDocsFailureResponse" } + } + } + } + }, + "security": [{ "bearer_token": [] }] + } + }, "/deepfence/complete/process": { "post": { "tags": ["Completion"], @@ -13095,6 +13207,7 @@ "nullable": true }, "cron_expr": { "type": "string" }, + "deepfence_system_scan": { "type": "boolean" }, "description": { "type": "string" }, "filters": { "$ref": "#/components/schemas/ModelScanFilter" }, "is_priority": { "type": "boolean" }, @@ -13676,6 +13789,7 @@ "items": { "type": "string" }, "nullable": true }, + "deepfence_system_scan": { "type": "boolean" }, "filters": { "$ref": "#/components/schemas/ModelScanFilter" }, "is_priority": { "type": "boolean" }, "node_ids": { @@ -13724,7 +13838,11 @@ "secret_latest_scan_id", "malwares_count", "malware_scan_status", - "malware_latest_scan_id" + "malware_latest_scan_id", + "kubernetes_cluster_name", + "kubernetes_cluster_id", + "kubernetes_namespace", + "is_deepfence_system" ], "type": "object", "properties": { @@ -13746,6 +13864,10 @@ }, "host_name": { "type": "string" }, "image": { "$ref": "#/components/schemas/ModelContainerImage" }, + "is_deepfence_system": { "type": "boolean" }, + "kubernetes_cluster_id": { "type": "string" }, + "kubernetes_cluster_name": { "type": "string" }, + "kubernetes_namespace": { "type": "string" }, "malware_latest_scan_id": { "type": "string" }, "malware_scan_status": { "type": "string" }, "malwares_count": { "type": "integer" }, @@ -13788,7 +13910,8 @@ "malwares_count", "malware_scan_status", "malware_latest_scan_id", - "containers" + "containers", + "is_deepfence_system" ], "type": "object", "properties": { @@ -13809,6 +13932,7 @@ }, "docker_image_virtual_size": { "type": "string" }, "image_node_id": { "type": "string" }, + "is_deepfence_system": { "type": "boolean" }, "malware_latest_scan_id": { "type": "string" }, "malware_scan_status": { "type": "string" }, "malwares_count": { "type": "integer" }, @@ -13891,6 +14015,7 @@ "from_timestamp": { "type": "integer" }, "report_id": { "type": "string" }, "status": { "type": "string" }, + "status_message": { "type": "string" }, "storage_path": { "type": "string" }, "to_timestamp": { "type": "integer" }, "type": { "type": "string" }, @@ -14496,6 +14621,7 @@ "required": ["node_ids", "filters"], "type": "object", "properties": { + "deepfence_system_scan": { "type": "boolean" }, "filters": { "$ref": "#/components/schemas/ModelScanFilter" }, "is_priority": { "type": "boolean" }, "node_ids": { @@ -14582,7 +14708,8 @@ "kubernetes_created", "malware_scan_status", "secret_scan_status", - "vulnerability_scan_status" + "vulnerability_scan_status", + "is_deepfence_system" ], "type": "object", "properties": { @@ -14592,6 +14719,7 @@ "nullable": true }, "host_name": { "type": "string" }, + "is_deepfence_system": { "type": "boolean" }, "kubernetes_cluster_id": { "type": "string" }, "kubernetes_cluster_name": { "type": "string" }, "kubernetes_created": { "type": "string" }, @@ -15206,6 +15334,7 @@ "required": ["node_ids", "filters"], "type": "object", "properties": { + "deepfence_system_scan": { "type": "boolean" }, "filters": { "$ref": "#/components/schemas/ModelScanFilter" }, "is_priority": { "type": "boolean" }, "node_ids": { @@ -15550,6 +15679,7 @@ "required": ["node_ids", "filters", "scan_config"], "type": "object", "properties": { + "deepfence_system_scan": { "type": "boolean" }, "filters": { "$ref": "#/components/schemas/ModelScanFilter" }, "is_priority": { "type": "boolean" }, "node_ids": { @@ -15634,6 +15764,7 @@ "interface_ips": { "type": "array", "items": { "type": "string" } }, "interface_names": { "type": "array", "items": { "type": "string" } }, "is_console_vm": { "type": "boolean" }, + "is_deepfence_system": { "type": "boolean" }, "kernel_id": { "type": "string" }, "kernel_version": { "type": "string" }, "kubernetes_cluster_id": { "type": "string" }, diff --git a/deepfence_frontend/apps/dashboard/src/api/api.ts b/deepfence_frontend/apps/dashboard/src/api/api.ts index feed865686..69e17f076e 100644 --- a/deepfence_frontend/apps/dashboard/src/api/api.ts +++ b/deepfence_frontend/apps/dashboard/src/api/api.ts @@ -415,5 +415,8 @@ export function getScanResultCompletionApiClient() { scanCompleteionApi.completeComplianceInfo.bind(scanCompleteionApi), completeCloudCompliance: scanCompleteionApi.completeCloudCompliance.bind(scanCompleteionApi), + completePodInfo: scanCompleteionApi.completePodInfo.bind(scanCompleteionApi), + completeContainerInfo: + scanCompleteionApi.completeContainerInfo.bind(scanCompleteionApi), }; } diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/apis/CompletionApi.ts b/deepfence_frontend/apps/dashboard/src/api/generated/apis/CompletionApi.ts index 2f1c356cb0..e9ac7ef152 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/apis/CompletionApi.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/apis/CompletionApi.ts @@ -39,10 +39,18 @@ export interface CompleteComplianceInfoRequest { completionCompletionNodeFieldReq?: CompletionCompletionNodeFieldReq; } +export interface CompleteContainerInfoRequest { + completionCompletionNodeFieldReq?: CompletionCompletionNodeFieldReq; +} + export interface CompleteHostInfoRequest { completionCompletionNodeFieldReq?: CompletionCompletionNodeFieldReq; } +export interface CompletePodInfoRequest { + completionCompletionNodeFieldReq?: CompletionCompletionNodeFieldReq; +} + export interface CompleteProcessInfoRequest { completionCompletionNodeFieldReq?: CompletionCompletionNodeFieldReq; } @@ -90,6 +98,22 @@ export interface CompletionApiInterface { */ completeComplianceInfo(requestParameters: CompleteComplianceInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; + /** + * Complete Container info + * @summary Get Completion for Container fields + * @param {CompletionCompletionNodeFieldReq} [completionCompletionNodeFieldReq] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CompletionApiInterface + */ + completeContainerInfoRaw(requestParameters: CompleteContainerInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; + + /** + * Complete Container info + * Get Completion for Container fields + */ + completeContainerInfo(requestParameters: CompleteContainerInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; + /** * Complete host info * @summary Get Completion for host fields @@ -106,6 +130,22 @@ export interface CompletionApiInterface { */ completeHostInfo(requestParameters: CompleteHostInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; + /** + * Complete Pod info + * @summary Get Completion for Pod fields + * @param {CompletionCompletionNodeFieldReq} [completionCompletionNodeFieldReq] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CompletionApiInterface + */ + completePodInfoRaw(requestParameters: CompletePodInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; + + /** + * Complete Pod info + * Get Completion for Pod fields + */ + completePodInfo(requestParameters: CompletePodInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; + /** * Complete process info * @summary Get Completion for process fields @@ -223,6 +263,45 @@ export class CompletionApi extends runtime.BaseAPI implements CompletionApiInter return await response.value(); } + /** + * Complete Container info + * Get Completion for Container fields + */ + async completeContainerInfoRaw(requestParameters: CompleteContainerInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("bearer_token", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/deepfence/complete/container`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CompletionCompletionNodeFieldReqToJSON(requestParameters.completionCompletionNodeFieldReq), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CompletionCompletionNodeFieldResFromJSON(jsonValue)); + } + + /** + * Complete Container info + * Get Completion for Container fields + */ + async completeContainerInfo(requestParameters: CompleteContainerInfoRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.completeContainerInfoRaw(requestParameters, initOverrides); + return await response.value(); + } + /** * Complete host info * Get Completion for host fields @@ -262,6 +341,45 @@ export class CompletionApi extends runtime.BaseAPI implements CompletionApiInter return await response.value(); } + /** + * Complete Pod info + * Get Completion for Pod fields + */ + async completePodInfoRaw(requestParameters: CompletePodInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("bearer_token", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/deepfence/complete/pod`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CompletionCompletionNodeFieldReqToJSON(requestParameters.completionCompletionNodeFieldReq), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CompletionCompletionNodeFieldResFromJSON(jsonValue)); + } + + /** + * Complete Pod info + * Get Completion for Pod fields + */ + async completePodInfo(requestParameters: CompletePodInfoRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.completePodInfoRaw(requestParameters, initOverrides); + return await response.value(); + } + /** * Complete process info * Get Completion for process fields diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelAddScheduledTaskRequest.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelAddScheduledTaskRequest.ts index 37b67eb73d..53dc5634d0 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelAddScheduledTaskRequest.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelAddScheduledTaskRequest.ts @@ -56,6 +56,12 @@ export interface ModelAddScheduledTaskRequest { * @memberof ModelAddScheduledTaskRequest */ cron_expr?: string; + /** + * + * @type {boolean} + * @memberof ModelAddScheduledTaskRequest + */ + deepfence_system_scan?: boolean; /** * * @type {string} @@ -129,6 +135,7 @@ export function ModelAddScheduledTaskRequestFromJSONTyped(json: any, ignoreDiscr 'action': json['action'], 'benchmark_types': json['benchmark_types'], 'cron_expr': !exists(json, 'cron_expr') ? undefined : json['cron_expr'], + 'deepfence_system_scan': !exists(json, 'deepfence_system_scan') ? undefined : json['deepfence_system_scan'], 'description': !exists(json, 'description') ? undefined : json['description'], 'filters': ModelScanFilterFromJSON(json['filters']), 'is_priority': !exists(json, 'is_priority') ? undefined : json['is_priority'], @@ -149,6 +156,7 @@ export function ModelAddScheduledTaskRequestToJSON(value?: ModelAddScheduledTask 'action': value.action, 'benchmark_types': value.benchmark_types, 'cron_expr': value.cron_expr, + 'deepfence_system_scan': value.deepfence_system_scan, 'description': value.description, 'filters': ModelScanFilterToJSON(value.filters), 'is_priority': value.is_priority, diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelComplianceScanTriggerReq.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelComplianceScanTriggerReq.ts index f8010f7c96..31d402652b 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelComplianceScanTriggerReq.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelComplianceScanTriggerReq.ts @@ -38,6 +38,12 @@ export interface ModelComplianceScanTriggerReq { * @memberof ModelComplianceScanTriggerReq */ benchmark_types: Array | null; + /** + * + * @type {boolean} + * @memberof ModelComplianceScanTriggerReq + */ + deepfence_system_scan?: boolean; /** * * @type {ModelScanFilter} @@ -81,6 +87,7 @@ export function ModelComplianceScanTriggerReqFromJSONTyped(json: any, ignoreDisc return { 'benchmark_types': json['benchmark_types'], + 'deepfence_system_scan': !exists(json, 'deepfence_system_scan') ? undefined : json['deepfence_system_scan'], 'filters': ModelScanFilterFromJSON(json['filters']), 'is_priority': !exists(json, 'is_priority') ? undefined : json['is_priority'], 'node_ids': (json['node_ids'] === null ? null : (json['node_ids'] as Array).map(ModelNodeIdentifierFromJSON)), @@ -97,6 +104,7 @@ export function ModelComplianceScanTriggerReqToJSON(value?: ModelComplianceScanT return { 'benchmark_types': value.benchmark_types, + 'deepfence_system_scan': value.deepfence_system_scan, 'filters': ModelScanFilterToJSON(value.filters), 'is_priority': value.is_priority, 'node_ids': (value.node_ids === null ? null : (value.node_ids as Array).map(ModelNodeIdentifierToJSON)), diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelContainer.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelContainer.ts index 3c40eab130..8e968f8d5b 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelContainer.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelContainer.ts @@ -116,6 +116,30 @@ export interface ModelContainer { * @memberof ModelContainer */ image: ModelContainerImage; + /** + * + * @type {boolean} + * @memberof ModelContainer + */ + is_deepfence_system: boolean; + /** + * + * @type {string} + * @memberof ModelContainer + */ + kubernetes_cluster_id: string; + /** + * + * @type {string} + * @memberof ModelContainer + */ + kubernetes_cluster_name: string; + /** + * + * @type {string} + * @memberof ModelContainer + */ + kubernetes_namespace: string; /** * * @type {string} @@ -227,6 +251,10 @@ export function instanceOfModelContainer(value: object): boolean { isInstance = isInstance && "docker_labels" in value; isInstance = isInstance && "host_name" in value; isInstance = isInstance && "image" in value; + isInstance = isInstance && "is_deepfence_system" in value; + isInstance = isInstance && "kubernetes_cluster_id" in value; + isInstance = isInstance && "kubernetes_cluster_name" in value; + isInstance = isInstance && "kubernetes_namespace" in value; isInstance = isInstance && "malware_latest_scan_id" in value; isInstance = isInstance && "malware_scan_status" in value; isInstance = isInstance && "malwares_count" in value; @@ -270,6 +298,10 @@ export function ModelContainerFromJSONTyped(json: any, ignoreDiscriminator: bool 'docker_labels': json['docker_labels'], 'host_name': json['host_name'], 'image': ModelContainerImageFromJSON(json['image']), + 'is_deepfence_system': json['is_deepfence_system'], + 'kubernetes_cluster_id': json['kubernetes_cluster_id'], + 'kubernetes_cluster_name': json['kubernetes_cluster_name'], + 'kubernetes_namespace': json['kubernetes_namespace'], 'malware_latest_scan_id': json['malware_latest_scan_id'], 'malware_scan_status': json['malware_scan_status'], 'malwares_count': json['malwares_count'], @@ -311,6 +343,10 @@ export function ModelContainerToJSON(value?: ModelContainer | null): any { 'docker_labels': value.docker_labels, 'host_name': value.host_name, 'image': ModelContainerImageToJSON(value.image), + 'is_deepfence_system': value.is_deepfence_system, + 'kubernetes_cluster_id': value.kubernetes_cluster_id, + 'kubernetes_cluster_name': value.kubernetes_cluster_name, + 'kubernetes_namespace': value.kubernetes_namespace, 'malware_latest_scan_id': value.malware_latest_scan_id, 'malware_scan_status': value.malware_scan_status, 'malwares_count': value.malwares_count, diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelContainerImage.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelContainerImage.ts index e8466d6df4..36d9e5c5ce 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelContainerImage.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelContainerImage.ts @@ -80,6 +80,12 @@ export interface ModelContainerImage { * @memberof ModelContainerImage */ image_node_id: string; + /** + * + * @type {boolean} + * @memberof ModelContainerImage + */ + is_deepfence_system: boolean; /** * * @type {string} @@ -168,6 +174,7 @@ export function instanceOfModelContainerImage(value: object): boolean { isInstance = isInstance && "docker_image_tag_list" in value; isInstance = isInstance && "docker_image_virtual_size" in value; isInstance = isInstance && "image_node_id" in value; + isInstance = isInstance && "is_deepfence_system" in value; isInstance = isInstance && "malware_latest_scan_id" in value; isInstance = isInstance && "malware_scan_status" in value; isInstance = isInstance && "malwares_count" in value; @@ -202,6 +209,7 @@ export function ModelContainerImageFromJSONTyped(json: any, ignoreDiscriminator: 'docker_image_tag_list': json['docker_image_tag_list'], 'docker_image_virtual_size': json['docker_image_virtual_size'], 'image_node_id': json['image_node_id'], + 'is_deepfence_system': json['is_deepfence_system'], 'malware_latest_scan_id': json['malware_latest_scan_id'], 'malware_scan_status': json['malware_scan_status'], 'malwares_count': json['malwares_count'], @@ -235,6 +243,7 @@ export function ModelContainerImageToJSON(value?: ModelContainerImage | null): a 'docker_image_tag_list': value.docker_image_tag_list, 'docker_image_virtual_size': value.docker_image_virtual_size, 'image_node_id': value.image_node_id, + 'is_deepfence_system': value.is_deepfence_system, 'malware_latest_scan_id': value.malware_latest_scan_id, 'malware_scan_status': value.malware_scan_status, 'malwares_count': value.malwares_count, diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelExportReport.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelExportReport.ts index b81caceac6..cdf634b583 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelExportReport.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelExportReport.ts @@ -49,6 +49,12 @@ export interface ModelExportReport { * @memberof ModelExportReport */ status?: string; + /** + * + * @type {string} + * @memberof ModelExportReport + */ + status_message?: string; /** * * @type {string} @@ -105,6 +111,7 @@ export function ModelExportReportFromJSONTyped(json: any, ignoreDiscriminator: b 'from_timestamp': !exists(json, 'from_timestamp') ? undefined : json['from_timestamp'], 'report_id': !exists(json, 'report_id') ? undefined : json['report_id'], 'status': !exists(json, 'status') ? undefined : json['status'], + 'status_message': !exists(json, 'status_message') ? undefined : json['status_message'], 'storage_path': !exists(json, 'storage_path') ? undefined : json['storage_path'], 'to_timestamp': !exists(json, 'to_timestamp') ? undefined : json['to_timestamp'], 'type': !exists(json, 'type') ? undefined : json['type'], @@ -127,6 +134,7 @@ export function ModelExportReportToJSON(value?: ModelExportReport | null): any { 'from_timestamp': value.from_timestamp, 'report_id': value.report_id, 'status': value.status, + 'status_message': value.status_message, 'storage_path': value.storage_path, 'to_timestamp': value.to_timestamp, 'type': value.type, diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelMalwareScanTriggerReq.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelMalwareScanTriggerReq.ts index 92fab9baea..954c3edd05 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelMalwareScanTriggerReq.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelMalwareScanTriggerReq.ts @@ -32,6 +32,12 @@ import { * @interface ModelMalwareScanTriggerReq */ export interface ModelMalwareScanTriggerReq { + /** + * + * @type {boolean} + * @memberof ModelMalwareScanTriggerReq + */ + deepfence_system_scan?: boolean; /** * * @type {ModelScanFilter} @@ -73,6 +79,7 @@ export function ModelMalwareScanTriggerReqFromJSONTyped(json: any, ignoreDiscrim } return { + 'deepfence_system_scan': !exists(json, 'deepfence_system_scan') ? undefined : json['deepfence_system_scan'], 'filters': ModelScanFilterFromJSON(json['filters']), 'is_priority': !exists(json, 'is_priority') ? undefined : json['is_priority'], 'node_ids': (json['node_ids'] === null ? null : (json['node_ids'] as Array).map(ModelNodeIdentifierFromJSON)), @@ -88,6 +95,7 @@ export function ModelMalwareScanTriggerReqToJSON(value?: ModelMalwareScanTrigger } return { + 'deepfence_system_scan': value.deepfence_system_scan, 'filters': ModelScanFilterToJSON(value.filters), 'is_priority': value.is_priority, 'node_ids': (value.node_ids === null ? null : (value.node_ids as Array).map(ModelNodeIdentifierToJSON)), diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelPod.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelPod.ts index 8a5320fdf9..0bfa181309 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelPod.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelPod.ts @@ -44,6 +44,12 @@ export interface ModelPod { * @memberof ModelPod */ host_name: string; + /** + * + * @type {boolean} + * @memberof ModelPod + */ + is_deepfence_system: boolean; /** * * @type {string} @@ -143,6 +149,7 @@ export function instanceOfModelPod(value: object): boolean { let isInstance = true; isInstance = isInstance && "containers" in value; isInstance = isInstance && "host_name" in value; + isInstance = isInstance && "is_deepfence_system" in value; isInstance = isInstance && "kubernetes_cluster_id" in value; isInstance = isInstance && "kubernetes_cluster_name" in value; isInstance = isInstance && "kubernetes_created" in value; @@ -174,6 +181,7 @@ export function ModelPodFromJSONTyped(json: any, ignoreDiscriminator: boolean): 'containers': (json['containers'] === null ? null : (json['containers'] as Array).map(ModelContainerFromJSON)), 'host_name': json['host_name'], + 'is_deepfence_system': json['is_deepfence_system'], 'kubernetes_cluster_id': json['kubernetes_cluster_id'], 'kubernetes_cluster_name': json['kubernetes_cluster_name'], 'kubernetes_created': json['kubernetes_created'], @@ -203,6 +211,7 @@ export function ModelPodToJSON(value?: ModelPod | null): any { 'containers': (value.containers === null ? null : (value.containers as Array).map(ModelContainerToJSON)), 'host_name': value.host_name, + 'is_deepfence_system': value.is_deepfence_system, 'kubernetes_cluster_id': value.kubernetes_cluster_id, 'kubernetes_cluster_name': value.kubernetes_cluster_name, 'kubernetes_created': value.kubernetes_created, diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelSecretScanTriggerReq.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelSecretScanTriggerReq.ts index 2839bd2d21..bc82d43564 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelSecretScanTriggerReq.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelSecretScanTriggerReq.ts @@ -32,6 +32,12 @@ import { * @interface ModelSecretScanTriggerReq */ export interface ModelSecretScanTriggerReq { + /** + * + * @type {boolean} + * @memberof ModelSecretScanTriggerReq + */ + deepfence_system_scan?: boolean; /** * * @type {ModelScanFilter} @@ -73,6 +79,7 @@ export function ModelSecretScanTriggerReqFromJSONTyped(json: any, ignoreDiscrimi } return { + 'deepfence_system_scan': !exists(json, 'deepfence_system_scan') ? undefined : json['deepfence_system_scan'], 'filters': ModelScanFilterFromJSON(json['filters']), 'is_priority': !exists(json, 'is_priority') ? undefined : json['is_priority'], 'node_ids': (json['node_ids'] === null ? null : (json['node_ids'] as Array).map(ModelNodeIdentifierFromJSON)), @@ -88,6 +95,7 @@ export function ModelSecretScanTriggerReqToJSON(value?: ModelSecretScanTriggerRe } return { + 'deepfence_system_scan': value.deepfence_system_scan, 'filters': ModelScanFilterToJSON(value.filters), 'is_priority': value.is_priority, 'node_ids': (value.node_ids === null ? null : (value.node_ids as Array).map(ModelNodeIdentifierToJSON)), diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelVulnerabilityScanTriggerReq.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelVulnerabilityScanTriggerReq.ts index 5392082ed5..2bf78021d6 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelVulnerabilityScanTriggerReq.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelVulnerabilityScanTriggerReq.ts @@ -38,6 +38,12 @@ import { * @interface ModelVulnerabilityScanTriggerReq */ export interface ModelVulnerabilityScanTriggerReq { + /** + * + * @type {boolean} + * @memberof ModelVulnerabilityScanTriggerReq + */ + deepfence_system_scan?: boolean; /** * * @type {ModelScanFilter} @@ -86,6 +92,7 @@ export function ModelVulnerabilityScanTriggerReqFromJSONTyped(json: any, ignoreD } return { + 'deepfence_system_scan': !exists(json, 'deepfence_system_scan') ? undefined : json['deepfence_system_scan'], 'filters': ModelScanFilterFromJSON(json['filters']), 'is_priority': !exists(json, 'is_priority') ? undefined : json['is_priority'], 'node_ids': (json['node_ids'] === null ? null : (json['node_ids'] as Array).map(ModelNodeIdentifierFromJSON)), @@ -102,6 +109,7 @@ export function ModelVulnerabilityScanTriggerReqToJSON(value?: ModelVulnerabilit } return { + 'deepfence_system_scan': value.deepfence_system_scan, 'filters': ModelScanFilterToJSON(value.filters), 'is_priority': value.is_priority, 'node_ids': (value.node_ids === null ? null : (value.node_ids as Array).map(ModelNodeIdentifierToJSON)), diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ReportMetadata.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ReportMetadata.ts index 498f00bad6..ecf41bf294 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ReportMetadata.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ReportMetadata.ts @@ -229,6 +229,12 @@ export interface ReportMetadata { * @memberof ReportMetadata */ is_console_vm?: boolean; + /** + * + * @type {boolean} + * @memberof ReportMetadata + */ + is_deepfence_system?: boolean; /** * * @type {string} @@ -519,6 +525,7 @@ export function ReportMetadataFromJSONTyped(json: any, ignoreDiscriminator: bool 'interface_ips': !exists(json, 'interface_ips') ? undefined : json['interface_ips'], 'interface_names': !exists(json, 'interface_names') ? undefined : json['interface_names'], 'is_console_vm': !exists(json, 'is_console_vm') ? undefined : json['is_console_vm'], + 'is_deepfence_system': !exists(json, 'is_deepfence_system') ? undefined : json['is_deepfence_system'], 'kernel_id': !exists(json, 'kernel_id') ? undefined : json['kernel_id'], 'kernel_version': !exists(json, 'kernel_version') ? undefined : json['kernel_version'], 'kubernetes_cluster_id': !exists(json, 'kubernetes_cluster_id') ? undefined : json['kubernetes_cluster_id'], @@ -605,6 +612,7 @@ export function ReportMetadataToJSON(value?: ReportMetadata | null): any { 'interface_ips': value.interface_ips, 'interface_names': value.interface_names, 'is_console_vm': value.is_console_vm, + 'is_deepfence_system': value.is_deepfence_system, 'kernel_id': value.kernel_id, 'kernel_version': value.kernel_version, 'kubernetes_cluster_id': value.kubernetes_cluster_id, diff --git a/deepfence_frontend/apps/dashboard/src/components/forms/SearchableNamespaceList.tsx b/deepfence_frontend/apps/dashboard/src/components/forms/SearchableNamespaceList.tsx index 55fef522ef..630200d54d 100644 --- a/deepfence_frontend/apps/dashboard/src/components/forms/SearchableNamespaceList.tsx +++ b/deepfence_frontend/apps/dashboard/src/components/forms/SearchableNamespaceList.tsx @@ -6,11 +6,11 @@ import { CircleSpinner, Combobox, ComboboxOption } from 'ui-components'; import { queries } from '@/queries'; export type SearchableNamespaceListProps = { + nodeType: 'pod' | 'container'; onChange?: (value: string[]) => void; onClearAll?: () => void; defaultSelectedNamespaces?: string[]; valueKey?: 'nodeId' | 'namespace'; - active?: boolean; triggerVariant?: 'select' | 'button'; helperText?: string; color?: 'error' | 'default'; @@ -18,10 +18,10 @@ export type SearchableNamespaceListProps = { const PAGE_SIZE = 15; const SearchableNamespace = ({ + nodeType, onChange, onClearAll, defaultSelectedNamespaces: defaultSelectedNamespaces, - active, triggerVariant, helperText, color, @@ -40,16 +40,29 @@ const SearchableNamespace = ({ setSelectedNamespaces(defaultSelectedNamespaces ?? []); }, [defaultSelectedNamespaces]); - const { data, isFetchingNextPage, hasNextPage, fetchNextPage } = - useSuspenseInfiniteQuery({ - ...queries.search.namespaces({ + const { data, isFetchingNextPage, hasNextPage, fetchNextPage } = (function () { + if (nodeType === 'pod') { + return useSuspenseInfiniteQuery({ + ...queries.common.searchPodsInfo({ + size: PAGE_SIZE, + searchText, + fieldName: 'kubernetes_namespace', + }), + keepPreviousData: true, + getNextPageParam: (lastPage, allPages) => { + return allPages.length * PAGE_SIZE; + }, + getPreviousPageParam: (firstPage, allPages) => { + if (!allPages.length) return 0; + return (allPages.length - 1) * PAGE_SIZE; + }, + }); + } + return useSuspenseInfiniteQuery({ + ...queries.common.searchContainersInfo({ size: PAGE_SIZE, searchText, - active, - order: { - sortBy: 'kubernetes_namespace', - descending: false, - }, + fieldName: 'kubernetes_namespace', }), keepPreviousData: true, getNextPageParam: (lastPage, allPages) => { @@ -60,6 +73,7 @@ const SearchableNamespace = ({ return (allPages.length - 1) * PAGE_SIZE; }, }); + })(); const searchNamespace = debounce((query: string) => { setSearchText(query); @@ -71,13 +85,6 @@ const SearchableNamespace = ({ return ( <> - : undefined @@ -106,15 +113,12 @@ const SearchableNamespace = ({ > {data?.pages .flatMap((page) => { - return page.namespaces; + return page.data; }) - .map((namespace, index) => { + .map((item, index) => { return ( - - {namespace.namespace} + + {item} ); })} diff --git a/deepfence_frontend/apps/dashboard/src/features/topology/data-components/tables/ContainersTable.tsx b/deepfence_frontend/apps/dashboard/src/features/topology/data-components/tables/ContainersTable.tsx index cb9688c0b1..c5edd637d4 100644 --- a/deepfence_frontend/apps/dashboard/src/features/topology/data-components/tables/ContainersTable.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/topology/data-components/tables/ContainersTable.tsx @@ -27,6 +27,7 @@ import { FilterBadge } from '@/components/filters/FilterBadge'; import { SearchableClusterList } from '@/components/forms/SearchableClusterList'; import { SearchableContainerList } from '@/components/forms/SearchableContainerList'; import { SearchableHostList } from '@/components/forms/SearchableHostList'; +import { SearchableNamespaceList } from '@/components/forms/SearchableNamespaceList'; import { CaretDown } from '@/components/icons/common/CaretDown'; import { FilterIcon } from '@/components/icons/common/Filter'; import { TimesIcon } from '@/components/icons/common/Times'; @@ -422,6 +423,27 @@ function Filters() { }); }} /> + { + setSearchParams((prev) => { + prev.delete('namespaces'); + prev.delete('page'); + return prev; + }); + }} + onChange={(value) => { + setSearchParams((prev) => { + prev.delete('namespaces'); + value.forEach((pod) => { + prev.append('namespaces', pod); + }); + prev.delete('page'); + return prev; + }); + }} + /> {appliedFilterCount > 0 ? (
@@ -501,6 +523,7 @@ function useSearchContainersWithPagination() { order: getOrderFromSearchParams(searchParams), clusterIds: searchParams.getAll('clusters'), containers: searchParams.getAll('containers'), + kubernetesNamespace: searchParams.getAll('namespaces'), }), keepPreviousData: true, }); diff --git a/deepfence_frontend/apps/dashboard/src/features/topology/data-components/tables/PodsTable.tsx b/deepfence_frontend/apps/dashboard/src/features/topology/data-components/tables/PodsTable.tsx index b12f4a78ab..48de720004 100644 --- a/deepfence_frontend/apps/dashboard/src/features/topology/data-components/tables/PodsTable.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/topology/data-components/tables/PodsTable.tsx @@ -257,19 +257,20 @@ function Filters() { }} /> { setSearchParams((prev) => { - prev.delete('pods'); + prev.delete('namespaces'); prev.delete('page'); return prev; }); }} onChange={(value) => { setSearchParams((prev) => { - prev.delete('pods'); + prev.delete('namespaces'); value.forEach((pod) => { - prev.append('pods', pod); + prev.append('namespaces', pod); }); prev.delete('page'); return prev; @@ -347,6 +348,7 @@ function useSearchPodsWithPagination() { clusterNames: searchParams.getAll('clusters'), pods: searchParams.getAll('pods'), kubernetesStatus: searchParams.get('kubernetesStatus') ?? undefined, + kubernetesNamespace: searchParams.getAll('namespaces'), }), keepPreviousData: true, }); diff --git a/deepfence_frontend/apps/dashboard/src/queries/common.ts b/deepfence_frontend/apps/dashboard/src/queries/common.ts index 4c7f45d429..2890d16213 100644 --- a/deepfence_frontend/apps/dashboard/src/queries/common.ts +++ b/deepfence_frontend/apps/dashboard/src/queries/common.ts @@ -141,6 +141,84 @@ export const commonQueries = createQueryKeys('common', { }, }; }, + searchPodsInfo: (filters: { fieldName: string; searchText: string; size: number }) => { + return { + queryKey: [{ filters }], + queryFn: async ({ pageParam = 0 }) => { + const { fieldName, searchText, size } = filters; + + const scanResultsReq: CompletionCompletionNodeFieldReq = { + completion: searchText, + field_name: fieldName, + window: { + offset: pageParam, + size, + }, + }; + + const api = apiWrapper({ + fn: getScanResultCompletionApiClient().completePodInfo, + }); + const response = await api({ + completionCompletionNodeFieldReq: scanResultsReq, + }); + + if (!response.ok) { + throw response.error; + } + + if (response.value === null) { + // TODO: handle this case with 404 status maybe + throw new Error('Error getting completion pods info'); + } + + return { + data: response.value.possible_values?.slice(0, size) || [], + }; + }, + }; + }, + searchContainersInfo: (filters: { + fieldName: string; + searchText: string; + size: number; + }) => { + return { + queryKey: [{ filters }], + queryFn: async ({ pageParam = 0 }) => { + const { fieldName, searchText, size } = filters; + + const scanResultsReq: CompletionCompletionNodeFieldReq = { + completion: searchText, + field_name: fieldName, + window: { + offset: pageParam, + size, + }, + }; + + const api = apiWrapper({ + fn: getScanResultCompletionApiClient().completeContainerInfo, + }); + const response = await api({ + completionCompletionNodeFieldReq: scanResultsReq, + }); + + if (!response.ok) { + throw response.error; + } + + if (response.value === null) { + // TODO: handle this case with 404 status maybe + throw new Error('Error getting completion containers info'); + } + + return { + data: response.value.possible_values?.slice(0, size) || [], + }; + }, + }; + }, searchPostureCompletionFilters: (filters: { scanId: string; fieldName: string; diff --git a/deepfence_frontend/apps/dashboard/src/queries/search.tsx b/deepfence_frontend/apps/dashboard/src/queries/search.tsx index 7a7c4f137c..c3cdb0a818 100644 --- a/deepfence_frontend/apps/dashboard/src/queries/search.tsx +++ b/deepfence_frontend/apps/dashboard/src/queries/search.tsx @@ -1111,6 +1111,7 @@ export const searchQueries = createQueryKeys('search', { }; clusterIds: string[]; containers: string[]; + kubernetesNamespace: string[]; }) => { return { queryKey: [filters], @@ -1125,6 +1126,7 @@ export const searchQueries = createQueryKeys('search', { order, clusterIds, containers, + kubernetesNamespace, } = filters; const searchSearchNodeReq: SearchSearchNodeReq = { node_filter: { @@ -1134,6 +1136,9 @@ export const searchQueries = createQueryKeys('search', { filter_in: { active: [true], ...(hosts.length ? { host_name: hosts } : {}), + ...(kubernetesNamespace.length + ? { kubernetes_namespace: kubernetesNamespace } + : {}), }, }, match_filter: { @@ -1281,6 +1286,7 @@ export const searchQueries = createQueryKeys('search', { hosts: string[]; clusterNames: string[]; pods: string[]; + kubernetesNamespace: string[]; kubernetesStatus?: string; order?: { sortBy: string; @@ -1290,8 +1296,16 @@ export const searchQueries = createQueryKeys('search', { return { queryKey: [filters], queryFn: async () => { - const { page, pageSize, hosts, pods, order, clusterNames, kubernetesStatus } = - filters; + const { + page, + pageSize, + hosts, + pods, + order, + clusterNames, + kubernetesStatus, + kubernetesNamespace, + } = filters; const searchSearchNodeReq: SearchSearchNodeReq = { node_filter: { filters: { @@ -1304,6 +1318,9 @@ export const searchQueries = createQueryKeys('search', { ? { kubernetes_cluster_name: clusterNames } : {}), ...(pods.length ? { pod_name: pods } : {}), + ...(kubernetesNamespace.length + ? { kubernetes_namespace: kubernetesNamespace } + : {}), }, }, match_filter: {