Skip to content

Commit 2040569

Browse files
Update checkmarx-ast-cli binaries with 2.0.2 (#23)
* Update checkmarx-ast-cli to 2.0.2
1 parent 31675c7 commit 2040569

File tree

5 files changed

+37
-46
lines changed

5 files changed

+37
-46
lines changed

checkmarx-ast-cli.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.1
1+
2.0.2

src/main/CxAuth.ts

Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export class CxAuth {
1414
clientId: string = "";
1515
clientSecret: string = "";
1616
apiKey: string = "";
17-
commands: string[] = [];
1817
pathToExecutable: string;
1918
tenant: string;
2019

@@ -56,7 +55,7 @@ export class CxAuth {
5655
}
5756

5857
initializeCommands(formatRequired: boolean): string[] {
59-
let list: string[] = [];
58+
const list: string[] = [];
6059
if (this.clientId) {
6160
list.push("--client-id");
6261
list.push(this.clientId);
@@ -80,61 +79,57 @@ export class CxAuth {
8079
if (formatRequired) {
8180
list.push("--format");
8281
list.push("json");
83-
list.push("-v");
8482
}
8583
return list;
8684
}
8785

8886
async scanCreate(params: ParamTypeMap): Promise<CxCommandOutput> {
89-
this.commands = this.initializeCommands(true);
90-
this.commands.push("scan");
91-
this.commands.push("create");
87+
const commands: string[] = ["scan", "create"];
88+
commands.push(...this.initializeCommands(true));
9289
params.forEach((value: string, key: CxParamType) => {
9390
if (key !== CxParamType.ADDITIONAL_PARAMETERS && key.length !== 1 && value) {
94-
this.commands.push("--" + key.toString().replace(/_/g, "-").toLowerCase());
95-
this.commands.push(value);
91+
commands.push("--" + key.toString().replace(/_/g, "-").toLowerCase());
92+
commands.push(value);
9693
} else if (key.length === 1 && value) {
97-
this.commands.push("-" + key.toString().replace(/_/g, "-").toLowerCase());
98-
this.commands.push(value);
94+
commands.push("-" + key.toString().replace(/_/g, "-").toLowerCase());
95+
commands.push(value);
9996
} else if (key === CxParamType.ADDITIONAL_PARAMETERS) {
10097
let paramList = value.match(/(?:[^\s"]+|"[^"]*")+/g);
10198
console.log("Additional parameters refined: " + paramList)
10299
if (paramList) {
103100
paramList.forEach((element) => {
104-
this.commands.push(element);
101+
commands.push(element);
105102
});
106103
}
107104
}
108105
});
109106

110-
let exec = new ExecutionService();
111-
return await exec.executeCommands(this.pathToExecutable, this.commands);
107+
const exec = new ExecutionService();
108+
return await exec.executeCommands(this.pathToExecutable, commands);
112109
}
113110

114111
async scanShow(id: string): Promise<CxCommandOutput> {
115-
this.commands = this.initializeCommands(true);
116-
this.commands.push("scan");
117-
this.commands.push("show");
118-
this.commands.push("--scan-id");
119-
this.commands.push(id);
120-
let exec = new ExecutionService();
121-
return await exec.executeCommands(this.pathToExecutable, this.commands);
112+
const commands: string[] = ["scan", "show", "--scan-id", id];
113+
commands.push(...this.initializeCommands(true));
114+
115+
const exec = new ExecutionService();
116+
return await exec.executeCommands(this.pathToExecutable, commands);
122117
}
123118

124119
async scanList(): Promise<CxCommandOutput> {
125-
this.commands = this.initializeCommands(true);
126-
this.commands.push("scan");
127-
this.commands.push("list");
128-
let exec = new ExecutionService();
129-
return await exec.executeCommands(this.pathToExecutable, this.commands);
120+
const commands: string[] = ["scan", "list"];
121+
commands.push(...this.initializeCommands(true));
122+
123+
const exec = new ExecutionService();
124+
return await exec.executeCommands(this.pathToExecutable, commands);
130125
}
131126

132127
async projectList(): Promise<CxCommandOutput> {
133-
this.commands = this.initializeCommands(true);
134-
this.commands.push("project");
135-
this.commands.push("list");
136-
let exec = new ExecutionService();
137-
return await exec.executeCommands(this.pathToExecutable, this.commands);
128+
const commands: string[] = ["project", "list"];
129+
commands.push(...this.initializeCommands(true));
130+
131+
const exec = new ExecutionService();
132+
return await exec.executeCommands(this.pathToExecutable, commands);
138133
}
139134

140135
async getResultsList(scanId: string) {
@@ -146,42 +141,38 @@ export class CxAuth {
146141
}
147142

148143
async getResults(scanId: string, resultType:string, outputFileName: string, outputFilePath: string) {
149-
this.commands = this.createResultCommand(scanId, resultType, outputFileName, outputFilePath)
144+
const commands = this.createResultCommand(scanId, resultType, outputFileName, outputFilePath)
150145

151146
const exec = new ExecutionService();
152-
return await exec.executeCommands(this.pathToExecutable, this.commands);
147+
return await exec.executeCommands(this.pathToExecutable, commands);
153148
}
154149

155150
async executeResultsCommands(scanId: string, resultType: string, fileExtension: string): Promise<string> {
156151
const fileName = new Date().getTime().toString();
157-
this.commands = this.createResultCommand(scanId, resultType, fileName, os.tmpdir())
152+
const commands = this.createResultCommand(scanId, resultType, fileName, os.tmpdir())
158153

159154
const exec = new ExecutionService();
160-
await exec.executeResultsCommands(this.pathToExecutable, this.commands)
155+
await exec.executeResultsCommands(this.pathToExecutable, commands)
161156

162157
const filePath = path.join(os.tmpdir(), fileName + fileExtension)
163158

164159
return fs.readFileSync(filePath,'utf8');
165160
}
166161

167162
createResultCommand(scanId: string, reportFormat: string, outputFileName: string, outputPath: string): string[] {
168-
const resultCommands = this.initializeCommands(false);
169-
resultCommands.push("result");
170-
resultCommands.push("--scan-id");
171-
resultCommands.push(scanId);
172-
resultCommands.push("--report-format");
173-
resultCommands.push(reportFormat);
163+
const commands: string[] = ["result", "--scan-id", scanId, "--report-format", reportFormat];
174164

175165
if (outputFileName) {
176-
resultCommands.push("--output-name")
177-
resultCommands.push(outputFileName)
166+
commands.push("--output-name")
167+
commands.push(outputFileName)
178168
}
179169
if (outputPath) {
180-
resultCommands.push("--output-path")
181-
resultCommands.push(outputPath)
170+
commands.push("--output-path")
171+
commands.push(outputPath)
182172
}
173+
commands.push(...this.initializeCommands(false));
183174

184-
return resultCommands;
175+
return commands;
185176
}
186177
}
187178

src/main/resources/cx-linux

24 KB
Binary file not shown.

src/main/resources/cx-mac

21.6 KB
Binary file not shown.

src/main/resources/cx.exe

22.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)