Skip to content

Commit

Permalink
Merge pull request #71 from Onboardbase/redaction
Browse files Browse the repository at this point in the history
feat: updates
  • Loading branch information
iamnasirudeen authored Jan 25, 2025
2 parents d0a7f1e + 6ebb97f commit da9971c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "securelog-scan",
"version": "3.0.19",
"version": "3.0.20",
"description": "A CLI tool to scan codebases for potential secrets.",
"main": "dist/index.js",
"author": {
Expand Down
25 changes: 19 additions & 6 deletions src/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ const handleCustomDetectors = (customDetectors?: DetectorConfig[]) => {
return parsedDetectors;
};

export const redactSensitiveData = async (
apiKey: string,
/**
* This particular method is exposed and free to use without
* API key but secret details wont be logged
*/
export const maskAndRedactSensitiveData = async (
options: ScanStringOptions
) => {
if (!apiKey) throw new Error("Please attach an API key");
await validateRequestApiKey(apiKey);

const core = new AhoCorasickCore(
handleCustomDetectors(options.customDetectors)
);
Expand Down Expand Up @@ -66,6 +66,19 @@ export const redactSensitiveData = async (
const decayer = decay();
const redactedValues = decayer.redact(maskedValues);

return { rawValue: redactedValues, maskedValues, redactedValues, secrets };
};

export const redactSensitiveData = async (
apiKey: string,
options: ScanStringOptions
) => {
if (!apiKey) throw new Error("Please attach an API key");
await validateRequestApiKey(apiKey);

const { rawValue, maskedValues, redactedValues, secrets } =
await maskAndRedactSensitiveData(options);

try {
await axios.post(`${API_BASE_URL}/log-redacted-secret`, {
rawValue: redactedValues,
Expand All @@ -75,7 +88,7 @@ export const redactSensitiveData = async (
console.log("Error occured logging secrets");
}

return { rawValue: redactedValues, maskedValues, redactedValues, secrets };
return { rawValue, maskedValues, redactedValues, secrets };
};

export const scanStringAndReturnJson = async (options: ScanStringOptions) => {
Expand Down

0 comments on commit da9971c

Please sign in to comment.