yorcreative/laravel-scanator
Composer 安装命令:
composer require yorcreative/laravel-scanator
包简介
A Laravel package that provides functionalities for detecting sensitive information and patterns in the database, helping to ensure data privacy and security by empowering developers to easily integrate database scanning capabilities into their applications and take proactive measures to protect sen
关键字:
README 文档
README
Laravel Scanator
A Laravel package that provides functionalities for detecting sensitive information and patterns in the database, helping to ensure data privacy and security by empowering developers to easily integrate database scanning capabilities into their applications and take proactive measures to protect sensitive data.
Installation
install the package via composer:
composer require yorcreative/laravel-scanator
Publish the assets.
php artisan vendor:publish --provider="YorCreative\Scanator\ScanatorServiceProvider" php artisan vendor:publish --provider="YorCreative\Scanator\ScrubberServiceProvider"
Configuration
Adjusting the Scanators Configuration File
Adjust the configuration file to suite your application, located in /config/scanator.php.
return [ 'sql' => [ 'ignore_tables' => [ 'failed_jobs', 'migrations' ], 'ignore_columns' => [ 'id', 'created_at', 'updated_at' ], 'ignore_types' => [ 'timestamp' ], 'select' => [ 'low_limit' => 3, 'high_limit' => 10 ], ] ];
Adjusting the Scrubber Configuration File
Adjust the regex_loader field to suite your application, located in /config/scrubber.php.
For more information on the Scrubber configuration file, please see the source documentation here.
return [ ... 'regex_loader' => ['*'], // Opt-in to specific regex classes OR include all with * wildcard. ... ];
Usage
This package is shipped without implementation. It is shipped as a tool and up to developers to choose how they implement to suite to applications needs.
Detection Manager
The DetectionManager class is an essential component of the Laravel Scanator package. It manages and stores the Detections during the scanning process. It provides methods to record detections, retrieve the list of detections, and obtain the scan start time.
Full Database Scan
This package ships with the ability to analyze and build out database schema and then scans for sensitive information excluding any tables, columns or types from the Scanator configuration file finally to return the Detection Manager class.
$detectionManager = Scanator::init(); $detections = $detectionManager->getDetections();
Selective Database Scan
This package ships with the ability to selectively scan tables.
$detectionManager = new DetectionManager(); Scanator::analyze($detectionManager, 'table_name', ['columns', 'to', 'scan']); $detections = $detectionManager->getDetections();
Defining Excludable Tables
The configuration file of this package offers the functionality to define excludable tables, allowing you to exclude them from the scanning process.
'ignore_tables' => [ 'failed_jobs', 'migrations' ],
Defining Excludable Columns
Similarly, you can define excludable columns within the configuration file to prevent the package from scanning them.
'ignore_columns' => [ 'id', 'created_at', 'updated_at' ],
Defining Excludable Data Types
To further refine the scanning process, you can specify excludable data types in the configuration file. The package will then disregard these data types during scanning.
'ignore_types' => [ 'timestamp' ],
Defining Sample Size
For greater control over the scanning procedure, the configuration file allows you to define the sample size extracted from each table.
'select' => [ 'low_limit' => 3, 'high_limit' => 10 ],
Scrubber Documentation
This package builds on the RegexRepository provided by the scrubber package. For complete documentation on the scrubber, see here
Regex Class Opt-in
You have the ability through the scrubber configuration file to define what regex classes you want loaded into the application when it is bootstrapped. By default, this package ships with a wildcard value.
Regex Collection & Defining Opt-in
To opt in, utilize the static properties on the RegexCollection class.
'regex_loader' => [ RegexCollection::$GOOGLE_API, RegexCollection::$AUTHORIZATION_BEARER, RegexCollection::$CREDIT_CARD_AMERICAN_EXPRESS, RegexCollection::$CREDIT_CARD_DISCOVER, RegexCollection::$CREDIT_CARD_VISA, RegexCollection::$JSON_WEB_TOKEN ],
Creating Custom Extended Classes
The Scrubber package ships with a command to create custom extended classes and allows further refining of database scans for the Scanator.
php artisan make:regex-class {name}
This command will create a stubbed out class in App\Scrubber\RegexCollection. The Scrubber package will autoload
everything from the App\Scrubber\RegexCollection folder with the wildcard value on the regex_loader array in the
scrubber config file. You will need to provide a Regex Pattern and a Testable String for the class.
Opting Into Custom Extended Classes
The regex_loader array takes strings, not objects. To opt in to specific custom extended regex classes, define the
class name as a string.
For example if I have a custom extended class as such:
<?php namespace App\Scrubber\RegexCollection; use YorCreative\Scrubber\Interfaces\RegexCollectionInterface; class TestRegex implements RegexCollectionInterface { public function getPattern(): string { /** * @todo * @note return a regex pattern to detect a specific piece of sensitive data. */ return '(?<=basic) [a-zA-Z0-9=:\\+\/-]{5,100}'; } public function getTestableString(): string { /** * @todo * @note return a string that can be used to verify the regex pattern provided. */ return 'basic f9Iu+YwMiJEsQu/vBHlbUNZRkN/ihdB1sNTU'; } public function isSecret(): bool { return false; } }
The regex_loader array should be defined as such:
'regex_loader' => [ RegexCollection::$GOOGLE_API, RegexCollection::$AUTHORIZATION_BEARER, RegexCollection::$CREDIT_CARD_AMERICAN_EXPRESS, RegexCollection::$CREDIT_CARD_DISCOVER, RegexCollection::$CREDIT_CARD_VISA, RegexCollection::$JSON_WEB_TOKEN, 'TestRegex' ],
Testing
composer test
Credits
yorcreative/laravel-scanator 适用场景与选型建议
yorcreative/laravel-scanator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 36, 最近一次更新时间为 2023 年 06 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「security」 「laravel」 「developers」 「data protection」 「data privacy」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 yorcreative/laravel-scanator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yorcreative/laravel-scanator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 yorcreative/laravel-scanator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Provide a way to secure accesses to all routes of an symfony application.
It's a barebone security class written on PHP
Contao CMS integrity check for some files
A PHP security linter to detect insecure functions like var_dump, print_r, and other dangerous functions in your codebase
Alfabank REST API integration
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 36
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-27