Skip to content

Commit 368bd8d

Browse files
Merge pull request #74 from Onboardbase/redaction
feat: optionally mask rawValue inside scanResult
2 parents 3c20ec5 + bad991c commit 368bd8d

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "securelog-scan",
3-
"version": "3.0.21",
3+
"version": "3.0.22",
44
"description": "A CLI tool to scan codebases for potential secrets.",
55
"main": "dist/index.js",
66
"author": {

src/shared/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ export const maskAndRedactSensitiveData = async (
5353
const { scan } = detector;
5454
const scanResponse = await scan(false, options.rawValue as string);
5555
if (scanResponse && scanResponse.rawValue) {
56+
/***
57+
* this replaces the secrets in the string to a masked one should incase there
58+
* are multiple secrets in the string, it replaces them one by one based on how
59+
* many secrets was detected
60+
*/
5661
modifiedValue = modifiedValue?.replaceAll(
5762
scanResponse.rawValue as string,
5863
maskString(scanResponse.rawValue as string, {
@@ -61,6 +66,16 @@ export const maskAndRedactSensitiveData = async (
6166
})
6267
);
6368

69+
/**
70+
* this masks the rawValue thats inside the scanResult based on the user option
71+
*/
72+
if (options.maskSecretRawValue) {
73+
scanResponse.rawValue = maskString(scanResponse.rawValue as string, {
74+
maskValue: options.maskedValue,
75+
visibleChars: options.visibleChars,
76+
});
77+
}
78+
6479
return scanResponse;
6580
}
6681
})

src/types/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface ScanStringOptions {
2323
maskedValue?: string;
2424
visibleChars?: number;
2525
customDetectors?: DetectorConfig[];
26+
maskSecretRawValue?: boolean;
2627
}
2728

2829
export interface DecayOptions {
@@ -94,10 +95,10 @@ export interface DataFormat {
9495
}
9596

9697
export type RedactionPattern = {
97-
pattern: string; // RE2 compatible pattern
98+
pattern: string; // RE2 compatible pattern
9899
replacement: string;
99100
description?: string;
100-
}
101+
};
101102

102103
export type RedactionConfig = {
103104
[key: string]: RedactionPattern;

0 commit comments

Comments
 (0)