Skip to content

Commit b4ce733

Browse files
committed
adding masked secrets + tests
1 parent babd0de commit b4ce733

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

src/main/mask/CxMask.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import CxMaskedSecret from "./CxMaskedSecret";
2+
3+
export default class CxMask {
4+
maskedSecrets: CxMaskedSecret[];
5+
maskedFile: string;
6+
7+
constructor(maskedSecrets: CxMaskedSecret[], maskedFile: string) {
8+
this.maskedSecrets = maskedSecrets;
9+
this.maskedFile = maskedFile;
10+
}
11+
12+
static parseMask(resultObject: any): CxMask {
13+
return new CxMask(resultObject.maskedSecrets,resultObject.maskedFile);
14+
}
15+
}

src/main/mask/CxMaskedSecret.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default class CxMaskedSecret {
2+
masked: string;
3+
secret: string;
4+
line: number;
5+
6+
constructor(masked: string, secret: string, line: number) {
7+
this.masked = masked;
8+
this.secret = secret;
9+
this.line = line;
10+
}
11+
}

src/tests/MaskTest.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {CxWrapper} from '../main/wrapper/CxWrapper';
2+
import {CxCommandOutput} from "../main/wrapper/CxCommandOutput";
3+
import {BaseTest} from "./BaseTest";
4+
5+
describe("Mask cases",() => {
6+
const cxScanConfig = new BaseTest();
7+
it('Mask Successful case', async () => {
8+
const auth = new CxWrapper(cxScanConfig);
9+
const data = await auth.maskSecrets("dist/tests/data/package.json")
10+
const cxCommandOutput: CxCommandOutput = data;
11+
expect(cxCommandOutput.payload.length).toEqual(1);
12+
});
13+
14+
});

0 commit comments

Comments
 (0)