Skip to content
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
22 changes: 17 additions & 5 deletions src/main/wrapper/CxWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,25 @@ export class CxWrapper {
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.SCAN_OSS);
}

async secretsScanResults(sourceFile: string): Promise<CxCommandOutput> {
const commands: string[] = [CxConstants.CMD_SCAN, CxConstants.CMD_SECRETS, CxConstants.SOURCE, sourceFile];
commands.push(...this.initializeCommands(false));
const exec = new ExecutionService();
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.SCAN_SECRETS);
async secretsScanResults(sourceFile: string, ignoredFilePath?: string): Promise<CxCommandOutput> {
const commands: string[] = [
CxConstants.CMD_SCAN,
CxConstants.CMD_SECRETS,
CxConstants.SOURCE,
sourceFile
];

if (ignoredFilePath) {
commands.push(CxConstants.IGNORE__FILE_PATH);
commands.push(ignoredFilePath);
}

commands.push(...this.initializeCommands(false));

const exec = new ExecutionService();
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.SCAN_SECRETS);
}

async scanCancel(id: string): Promise<CxCommandOutput> {
const commands: string[] = [CxConstants.CMD_SCAN, CxConstants.SUB_CMD_CANCEL, CxConstants.SCAN_ID, id];
commands.push(...this.initializeCommands(false));
Expand Down
4 changes: 2 additions & 2 deletions src/tests/ScanTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ describe("ScanCreate cases", () => {
expect(hasCOA).toBe(false);
});

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