Skip to content

Commit c9384a0

Browse files
committed
Add support for secrets scanning with new CxSecretsResult class and update execution commands
1 parent 33583e0 commit c9384a0

File tree

4 files changed

+158
-110
lines changed

4 files changed

+158
-110
lines changed

src/main/secrets/CxSecrets.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
export default class CxSecretsResult {
2+
title: string;
3+
description: string;
4+
filepath: string;
5+
severity: string;
6+
locations: { line: number, startIndex: number, endIndex: number }[];
7+
8+
static parseResult(resultObject: any): CxSecretsResult[] {
9+
const results = resultObject.Packages;
10+
let secretsResults: CxSecretsResult[] = [];
11+
if (results instanceof Array) {
12+
secretsResults = results.map((member: any) => {
13+
const secretsResult = new CxSecretsResult();
14+
secretsResult.title = member.Title;
15+
secretsResult.description = member.Description;
16+
secretsResult.filepath = member.FilePath;
17+
secretsResult.locations = Array.isArray(member.Locations)
18+
? member.Locations.map((l: any) => ({
19+
line: l.Line,
20+
startIndex: l.StartIndex,
21+
endIndex: l.EndIndex,
22+
}))
23+
: [];
24+
return secretsResult;
25+
});
26+
} else {
27+
const secretsResult = new CxSecretsResult();
28+
secretsResult.title = results.Title;
29+
secretsResult.description = results.Description;
30+
secretsResult.filepath = results.FilePath;
31+
secretsResult.filepath = results.FilePath;
32+
secretsResult.locations = Array.isArray(results.Locations)
33+
? results.Locations.map((l: any) => ({
34+
line: l.Line,
35+
startIndex: l.StartIndex,
36+
endIndex: l.EndIndex,
37+
}))
38+
: [];
39+
secretsResults.push(secretsResult);
40+
}
41+
return secretsResults;
42+
}
43+
}

src/main/wrapper/CxConstants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export enum CxConstants {
9090
SCAN_TYPE = "CxScan",
9191
SCAN_ASCA = "CxAsca",
9292
SCAN_OSS = "CxOss",
93+
SCAN_SECRETS = "CxSecrets",
9394
PROJECT_TYPE = "CxProject",
9495
PREDICATE_TYPE = "CxPredicate",
9596
CODE_BASHING_TYPE = "CxCodeBashing",

src/main/wrapper/CxWrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class CxWrapper {
160160
const commands: string[] = [CxConstants.CMD_SCAN, CxConstants.CMD_OSS, CxConstants.SOURCE, sourceFile];
161161
commands.push(...this.initializeCommands(false));
162162
const exec = new ExecutionService();
163-
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.SCAN_OSS);
163+
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.SCAN_SECRETS);
164164
}
165165

166166
async scanCancel(id: string): Promise<CxCommandOutput> {

0 commit comments

Comments
 (0)