Skip to content

Commit a7f7a22

Browse files
cx-itay-pazItay Paz
andauthored
add ignore file to secrets (#865)
Co-authored-by: Itay Paz <[email protected]>
1 parent 1e6b8e8 commit a7f7a22

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

src/main/wrapper/CxWrapper.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,25 @@ export class CxWrapper {
168168
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.SCAN_OSS);
169169
}
170170

171-
async secretsScanResults(sourceFile: string): Promise<CxCommandOutput> {
172-
const commands: string[] = [CxConstants.CMD_SCAN, CxConstants.CMD_SECRETS, CxConstants.SOURCE, sourceFile];
173-
commands.push(...this.initializeCommands(false));
174-
const exec = new ExecutionService();
175-
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.SCAN_SECRETS);
171+
async secretsScanResults(sourceFile: string, ignoredFilePath?: string): Promise<CxCommandOutput> {
172+
const commands: string[] = [
173+
CxConstants.CMD_SCAN,
174+
CxConstants.CMD_SECRETS,
175+
CxConstants.SOURCE,
176+
sourceFile
177+
];
178+
179+
if (ignoredFilePath) {
180+
commands.push(CxConstants.IGNORE__FILE_PATH);
181+
commands.push(ignoredFilePath);
176182
}
177183

184+
commands.push(...this.initializeCommands(false));
185+
186+
const exec = new ExecutionService();
187+
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.SCAN_SECRETS);
188+
}
189+
178190
async scanCancel(id: string): Promise<CxCommandOutput> {
179191
const commands: string[] = [CxConstants.CMD_SCAN, CxConstants.SUB_CMD_CANCEL, CxConstants.SCAN_ID, id];
180192
commands.push(...this.initializeCommands(false));

src/tests/ScanTest.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ describe("ScanCreate cases", () => {
205205
expect(hasCOA).toBe(false);
206206
});
207207

208-
it.skip('ScanSecrets Successful case', async () => {
208+
it('ScanSecrets Successful case', async () => {
209209
const wrapper = new CxWrapper(cxScanConfig);
210-
const cxCommandOutput: CxCommandOutput = await wrapper.secretsScanResults("src/tests/data/secret-exposed.txt");
210+
const cxCommandOutput: CxCommandOutput = await wrapper.secretsScanResults("src/tests/data/secret-exposed.txt","");
211211
console.log("Json object from scanOSS successful case: " + JSON.stringify(cxCommandOutput));
212212
expect(cxCommandOutput.payload).toBeDefined();
213213
expect(cxCommandOutput.exitCode).toBe(0);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"Title": "github-pat",
3+
"FilePath": "/Users/itaypaz/Library/CloudStorage/OneDrive-Checkmarx/Documents/jswrapper/ast-cli-javascript-wrapper/src/tests/data/secret-exposed.txt",
4+
"Line": 3
5+
}

0 commit comments

Comments
 (0)