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

Update reporting spec #2370

Merged
merged 2 commits into from
Nov 12, 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
16,751 changes: 16,751 additions & 0 deletions deepfence_frontend/apps/dashboard/api-spec-original.json

Large diffs are not rendered by default.

569 changes: 15 additions & 554 deletions deepfence_frontend/apps/dashboard/api-spec.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions deepfence_frontend/apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"lint:fix": "eslint ./src --ext .jsx,.js,.ts,.tsx --quiet --fix --ignore-path ./.gitignore",
"test": "vitest",
"coverage": "vitest run --coverage",
"codegen": "pnpm run codegen:clean && openapi-generator-cli generate",
"codegen:clean": "rm -rf ./src/api/generated"
"codegen": "pnpm run codegen:clean && pnpm run transform-api-spec && openapi-generator-cli generate",
"codegen:clean": "rm -rf ./src/api/generated",
"transform-api-spec": "node scripts/transformAPISpec.js"
},
"dependencies": {
"@antv/g6": "^4.8.24",
Expand Down
44 changes: 44 additions & 0 deletions deepfence_frontend/apps/dashboard/scripts/transformAPISpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import fs from 'fs';
import path from 'path';
import * as prettier from 'prettier';

(async () => {
const apiSpec = JSON.parse(
fs.readFileSync(path.resolve('./api-spec-original.json'), 'utf8'),
);

// BEGIN: Transform UtilsReportFilters node_type
delete apiSpec.components.schemas.UtilsReportFilters.properties.node_type.items.type;
apiSpec.components.schemas.UtilsReportFilters.properties.node_type.items.enum =
apiSpec.components.schemas.UtilsReportFilters.properties.node_type.enum;
delete apiSpec.components.schemas.UtilsReportFilters.properties.node_type.enum;
// END

// BEGIN INGEST API ISSUE FIXES
const routes = [
'/deepfence/ingest/cloud-resources',
'/deepfence/ingest/cloud-compliance-status',
'/deepfence/ingest/cloud-compliance',
'/deepfence/ingest/compliance-scan-logs',
'/deepfence/ingest/compliance',
'/deepfence/ingest/malware',
'/deepfence/ingest/malware-scan-logs',
'/deepfence/ingest/secret-scan-logs',
'/deepfence/ingest/secrets',
'/deepfence/ingest/vulnerabilities',
'/deepfence/ingest/vulnerabilities-scan-logs',
];

routes.forEach((route) => {
delete apiSpec.paths[route];
});

// END

const prettierrc = fs.readFileSync(path.resolve('./../../.prettierrc.json'), 'utf-8');
const fileContent = await prettier.format(JSON.stringify(apiSpec), {
...JSON.parse(prettierrc),
parser: 'json',
});
fs.writeFileSync(path.resolve('./api-spec.json'), fileContent, 'utf8');
})();
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.openapi-generator-ignore
apis/AuthenticationApi.ts
apis/CloudNodesApi.ts
apis/CloudResourcesApi.ts
apis/CloudScannerApi.ts
apis/CommonApi.ts
apis/CompletionApi.ts
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import * as runtime from '../runtime';
import type {
ApiDocsBadRequestResponse,
ApiDocsFailureResponse,
IngestersCloudCompliance,
IngestersCloudComplianceScanStatus,
ModelCloudComplianceScanResult,
ModelComplianceScanStatusResp,
ModelScanListReq,
Expand All @@ -32,10 +30,6 @@ import {
ApiDocsBadRequestResponseToJSON,
ApiDocsFailureResponseFromJSON,
ApiDocsFailureResponseToJSON,
IngestersCloudComplianceFromJSON,
IngestersCloudComplianceToJSON,
IngestersCloudComplianceScanStatusFromJSON,
IngestersCloudComplianceScanStatusToJSON,
ModelCloudComplianceScanResultFromJSON,
ModelCloudComplianceScanResultToJSON,
ModelComplianceScanStatusRespFromJSON,
Expand All @@ -56,14 +50,6 @@ export interface CountResultsCloudComplianceScanRequest {
modelScanResultsReq?: ModelScanResultsReq;
}

export interface IngestCloudComplianceScanStatusRequest {
ingestersCloudComplianceScanStatus?: Array<IngestersCloudComplianceScanStatus> | null;
}

export interface IngestCloudCompliancesRequest {
ingestersCloudCompliance?: Array<IngestersCloudCompliance> | null;
}

export interface ListCloudComplianceScanRequest {
modelScanListReq?: ModelScanListReq;
}
Expand Down Expand Up @@ -99,38 +85,6 @@ export interface CloudScannerApiInterface {
*/
countResultsCloudComplianceScan(requestParameters: CountResultsCloudComplianceScanRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SearchSearchCountResp>;

/**
* Ingest Cloud compliances found while scanning cloud provider
* @summary Ingest Cloud Compliances scan status
* @param {Array<IngestersCloudComplianceScanStatus>} [ingestersCloudComplianceScanStatus]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof CloudScannerApiInterface
*/
ingestCloudComplianceScanStatusRaw(requestParameters: IngestCloudComplianceScanStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>>;

/**
* Ingest Cloud compliances found while scanning cloud provider
* Ingest Cloud Compliances scan status
*/
ingestCloudComplianceScanStatus(requestParameters: IngestCloudComplianceScanStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;

/**
* Ingest Cloud compliances found while scanning cloud provider
* @summary Ingest Cloud Compliances
* @param {Array<IngestersCloudCompliance>} [ingestersCloudCompliance]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof CloudScannerApiInterface
*/
ingestCloudCompliancesRaw(requestParameters: IngestCloudCompliancesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>>;

/**
* Ingest Cloud compliances found while scanning cloud provider
* Ingest Cloud Compliances
*/
ingestCloudCompliances(requestParameters: IngestCloudCompliancesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;

/**
* Get Cloud Compliance Scans list for cloud node
* @summary Get Cloud Compliance Scans List
Expand Down Expand Up @@ -225,82 +179,6 @@ export class CloudScannerApi extends runtime.BaseAPI implements CloudScannerApiI
return await response.value();
}

/**
* Ingest Cloud compliances found while scanning cloud provider
* Ingest Cloud Compliances scan status
*/
async ingestCloudComplianceScanStatusRaw(requestParameters: IngestCloudComplianceScanStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
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/ingest/cloud-compliance-status`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: requestParameters.ingestersCloudComplianceScanStatus?.map(IngestersCloudComplianceScanStatusToJSON),
}, initOverrides);

return new runtime.VoidApiResponse(response);
}

/**
* Ingest Cloud compliances found while scanning cloud provider
* Ingest Cloud Compliances scan status
*/
async ingestCloudComplianceScanStatus(requestParameters: IngestCloudComplianceScanStatusRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.ingestCloudComplianceScanStatusRaw(requestParameters, initOverrides);
}

/**
* Ingest Cloud compliances found while scanning cloud provider
* Ingest Cloud Compliances
*/
async ingestCloudCompliancesRaw(requestParameters: IngestCloudCompliancesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
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/ingest/cloud-compliance`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: requestParameters.ingestersCloudCompliance?.map(IngestersCloudComplianceToJSON),
}, initOverrides);

return new runtime.VoidApiResponse(response);
}

/**
* Ingest Cloud compliances found while scanning cloud provider
* Ingest Cloud Compliances
*/
async ingestCloudCompliances(requestParameters: IngestCloudCompliancesRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.ingestCloudCompliancesRaw(requestParameters, initOverrides);
}

/**
* Get Cloud Compliance Scans list for cloud node
* Get Cloud Compliance Scans List
Expand Down
Loading
Loading