zae/csp-reporting
Composer 安装命令:
composer require zae/csp-reporting
包简介
CSP Reporting
README 文档
README
Catch the policy violations your users generate and store them somewhere
Install
Via Composer
$ composer require zae/csp-reporting
Usage
Configure your csp reports to go to /csp-report.
Laravel
Publish the config file using artisan vendor:publish
#config/csp-report.php return [ 'persist' => [ 'class' => LogCspPersister::class, 'properties' => [ 'loglevel' => Psr\Log\LogLevel::INFO ] ], 'limiter' => [ 'class' => CspCacheLimiter::class, 'properties' => [ 'key' => 'csp-rate-limiter', 'maxAttempts' => 1, 'decay' => 60 ] ], ];
By default the plugin will store the violations in the log, but there is also a BugsnagPersister that
will send the violation to bugsnag.
Craft 3
Configure your application to use the Module with the right limiter and persister.
use Zae\ContentSecurityPolicyReporting\Contracts\CspLimiter; use Zae\ContentSecurityPolicyReporting\Contracts\CspPersistable; use Zae\ContentSecurityPolicyReporting\Limiters\CspLotteryLimiter; use Zae\ContentSecurityPolicyReporting\Persisters\BugsnagCspPersister; return [ 'bootstrap' => [ 'csp-reporting' ], 'components' => [ 'csp-reporting' => [ 'class' => \Zae\ContentSecurityPolicyReporting\Craft\Module::class, 'components' => [ CspPersistable::class => static function () { return new BugsnagCspPersister( \Bugsnag\Client::make(getenv('BUGSNAG_API_KEY')) ); }, CspLimiter::class => static function () { return new CspLotteryLimiter(5); } ] ], ] ]
On high traffic sites the violations might occur often and probably they will all be the same, so the limiter will make sure only a part of the violations will actually be stored.
The properties array will allow you to configurate the handlers.
You can also provide your own classes as long as they implement the right interfaces.
Provided Limiters
CspCacheLimiterCspLotteryLimiter
Provided Persisters
LogCspPersisterBugsnagCspPersister
Testing
$ composer run test
Contributing
Contributions are welcome via pull requests on github.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 2.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-26