aerticket/data-anonymizer
Composer 安装命令:
composer require aerticket/data-anonymizer
包简介
Anonymize sensitive data in your models via annotations
README 文档
README
Anonymize sensitive data in your models via annotations
Installation
Install the package via composer:
composer require aerticket/data-anonymizer
(or by adding the dependency to the composer manifest of an installed package)
Basic usage
You can define which models should be anonymized via annotations:
use Aerticket\DataAnonymizer\Annotations as Anonymizer; /** * @Anonymizer\AnonymizableEntity(referenceDate="updatedAt") */ class SomeClass { /** * @var \DateTime */ $updatedAt; /** * @var string * @Anonymizer\Anonymize() */ $personalData; }
The referenceDate option of the class annotation is mandatory. It is the path to the property that contains the date that
is used to determine the age of the entity. You can use the same syntax as a query condition (e.g.
relatedObject.anotherRelatedObject.creationDate).
To actually trigger the anonymization process, you have to call the following flow command:
./flow anonymize:run
Please note that a maximum number of 100 entities is anonymized per class and run. If more entities have to be anonymized, you have to run the command several times.
Anonymize given entities
If you need to manually trigger data anonymization (e.g. user data that can be cleared after having been processed), you can explicitly anonymize a given entity:
$this->anonymizationService->anonymizeEntity($record);
You can work on not (yet) persisted objects as well by avoiding an update of the record in its repository with the second parameter to anonymizeEntity.
Configuration options
Age
You can define the age after which entities should be anonymized. The default value is configured via Settings.yaml:
Aerticket: DataAnonymizer: defaults: anonymizeAfter: '30 days'
If you want to override this value for a specific class, you can use the anonymizeAfter option of the AnonymizableEntity
annotation.
Anonymized values
When anonymizing an entity, a anonymized value is set for each property that should be anonymized. For different property types (string, integer), different default values are configured via Settings.yaml.
If you want to use an individual value for a specific property, you can add the value to the Anonymize annotation
of the property:
use Aerticket\DataAnonymizer\Annotations as Anonymizer; /** * @Anonymizer\AnonymizableEntity(referenceDate="updatedAt") */ class SomeClass { /** * @var \DateTime */ $updatedAt; /** * @var string * @Anonymizer\Anonymize("anonymized@anonymized.com") */ $emailAddress; }
Limitations
The following limitations apply at the moment:
- This package only works with entities that have its own repository.
- Anonymization of nested properties is non implemented yet.
aerticket/data-anonymizer 适用场景与选型建议
aerticket/data-anonymizer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 137 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 aerticket/data-anonymizer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aerticket/data-anonymizer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 137
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 6
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-08