承接 zae/csp-reporting 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zae/csp-reporting

Composer 安装命令:

composer require zae/csp-reporting

包简介

CSP Reporting

README 文档

README

Latest Version Software License Total Downloads

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

  • CspCacheLimiter
  • CspLotteryLimiter

Provided Persisters

  • LogCspPersister
  • BugsnagCspPersister

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

GitHub 信息

  • Stars: 2
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固