brendantwhite/databasemask
Composer 安装命令:
composer require brendantwhite/databasemask
包简介
Mask data from Production using Faker to use safely elsewhere
README 文档
README
Mask data from Production using Faker to use safely elsewhere.
Use Case
Ever wanted to use a copy of your Laravel project's Production database in your test environments? But you can't, because it's a security risk?
Now, you can get a copy of the Production database and mask just the values that need masking - names, phone numbers, email addresses etc - while keeping your data otherwise intact.
Installation
From the command line run:
composer require brendantwhite/databasemask
Configuration
First, ensure you have a Model Factory defined for each Eloquent model class that you want to mask.
Then, add a $masked property to your Eloquent model classes, specifying which attributes on your
model should be masked.
<?php // in app/Models/User.php /** * The attributes that should be masked by DatabaseMask. * * @var array */ protected $masked = [ 'name', 'email', 'password', ];
If you have any models that you don't need to be masked at all,
add the $masked property anyway, but make it an empty array.
<?php // in app/Models/SomeOtherModel.php /** * The attributes that should be masked by DatabaseMask. * * @var array */ protected $masked = [];
Usage
To mask your data, run the php artisan dbm:mask command. This will loop through all your Eloquent models, looking for
the $masked property.
-
If the
$maskedproperty is null or the empty set, that model will be skipped. -
If the
$maskedproperty is missing, that model will be flagged with a warning. -
If the
$maskedproperty is not empty, but no Factory has been created for that model, an error is returned.
But if the $masked property contains field names, and a Factory has been created, then
the fields in the $masked property will be replaced with Faker values. All other fields will be left untouched.
Backup and Restore
This package also contains light wrappers around Spatie's excellent laravel-db-snapshots package, to make backups and restores even easier.
To use these commands you will first need to install laravel-db-snapshots
as per their installation instructions.
Then, run php artisan dbm:backup to create a backup file of your database on your snapshots disk.
Run php artisan dbm:restore to choose a backup file and restore it to your current enviroment.
Generally, you'll want to backup from your Production enviornment, and restore to some other environment, and then mask that data in the other environment.
You do not need to install laravel-db-snapshots if you only want to use the dbm:mask command.
Testing DatabaseMask
TODO: write some tests.
Disclaimer
I cannot, and do not, guarantee that using DatabaseMask will make your data 100% de-identified.
I can and will make a good-faith effort to ensure that, when configured correctly, DatabaseMask will remove personally idendifiable information from your data.
However I cannot guarantee that this software is 100% bug-free, and I certainly can't guarantee that you have configured it correctly. So use this software at your own risk.
License
This package is open-sourced software licensed under the MIT license.
brendantwhite/databasemask 适用场景与选型建议
brendantwhite/databasemask 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 10 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「laravel」 「obfuscation」 「privacy」 「Masking」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 brendantwhite/databasemask 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 brendantwhite/databasemask 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 brendantwhite/databasemask 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Simple captcha generator
Store your language lines in the database, yaml or other sources
AMWSCAN (Antimalware Scanner) is a php antimalware/antivirus scanner console script written in php for scan your project. This can work on php projects and a lot of others platform.
Laravel package for obfuscating ids in urls.
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
统计信息
- 总下载量: 35
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-31