diff --git a/deepfence_frontend/apps/dashboard/api-spec.json b/deepfence_frontend/apps/dashboard/api-spec.json index 6a96bf88ee..c4b50c85ad 100644 --- a/deepfence_frontend/apps/dashboard/api-spec.json +++ b/deepfence_frontend/apps/dashboard/api-spec.json @@ -1133,6 +1133,106 @@ "security": [{ "bearer_token": [] }] } }, + "/deepfence/diagnosis/cloud-scanner-logs": { + "post": { + "tags": ["Diagnosis"], + "summary": "Generate Cloud Scanner Diagnostic Logs", + "description": "Generate Cloud Scanner Diagnostic Logs", + "operationId": "generateCloudScannerDiagnosticLogs", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DiagnosisGenerateCloudScannerDiagnosticLogsRequest" + } + } + } + }, + "responses": { + "202": { "description": "Accepted" }, + "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/diagnosis/cloud-scanner-logs/status/{node_id}": { + "put": { + "tags": ["Diagnosis"], + "summary": "Update Cloud Scanner Diagnostic Logs Status", + "description": "Update cloud scanner diagnostic logs status", + "operationId": "updateCloudScannerDiagnosticLogsStatus", + "parameters": [ + { + "name": "node_id", + "in": "path", + "required": true, + "schema": { "type": "string" } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/DiagnosisDiagnosticLogsStatus" } + } + } + }, + "responses": { + "204": { "description": "No Content" }, + "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/diagnosis/console-logs": { "post": { "tags": ["Diagnosis"], @@ -10490,6 +10590,18 @@ "tail": { "type": "integer" } } }, + "DiagnosisGenerateCloudScannerDiagnosticLogsRequest": { + "required": ["node_ids", "tail"], + "type": "object", + "properties": { + "node_ids": { + "type": "array", + "items": { "$ref": "#/components/schemas/DiagnosisNodeIdentifier" }, + "nullable": true + }, + "tail": { "type": "integer" } + } + }, "DiagnosisGenerateConsoleDiagnosticLogsRequest": { "required": ["tail"], "type": "object", @@ -10503,6 +10615,11 @@ "items": { "$ref": "#/components/schemas/DiagnosisDiagnosticLogsLink" }, "nullable": true }, + "cloud_scanner_logs": { + "type": "array", + "items": { "$ref": "#/components/schemas/DiagnosisDiagnosticLogsLink" }, + "nullable": true + }, "console_logs": { "type": "array", "items": { "$ref": "#/components/schemas/DiagnosisDiagnosticLogsLink" }, @@ -10515,7 +10632,7 @@ "type": "object", "properties": { "node_id": { "type": "string" }, - "node_type": { "enum": ["host", "cluster"], "type": "string" } + "node_type": { "enum": ["host", "cluster", "cloud_account"], "type": "string" } } }, "FormDataModelRegistryGCRAddReq": { @@ -11394,6 +11511,7 @@ "items": { "$ref": "#/components/schemas/ModelCloudNodeCloudtrailTrail" }, "nullable": true }, + "log_action": { "$ref": "#/components/schemas/ControlsAction" }, "refresh": { "type": "string" }, "scans": { "type": "object", @@ -12789,6 +12907,7 @@ "properties": { "mask_across_hosts_and_images": { "type": "boolean" }, "mask_in_this_host_or_image_tags": { "type": "boolean" }, + "mask_in_this_image_tag": { "type": "boolean" }, "result_ids": { "type": "array", "items": { "type": "string" }, diff --git a/deepfence_frontend/apps/dashboard/src/api/api.ts b/deepfence_frontend/apps/dashboard/src/api/api.ts index dbd96bc7e9..40ed550027 100644 --- a/deepfence_frontend/apps/dashboard/src/api/api.ts +++ b/deepfence_frontend/apps/dashboard/src/api/api.ts @@ -288,6 +288,8 @@ export function getDiagnosisApiClient() { return { generateAgentDiagnosticLogs: diagnosisApi.generateAgentDiagnosticLogs.bind(diagnosisApi), + generateCloudScannerDiagnosticLogs: + diagnosisApi.generateCloudScannerDiagnosticLogs.bind(diagnosisApi), generateConsoleDiagnosticLogs: diagnosisApi.generateConsoleDiagnosticLogs.bind(diagnosisApi), getDiagnosticLogs: diagnosisApi.getDiagnosticLogs.bind(diagnosisApi), diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/.openapi-generator/FILES b/deepfence_frontend/apps/dashboard/src/api/generated/.openapi-generator/FILES index 75e1d76335..dbb43244e5 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/.openapi-generator/FILES +++ b/deepfence_frontend/apps/dashboard/src/api/generated/.openapi-generator/FILES @@ -38,6 +38,7 @@ models/DiagnosisDiagnosticLogsLink.ts models/DiagnosisDiagnosticLogsStatus.ts models/DiagnosisDiagnosticNotification.ts models/DiagnosisGenerateAgentDiagnosticLogsRequest.ts +models/DiagnosisGenerateCloudScannerDiagnosticLogsRequest.ts models/DiagnosisGenerateConsoleDiagnosticLogsRequest.ts models/DiagnosisGetDiagnosticLogsResponse.ts models/DiagnosisNodeIdentifier.ts diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/apis/DiagnosisApi.ts b/deepfence_frontend/apps/dashboard/src/api/generated/apis/DiagnosisApi.ts index 797ef3fe72..860ab4c07e 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/apis/DiagnosisApi.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/apis/DiagnosisApi.ts @@ -20,6 +20,7 @@ import type { DiagnosisDiagnosticLogsStatus, DiagnosisDiagnosticNotification, DiagnosisGenerateAgentDiagnosticLogsRequest, + DiagnosisGenerateCloudScannerDiagnosticLogsRequest, DiagnosisGenerateConsoleDiagnosticLogsRequest, DiagnosisGetDiagnosticLogsResponse, } from '../models'; @@ -34,6 +35,8 @@ import { DiagnosisDiagnosticNotificationToJSON, DiagnosisGenerateAgentDiagnosticLogsRequestFromJSON, DiagnosisGenerateAgentDiagnosticLogsRequestToJSON, + DiagnosisGenerateCloudScannerDiagnosticLogsRequestFromJSON, + DiagnosisGenerateCloudScannerDiagnosticLogsRequestToJSON, DiagnosisGenerateConsoleDiagnosticLogsRequestFromJSON, DiagnosisGenerateConsoleDiagnosticLogsRequestToJSON, DiagnosisGetDiagnosticLogsResponseFromJSON, @@ -44,6 +47,10 @@ export interface GenerateAgentDiagnosticLogsRequest { diagnosisGenerateAgentDiagnosticLogsRequest?: DiagnosisGenerateAgentDiagnosticLogsRequest; } +export interface GenerateCloudScannerDiagnosticLogsRequest { + diagnosisGenerateCloudScannerDiagnosticLogsRequest?: DiagnosisGenerateCloudScannerDiagnosticLogsRequest; +} + export interface GenerateConsoleDiagnosticLogsRequest { diagnosisGenerateConsoleDiagnosticLogsRequest?: DiagnosisGenerateConsoleDiagnosticLogsRequest; } @@ -53,6 +60,11 @@ export interface UpdateAgentDiagnosticLogsStatusRequest { diagnosisDiagnosticLogsStatus?: DiagnosisDiagnosticLogsStatus; } +export interface UpdateCloudScannerDiagnosticLogsStatusRequest { + nodeId: string; + diagnosisDiagnosticLogsStatus?: DiagnosisDiagnosticLogsStatus; +} + /** * DiagnosisApi - interface * @@ -91,6 +103,22 @@ export interface DiagnosisApiInterface { */ generateAgentDiagnosticLogs(requestParameters: GenerateAgentDiagnosticLogsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; + /** + * Generate Cloud Scanner Diagnostic Logs + * @summary Generate Cloud Scanner Diagnostic Logs + * @param {DiagnosisGenerateCloudScannerDiagnosticLogsRequest} [diagnosisGenerateCloudScannerDiagnosticLogsRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DiagnosisApiInterface + */ + generateCloudScannerDiagnosticLogsRaw(requestParameters: GenerateCloudScannerDiagnosticLogsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; + + /** + * Generate Cloud Scanner Diagnostic Logs + * Generate Cloud Scanner Diagnostic Logs + */ + generateCloudScannerDiagnosticLogs(requestParameters: GenerateCloudScannerDiagnosticLogsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; + /** * Generate Console Diagnostic Logs * @summary Generate Console Diagnostic Logs @@ -139,6 +167,23 @@ export interface DiagnosisApiInterface { */ updateAgentDiagnosticLogsStatus(requestParameters: UpdateAgentDiagnosticLogsStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; + /** + * Update cloud scanner diagnostic logs status + * @summary Update Cloud Scanner Diagnostic Logs Status + * @param {string} nodeId + * @param {DiagnosisDiagnosticLogsStatus} [diagnosisDiagnosticLogsStatus] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DiagnosisApiInterface + */ + updateCloudScannerDiagnosticLogsStatusRaw(requestParameters: UpdateCloudScannerDiagnosticLogsStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; + + /** + * Update cloud scanner diagnostic logs status + * Update Cloud Scanner Diagnostic Logs Status + */ + updateCloudScannerDiagnosticLogsStatus(requestParameters: UpdateCloudScannerDiagnosticLogsStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; + } /** @@ -220,6 +265,44 @@ export class DiagnosisApi extends runtime.BaseAPI implements DiagnosisApiInterfa await this.generateAgentDiagnosticLogsRaw(requestParameters, initOverrides); } + /** + * Generate Cloud Scanner Diagnostic Logs + * Generate Cloud Scanner Diagnostic Logs + */ + async generateCloudScannerDiagnosticLogsRaw(requestParameters: GenerateCloudScannerDiagnosticLogsRequest, 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/diagnosis/cloud-scanner-logs`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: DiagnosisGenerateCloudScannerDiagnosticLogsRequestToJSON(requestParameters.diagnosisGenerateCloudScannerDiagnosticLogsRequest), + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Generate Cloud Scanner Diagnostic Logs + * Generate Cloud Scanner Diagnostic Logs + */ + async generateCloudScannerDiagnosticLogs(requestParameters: GenerateCloudScannerDiagnosticLogsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.generateCloudScannerDiagnosticLogsRaw(requestParameters, initOverrides); + } + /** * Generate Console Diagnostic Logs * Generate Console Diagnostic Logs @@ -336,4 +419,46 @@ export class DiagnosisApi extends runtime.BaseAPI implements DiagnosisApiInterfa await this.updateAgentDiagnosticLogsStatusRaw(requestParameters, initOverrides); } + /** + * Update cloud scanner diagnostic logs status + * Update Cloud Scanner Diagnostic Logs Status + */ + async updateCloudScannerDiagnosticLogsStatusRaw(requestParameters: UpdateCloudScannerDiagnosticLogsStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.nodeId === null || requestParameters.nodeId === undefined) { + throw new runtime.RequiredError('nodeId','Required parameter requestParameters.nodeId was null or undefined when calling updateCloudScannerDiagnosticLogsStatus.'); + } + + 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/diagnosis/cloud-scanner-logs/status/{node_id}`.replace(`{${"node_id"}}`, encodeURIComponent(String(requestParameters.nodeId))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: DiagnosisDiagnosticLogsStatusToJSON(requestParameters.diagnosisDiagnosticLogsStatus), + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Update cloud scanner diagnostic logs status + * Update Cloud Scanner Diagnostic Logs Status + */ + async updateCloudScannerDiagnosticLogsStatus(requestParameters: UpdateCloudScannerDiagnosticLogsStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.updateCloudScannerDiagnosticLogsStatusRaw(requestParameters, initOverrides); + } + } diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/DiagnosisGenerateCloudScannerDiagnosticLogsRequest.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/DiagnosisGenerateCloudScannerDiagnosticLogsRequest.ts new file mode 100644 index 0000000000..df10a7f4ec --- /dev/null +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/DiagnosisGenerateCloudScannerDiagnosticLogsRequest.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Deepfence ThreatMapper + * Deepfence Runtime API provides programmatic control over Deepfence microservice securing your container, kubernetes and cloud deployments. The API abstracts away underlying infrastructure details like cloud provider, container distros, container orchestrator and type of deployment. This is one uniform API to manage and control security alerts, policies and response to alerts for microservices running anywhere i.e. managed pure greenfield container deployments or a mix of containers, VMs and serverless paradigms like AWS Fargate. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: community@deepfence.io + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { DiagnosisNodeIdentifier } from './DiagnosisNodeIdentifier'; +import { + DiagnosisNodeIdentifierFromJSON, + DiagnosisNodeIdentifierFromJSONTyped, + DiagnosisNodeIdentifierToJSON, +} from './DiagnosisNodeIdentifier'; + +/** + * + * @export + * @interface DiagnosisGenerateCloudScannerDiagnosticLogsRequest + */ +export interface DiagnosisGenerateCloudScannerDiagnosticLogsRequest { + /** + * + * @type {Array} + * @memberof DiagnosisGenerateCloudScannerDiagnosticLogsRequest + */ + node_ids: Array | null; + /** + * + * @type {number} + * @memberof DiagnosisGenerateCloudScannerDiagnosticLogsRequest + */ + tail: number; +} + +/** + * Check if a given object implements the DiagnosisGenerateCloudScannerDiagnosticLogsRequest interface. + */ +export function instanceOfDiagnosisGenerateCloudScannerDiagnosticLogsRequest(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "node_ids" in value; + isInstance = isInstance && "tail" in value; + + return isInstance; +} + +export function DiagnosisGenerateCloudScannerDiagnosticLogsRequestFromJSON(json: any): DiagnosisGenerateCloudScannerDiagnosticLogsRequest { + return DiagnosisGenerateCloudScannerDiagnosticLogsRequestFromJSONTyped(json, false); +} + +export function DiagnosisGenerateCloudScannerDiagnosticLogsRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): DiagnosisGenerateCloudScannerDiagnosticLogsRequest { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'node_ids': (json['node_ids'] === null ? null : (json['node_ids'] as Array).map(DiagnosisNodeIdentifierFromJSON)), + 'tail': json['tail'], + }; +} + +export function DiagnosisGenerateCloudScannerDiagnosticLogsRequestToJSON(value?: DiagnosisGenerateCloudScannerDiagnosticLogsRequest | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'node_ids': (value.node_ids === null ? null : (value.node_ids as Array).map(DiagnosisNodeIdentifierToJSON)), + 'tail': value.tail, + }; +} + diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/DiagnosisGetDiagnosticLogsResponse.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/DiagnosisGetDiagnosticLogsResponse.ts index e2e11803e2..7a847a4bea 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/DiagnosisGetDiagnosticLogsResponse.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/DiagnosisGetDiagnosticLogsResponse.ts @@ -32,6 +32,12 @@ export interface DiagnosisGetDiagnosticLogsResponse { * @memberof DiagnosisGetDiagnosticLogsResponse */ agent_logs?: Array | null; + /** + * + * @type {Array} + * @memberof DiagnosisGetDiagnosticLogsResponse + */ + cloud_scanner_logs?: Array | null; /** * * @type {Array} @@ -60,6 +66,7 @@ export function DiagnosisGetDiagnosticLogsResponseFromJSONTyped(json: any, ignor return { 'agent_logs': !exists(json, 'agent_logs') ? undefined : (json['agent_logs'] === null ? null : (json['agent_logs'] as Array).map(DiagnosisDiagnosticLogsLinkFromJSON)), + 'cloud_scanner_logs': !exists(json, 'cloud_scanner_logs') ? undefined : (json['cloud_scanner_logs'] === null ? null : (json['cloud_scanner_logs'] as Array).map(DiagnosisDiagnosticLogsLinkFromJSON)), 'console_logs': !exists(json, 'console_logs') ? undefined : (json['console_logs'] === null ? null : (json['console_logs'] as Array).map(DiagnosisDiagnosticLogsLinkFromJSON)), }; } @@ -74,6 +81,7 @@ export function DiagnosisGetDiagnosticLogsResponseToJSON(value?: DiagnosisGetDia return { 'agent_logs': value.agent_logs === undefined ? undefined : (value.agent_logs === null ? null : (value.agent_logs as Array).map(DiagnosisDiagnosticLogsLinkToJSON)), + 'cloud_scanner_logs': value.cloud_scanner_logs === undefined ? undefined : (value.cloud_scanner_logs === null ? null : (value.cloud_scanner_logs as Array).map(DiagnosisDiagnosticLogsLinkToJSON)), 'console_logs': value.console_logs === undefined ? undefined : (value.console_logs === null ? null : (value.console_logs as Array).map(DiagnosisDiagnosticLogsLinkToJSON)), }; } diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/DiagnosisNodeIdentifier.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/DiagnosisNodeIdentifier.ts index c7e62f007c..39c55e6031 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/DiagnosisNodeIdentifier.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/DiagnosisNodeIdentifier.ts @@ -39,7 +39,8 @@ export interface DiagnosisNodeIdentifier { */ export const DiagnosisNodeIdentifierNodeTypeEnum = { Host: 'host', - Cluster: 'cluster' + Cluster: 'cluster', + CloudAccount: 'cloud_account' } as const; export type DiagnosisNodeIdentifierNodeTypeEnum = typeof DiagnosisNodeIdentifierNodeTypeEnum[keyof typeof DiagnosisNodeIdentifierNodeTypeEnum]; diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelCloudNodeAccountRegisterRespData.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelCloudNodeAccountRegisterRespData.ts index 53a498c587..203c3626ee 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelCloudNodeAccountRegisterRespData.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelCloudNodeAccountRegisterRespData.ts @@ -13,6 +13,12 @@ */ import { exists, mapValues } from '../runtime'; +import type { ControlsAction } from './ControlsAction'; +import { + ControlsActionFromJSON, + ControlsActionFromJSONTyped, + ControlsActionToJSON, +} from './ControlsAction'; import type { ModelCloudComplianceScanDetails } from './ModelCloudComplianceScanDetails'; import { ModelCloudComplianceScanDetailsFromJSON, @@ -38,6 +44,12 @@ export interface ModelCloudNodeAccountRegisterRespData { * @memberof ModelCloudNodeAccountRegisterRespData */ cloudtrail_trails?: Array | null; + /** + * + * @type {ControlsAction} + * @memberof ModelCloudNodeAccountRegisterRespData + */ + log_action?: ControlsAction; /** * * @type {string} @@ -72,6 +84,7 @@ export function ModelCloudNodeAccountRegisterRespDataFromJSONTyped(json: any, ig return { 'cloudtrail_trails': !exists(json, 'cloudtrail_trails') ? undefined : (json['cloudtrail_trails'] === null ? null : (json['cloudtrail_trails'] as Array).map(ModelCloudNodeCloudtrailTrailFromJSON)), + 'log_action': !exists(json, 'log_action') ? undefined : ControlsActionFromJSON(json['log_action']), 'refresh': !exists(json, 'refresh') ? undefined : json['refresh'], 'scans': !exists(json, 'scans') ? undefined : (json['scans'] === null ? null : mapValues(json['scans'], ModelCloudComplianceScanDetailsFromJSON)), }; @@ -87,6 +100,7 @@ export function ModelCloudNodeAccountRegisterRespDataToJSON(value?: ModelCloudNo return { 'cloudtrail_trails': value.cloudtrail_trails === undefined ? undefined : (value.cloudtrail_trails === null ? null : (value.cloudtrail_trails as Array).map(ModelCloudNodeCloudtrailTrailToJSON)), + 'log_action': ControlsActionToJSON(value.log_action), 'refresh': value.refresh, 'scans': value.scans === undefined ? undefined : (value.scans === null ? null : mapValues(value.scans, ModelCloudComplianceScanDetailsToJSON)), }; diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelScanResultsMaskRequest.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelScanResultsMaskRequest.ts index 2d2e4c1c94..a416b6be97 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelScanResultsMaskRequest.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/ModelScanResultsMaskRequest.ts @@ -31,6 +31,12 @@ export interface ModelScanResultsMaskRequest { * @memberof ModelScanResultsMaskRequest */ mask_in_this_host_or_image_tags?: boolean; + /** + * + * @type {boolean} + * @memberof ModelScanResultsMaskRequest + */ + mask_in_this_image_tag?: boolean; /** * * @type {Array} @@ -89,6 +95,7 @@ export function ModelScanResultsMaskRequestFromJSONTyped(json: any, ignoreDiscri 'mask_across_hosts_and_images': !exists(json, 'mask_across_hosts_and_images') ? undefined : json['mask_across_hosts_and_images'], 'mask_in_this_host_or_image_tags': !exists(json, 'mask_in_this_host_or_image_tags') ? undefined : json['mask_in_this_host_or_image_tags'], + 'mask_in_this_image_tag': !exists(json, 'mask_in_this_image_tag') ? undefined : json['mask_in_this_image_tag'], 'result_ids': json['result_ids'], 'scan_id': json['scan_id'], 'scan_type': json['scan_type'], @@ -106,6 +113,7 @@ export function ModelScanResultsMaskRequestToJSON(value?: ModelScanResultsMaskRe 'mask_across_hosts_and_images': value.mask_across_hosts_and_images, 'mask_in_this_host_or_image_tags': value.mask_in_this_host_or_image_tags, + 'mask_in_this_image_tag': value.mask_in_this_image_tag, 'result_ids': value.result_ids, 'scan_id': value.scan_id, 'scan_type': value.scan_type, diff --git a/deepfence_frontend/apps/dashboard/src/api/generated/models/index.ts b/deepfence_frontend/apps/dashboard/src/api/generated/models/index.ts index 9b39200d2d..572bda2e47 100644 --- a/deepfence_frontend/apps/dashboard/src/api/generated/models/index.ts +++ b/deepfence_frontend/apps/dashboard/src/api/generated/models/index.ts @@ -13,6 +13,7 @@ export * from './DiagnosisDiagnosticLogsLink'; export * from './DiagnosisDiagnosticLogsStatus'; export * from './DiagnosisDiagnosticNotification'; export * from './DiagnosisGenerateAgentDiagnosticLogsRequest'; +export * from './DiagnosisGenerateCloudScannerDiagnosticLogsRequest'; export * from './DiagnosisGenerateConsoleDiagnosticLogsRequest'; export * from './DiagnosisGetDiagnosticLogsResponse'; export * from './DiagnosisNodeIdentifier'; diff --git a/deepfence_frontend/apps/dashboard/src/features/settings/pages/DiagnosticLogs.tsx b/deepfence_frontend/apps/dashboard/src/features/settings/pages/DiagnosticLogs.tsx index be932ddb7e..5f7ac28ae6 100644 --- a/deepfence_frontend/apps/dashboard/src/features/settings/pages/DiagnosticLogs.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/settings/pages/DiagnosticLogs.tsx @@ -1,11 +1,13 @@ import { useSuspenseQuery } from '@suspensive/react-query'; import { Suspense, useMemo, useState } from 'react'; -import { ActionFunctionArgs, useFetcher } from 'react-router-dom'; +import { ActionFunctionArgs, FetcherWithComponents, useFetcher } from 'react-router-dom'; import { useInterval } from 'react-use'; import { toast } from 'sonner'; import { Button, createColumnHelper, + Listbox, + ListboxOption, SlidingModal, SlidingModalCloseButton, SlidingModalContent, @@ -21,6 +23,7 @@ import { DiagnosisNodeIdentifierNodeTypeEnum, } from '@/api/generated'; import { DFLink } from '@/components/DFLink'; +import { SearchableCloudAccountsList } from '@/components/forms/SearchableCloudAccountsList'; import { SearchableClusterList } from '@/components/forms/SearchableClusterList'; import { SearchableHostList } from '@/components/forms/SearchableHostList'; import { DownloadLineIcon } from '@/components/icons/common/DownloadLine'; @@ -31,11 +34,13 @@ import { invalidateAllQueries, queries } from '@/queries'; import { get403Message, getResponseErrors } from '@/utils/403'; import { apiWrapper } from '@/utils/api'; import { formatMilliseconds } from '@/utils/date'; +import { getArrayTypeValuesFromFormData } from '@/utils/formData'; const DEFAULT_PAGE_SIZE = 10; const ACTION_TYPE = { CONSOLE_LOGS: 'consoleLogs', AGENT_LOGS: 'agentLogs', + CLOUD_SCANNER_LOGS: 'cloudScannerLogs', }; type ActionData = { @@ -68,13 +73,19 @@ const action = async ({ request }: ActionFunctionArgs): Promise => { } } + // cloud filter + const accountIds = getArrayTypeValuesFromFormData(formData, 'cloudAccountsFilter'); + if (!actionType) { return { success: false, message: 'You have not triggered any action', }; } - if (actionType === ACTION_TYPE.AGENT_LOGS) { + if ( + actionType === ACTION_TYPE.AGENT_LOGS || + actionType === ACTION_TYPE.CLOUD_SCANNER_LOGS + ) { const _hosts = nodeIds.map((node) => { return { node_id: node, @@ -89,17 +100,37 @@ const action = async ({ request }: ActionFunctionArgs): Promise => { }; }); - const logsApi = apiWrapper({ - fn: getDiagnosisApiClient().generateAgentDiagnosticLogs, + const clouds = accountIds.map((account) => { + return { + node_id: account, + node_type: DiagnosisNodeIdentifierNodeTypeEnum.CloudAccount, + }; }); - const logsResponse = await logsApi({ - diagnosisGenerateAgentDiagnosticLogsRequest: { - node_ids: [..._hosts, ..._clusters], - tail: 10000, - }, + const logsApi = apiWrapper({ + fn: + actionType === ACTION_TYPE.CLOUD_SCANNER_LOGS + ? getDiagnosisApiClient().generateCloudScannerDiagnosticLogs + : getDiagnosisApiClient().generateAgentDiagnosticLogs, }); + const api = + actionType === ACTION_TYPE.CLOUD_SCANNER_LOGS + ? { + diagnosisGenerateCloudScannerDiagnosticLogsRequest: { + node_ids: [..._hosts, ..._clusters, ...clouds], + tail: 10000, + }, + } + : { + diagnosisGenerateAgentDiagnosticLogsRequest: { + node_ids: [..._hosts, ..._clusters, ...clouds], + tail: 10000, + }, + }; + + const logsResponse = await logsApi(api); + if (!logsResponse.ok) { if (logsResponse.error.response.status === 400) { const { message, fieldErrors } = await getResponseErrors(logsResponse.error); @@ -239,6 +270,7 @@ const AgentDiagnosticLogsTable = () => { const { data } = useGetLogs(); const { data: _logs, message } = data; const agentLogs = _logs?.agent_logs ?? []; + const cloudScannerLogs = _logs?.cloud_scanner_logs ?? []; const [pageSize, setPageSize] = useState(DEFAULT_PAGE_SIZE); const columns = useMemo(() => { @@ -305,7 +337,7 @@ const AgentDiagnosticLogsTable = () => { <> { ); }; +const SelectCloudAccount = ({ + fetcher, +}: { + fetcher: FetcherWithComponents; +}) => { + const [cloud, setCloud] = useState(''); + const [selectedCloudAccounts, setSelectedCloudAccounts] = useState([]); + + return ( +
+ { + setCloud(value); + }} + placeholder="Select cloud type" + label="Select Cloud Type" + getDisplayValue={(value) => { + return value?.toString() || ''; + }} + > + {['AWS', 'GCP', 'Azure']?.map((provider) => { + return ( + + {provider} + + ); + })} + + { + setSelectedCloudAccounts([]); + }} + onChange={(value) => { + setSelectedCloudAccounts(value); + }} + helperText={fetcher?.data?.fieldErrors?.node_ids} + color={fetcher?.data?.fieldErrors?.node_ids ? 'error' : 'default'} + /> +
+ ); +}; const AgentDiagnosticsLogsModal = ({ showDialog, setShowDialog, nodeType, }: { showDialog: boolean; - nodeType: 'host' | 'cluster'; + nodeType: 'host' | 'cluster' | 'cloud account'; setShowDialog: React.Dispatch>; }) => { const fetcher = useFetcher(); @@ -382,7 +463,11 @@ const AgentDiagnosticsLogsModal = ({ name="actionType" readOnly hidden - value={ACTION_TYPE.AGENT_LOGS} + value={ + nodeType === 'cloud account' + ? ACTION_TYPE.CLOUD_SCANNER_LOGS + : ACTION_TYPE.AGENT_LOGS + } /> {nodeType === 'host' && ( )} + {nodeType === 'cloud account' && } + {fetcher?.data?.message ? (

{fetcher.data.message} @@ -448,7 +535,7 @@ const AgentDiagnosticsLogsModal = ({ const AgentDiagnosticLogsComponent = () => { const [showDialog, setShowDialog] = useState(false); - const [nodeType, setNodeType] = useState<'host' | 'cluster'>('host'); + const [nodeType, setNodeType] = useState<'host' | 'cluster' | 'cloud account'>('host'); const { data } = useGetLogs(); const { message } = data; if (message) { @@ -488,6 +575,18 @@ const AgentDiagnosticLogsComponent = () => { > Generate cluster agent diagnostic logs + );