This repository has been archived by the owner on Apr 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add detect method to allow discovering PII in normal data
- Loading branch information
Showing
3 changed files
with
77 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { detect, isPII } from "../index" | ||
|
||
const detector = (data: unknown) => Array.isArray(data) | ||
|
||
describe("detect", () => { | ||
it("should detect variables", () => { | ||
expect(detect(detector, "test")).toBe("test") | ||
expect(isPII(detect(detector, []))).toBeTruthy() | ||
}) | ||
|
||
it("should handle Map", () => { | ||
const map = new Map<string, any>([ | ||
["a", 1], | ||
["b", []], | ||
]) | ||
|
||
const detectedArrays = detect(detector, { test: map }) | ||
expect(isPII((detectedArrays as any).test.get("b"))).toBeTruthy() | ||
}) | ||
|
||
it("should handle Set", () => { | ||
const set = new Set([[]]) | ||
|
||
const detectedArrays = detect(detector, { test: set }) | ||
expect(isPII(Array.from((detectedArrays as any).test)[0])).toBeTruthy() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters