Skip to content

Commit

Permalink
Merge pull request #918 from deepfence/v2-ui-most-exploitable
Browse files Browse the repository at this point in the history
V2 UI most exploitable
  • Loading branch information
milan-deepfence authored Mar 1, 2023
2 parents 5264abc + 1278046 commit 9e973d0
Show file tree
Hide file tree
Showing 11 changed files with 1,002 additions and 278 deletions.
97 changes: 27 additions & 70 deletions deepfence_frontend/apps/dashboard/api-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -2452,90 +2452,26 @@
}
},
"/deepfence/scan/nodes-in-result": {
"get": {
"post": {
"tags": ["Scan Results"],
"summary": "Get all nodes in given scan result ids",
"description": "Get all nodes in given scan result ids",
"operationId": "getAllNodesInScanResults",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": { "$ref": "#/components/schemas/ModelScanResultBasicNode" }
}
}
}
},
"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" }
}
"requestBody": {
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ModelNodesInScanResultRequest" }
}
}
},
"security": [{ "bearer_token": [] }]
}
},
"/deepfence/scan/nodes/{scan_type}/{result_id}": {
"get": {
"tags": ["Scan Results"],
"summary": "Get all nodes in given scan result",
"description": "Get all nodes in given scan result",
"operationId": "getAllNodesInScanResult",
"parameters": [
{
"name": "result_id",
"in": "path",
"required": true,
"schema": { "type": "string" }
},
{
"name": "scan_type",
"in": "path",
"required": true,
"schema": {
"enum": [
"SecretScan",
"VulnerabilityScan",
"MalwareScan",
"ComplianceScan",
"CloudComplianceScan"
],
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": { "$ref": "#/components/schemas/ModelBasicNode" }
"items": { "$ref": "#/components/schemas/ModelScanResultBasicNode" }
}
}
}
Expand Down Expand Up @@ -7456,6 +7392,27 @@
}
}
},
"ModelNodesInScanResultRequest": {
"required": ["result_ids", "scan_type"],
"type": "object",
"properties": {
"result_ids": {
"type": "array",
"items": { "type": "string" },
"nullable": true
},
"scan_type": {
"enum": [
"SecretScan",
"VulnerabilityScan",
"MalwareScan",
"ComplianceScan",
"CloudComplianceScan"
],
"type": "string"
}
}
},
"ModelPasswordResetRequest": {
"required": ["email"],
"type": "object",
Expand Down
3 changes: 3 additions & 0 deletions deepfence_frontend/apps/dashboard/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export function getSearchApiClient() {
searchVulnerabilities: searchApi.searchVulnerabilities.bind(searchApi),
searchVulnerabilitiesCount: searchApi.countVulnerabilities.bind(searchApi),
searchVulnerabilityScanCount: searchApi.countVulnerabilityScans.bind(searchApi),
searchVulnerabilityCount: searchApi.countVulnerabilities.bind(searchApi),
};
}

Expand All @@ -141,5 +142,7 @@ export function getScanResultsApiClient() {
notifyScanResult: scanResultsApi.notifyScanResult.bind(scanResultsApi),
maskScanResult: scanResultsApi.maskScanResult.bind(scanResultsApi),
unmaskScanResult: scanResultsApi.unmaskScanResult.bind(scanResultsApi),
getAllNodesInScanResults:
scanResultsApi.getAllNodesInScanResults.bind(scanResultsApi),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ models/ModelMalwareScanResult.ts
models/ModelMalwareScanTriggerReq.ts
models/ModelMessageResponse.ts
models/ModelNodeIdentifier.ts
models/ModelNodesInScanResultRequest.ts
models/ModelPasswordResetRequest.ts
models/ModelPasswordResetVerifyRequest.ts
models/ModelPod.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import * as runtime from '../runtime';
import type {
ApiDocsBadRequestResponse,
ApiDocsFailureResponse,
ModelBasicNode,
ModelDownloadReportResponse,
ModelNodesInScanResultRequest,
ModelScanResultBasicNode,
ModelScanResultsActionRequest,
ModelScanResultsMaskRequest,
Expand All @@ -28,10 +28,10 @@ import {
ApiDocsBadRequestResponseToJSON,
ApiDocsFailureResponseFromJSON,
ApiDocsFailureResponseToJSON,
ModelBasicNodeFromJSON,
ModelBasicNodeToJSON,
ModelDownloadReportResponseFromJSON,
ModelDownloadReportResponseToJSON,
ModelNodesInScanResultRequestFromJSON,
ModelNodesInScanResultRequestToJSON,
ModelScanResultBasicNodeFromJSON,
ModelScanResultBasicNodeToJSON,
ModelScanResultsActionRequestFromJSON,
Expand All @@ -54,9 +54,8 @@ export interface DownloadScanResultsRequest {
scanType: DownloadScanResultsScanTypeEnum;
}

export interface GetAllNodesInScanResultRequest {
resultId: string;
scanType: GetAllNodesInScanResultScanTypeEnum;
export interface GetAllNodesInScanResultsRequest {
modelNodesInScanResultRequest?: ModelNodesInScanResultRequest;
}

export interface MaskScanResultRequest {
Expand Down Expand Up @@ -128,37 +127,21 @@ export interface ScanResultsApiInterface {
*/
downloadScanResults(requestParameters: DownloadScanResultsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ModelDownloadReportResponse>;

/**
* Get all nodes in given scan result
* @summary Get all nodes in given scan result
* @param {string} resultId
* @param {'SecretScan' | 'VulnerabilityScan' | 'MalwareScan' | 'ComplianceScan' | 'CloudComplianceScan'} scanType
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ScanResultsApiInterface
*/
getAllNodesInScanResultRaw(requestParameters: GetAllNodesInScanResultRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ModelBasicNode>>>;

/**
* Get all nodes in given scan result
* Get all nodes in given scan result
*/
getAllNodesInScanResult(requestParameters: GetAllNodesInScanResultRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ModelBasicNode>>;

/**
* Get all nodes in given scan result ids
* @summary Get all nodes in given scan result ids
* @param {ModelNodesInScanResultRequest} [modelNodesInScanResultRequest]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ScanResultsApiInterface
*/
getAllNodesInScanResultsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ModelScanResultBasicNode>>>;
getAllNodesInScanResultsRaw(requestParameters: GetAllNodesInScanResultsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ModelScanResultBasicNode>>>;

/**
* Get all nodes in given scan result ids
* Get all nodes in given scan result ids
*/
getAllNodesInScanResults(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ModelScanResultBasicNode>>;
getAllNodesInScanResults(requestParameters: GetAllNodesInScanResultsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ModelScanResultBasicNode>>;

/**
* Mask scan results
Expand Down Expand Up @@ -340,59 +323,17 @@ export class ScanResultsApi extends runtime.BaseAPI implements ScanResultsApiInt
return await response.value();
}

/**
* Get all nodes in given scan result
* Get all nodes in given scan result
*/
async getAllNodesInScanResultRaw(requestParameters: GetAllNodesInScanResultRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ModelBasicNode>>> {
if (requestParameters.resultId === null || requestParameters.resultId === undefined) {
throw new runtime.RequiredError('resultId','Required parameter requestParameters.resultId was null or undefined when calling getAllNodesInScanResult.');
}

if (requestParameters.scanType === null || requestParameters.scanType === undefined) {
throw new runtime.RequiredError('scanType','Required parameter requestParameters.scanType was null or undefined when calling getAllNodesInScanResult.');
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

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/scan/nodes/{scan_type}/{result_id}`.replace(`{${"result_id"}}`, encodeURIComponent(String(requestParameters.resultId))).replace(`{${"scan_type"}}`, encodeURIComponent(String(requestParameters.scanType))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ModelBasicNodeFromJSON));
}

/**
* Get all nodes in given scan result
* Get all nodes in given scan result
*/
async getAllNodesInScanResult(requestParameters: GetAllNodesInScanResultRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ModelBasicNode>> {
const response = await this.getAllNodesInScanResultRaw(requestParameters, initOverrides);
return await response.value();
}

/**
* Get all nodes in given scan result ids
* Get all nodes in given scan result ids
*/
async getAllNodesInScanResultsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ModelScanResultBasicNode>>> {
async getAllNodesInScanResultsRaw(requestParameters: GetAllNodesInScanResultsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ModelScanResultBasicNode>>> {
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", []);
Expand All @@ -403,9 +344,10 @@ export class ScanResultsApi extends runtime.BaseAPI implements ScanResultsApiInt
}
const response = await this.request({
path: `/deepfence/scan/nodes-in-result`,
method: 'GET',
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: ModelNodesInScanResultRequestToJSON(requestParameters.modelNodesInScanResultRequest),
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ModelScanResultBasicNodeFromJSON));
Expand All @@ -415,8 +357,8 @@ export class ScanResultsApi extends runtime.BaseAPI implements ScanResultsApiInt
* Get all nodes in given scan result ids
* Get all nodes in given scan result ids
*/
async getAllNodesInScanResults(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ModelScanResultBasicNode>> {
const response = await this.getAllNodesInScanResultsRaw(initOverrides);
async getAllNodesInScanResults(requestParameters: GetAllNodesInScanResultsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ModelScanResultBasicNode>> {
const response = await this.getAllNodesInScanResultsRaw(requestParameters, initOverrides);
return await response.value();
}

Expand Down Expand Up @@ -558,14 +500,3 @@ export const DownloadScanResultsScanTypeEnum = {
CloudComplianceScan: 'CloudComplianceScan'
} as const;
export type DownloadScanResultsScanTypeEnum = typeof DownloadScanResultsScanTypeEnum[keyof typeof DownloadScanResultsScanTypeEnum];
/**
* @export
*/
export const GetAllNodesInScanResultScanTypeEnum = {
SecretScan: 'SecretScan',
VulnerabilityScan: 'VulnerabilityScan',
MalwareScan: 'MalwareScan',
ComplianceScan: 'ComplianceScan',
CloudComplianceScan: 'CloudComplianceScan'
} as const;
export type GetAllNodesInScanResultScanTypeEnum = typeof GetAllNodesInScanResultScanTypeEnum[keyof typeof GetAllNodesInScanResultScanTypeEnum];
Loading

0 comments on commit 9e973d0

Please sign in to comment.