2017 © Pedro Peláez
 

symfony-bundle csp-logger-bundle

A Symfony Bundle that can collect reports from CSP

image

sockam/csp-logger-bundle

A Symfony Bundle that can collect reports from CSP

  • Saturday, February 4, 2017
  • by vamsiikrishna
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Intro to SockamCSPLoggerBundle

SensioLabsInsight StyleCI Scrutinizer Code Quality, (*1)

The SockamCSPLoggerBundle provides a basic service for logging content security policy violations., (*2)

Features

  • Saving CSP violations
  • Viewing the saves CSP violations

Installation

Get the bundle

Add sockam/csp-logger-bundle to your dependencies:, (*3)

``` json { "require": { ... "sockam/csp-logger-bundle": "^0.2.0" } ... }, (*4)


To install, run `php composer.phar [update|install]`. ### Add CSPLoggerBundle to your application kernel ``` php <?php // app/AppKernel.php public function registerBundles() { return array( // ... new Sockam\CSPLoggerBundle\SockamCSPLoggerBundle(), // ... ); }

Import the routing configuration

Add to your routing.yml:, (*5)

``` yml, (*6)

app/config/routing.yml

sockam_csp_logger: resource: "@SockamCSPLoggerBundle/Resources/config/routing.yml" prefix: /csp, (*7)


You can customize the prefix as you wish. ### Update your database schema: ``` shell $ php bin/console doctrine:schema:update --force

You can now use /csp/log endpoint in your CSP headers: You can now access the dashboard at this url: /csp/logs, (*8)

To secure the CSP violations viewer, you can add the following to your security.yml - provided your administrator role is ROLE_ADMIN, (*9)

    access_control:
        - { path: ^/csp/logs, roles: ROLE_ADMIN }

Now only users with the role ROLE_ADMIN will be able to access the CSP violations viewer at this url: /csp/logs, (*10)

Screenshots

Violations viewer

CSP Violations Log Viewer, (*11)

The Versions