tapbuy/data-scrubber

一个帮助清理敏感数据的工具

0.5 2024-06-24 14:09 UTC

This package is auto-updated.

Last update: 2024-09-24 14:36:28 UTC


README

一个帮助清理敏感数据的工具。

用法

$dataScrubber = new DataScrubber(string $url)
API URL 应返回一个键的 JSON 数组。
结果存储在 var/data-scrubbing-keys.json
如果文件不存在,将从 API 获取。
要更新文件,使用以下命令
php bin/updateKeys.php https://domain.com/keys

$dataScrubber->anonymizeObject(array|object $data): array|object

$dataScrubber = new DataScrubber('https://domain.com/keys');
$data = [
    "userName" => "John Doe",
    "something" => [
        "email" => "john.doe@mail.com",
        "nonPersonalKey" => "value"
    ],
    "test" => [
        "phonenumber" => [
            "phonenumber" => 606060606,
        ]
    ],
    "arrayValue": [
        "shouldBeScrubbed1",
        "shouldBeScrubbed2",
        "shouldBeScrubbed3",
    ]
];
$data = $dataScrubber->anonymizeObject($data);

对于数组,您的 API 端点应返回 key[],例如 arrayValue[]

使用此 API 响应示例: ["userName", "email", "phonenumber", "arrayValue[]"]

[
    "userName" => "********",
    "something" => [
        "email" => "*****************",
        "nonPersonalKey" => "value"
    ],
    "test" => [
        "phonenumber" => [
            "phonenumber" => 394720143,
        ]
    ],
    "arrayValue": [
        "*****************",
        "*****************",
        "*****************",
    ]
]