Code Monkey home page Code Monkey logo

csp-report-listener's Introduction

logo

Metlo CSP Report Listener

Easily build your CSP


Prs Welcome Join Discord Server GitHub Workflow Status License


Building a good CSP is hard to do when you have tons of unknown scripts across your web apps. The easiest way to incrementally build your CSP using the report-uri directive and listen for anything that breaks in report only mode. Our CSP Reporter makes this easy by storing all CSP report logs and displaying distinct reports you can add to your policy.

UI Screenshot

Checkout Metlo API Security for more complete API protection!

Setup

1. Install the Service

You can either use Docker or our Binary to install. You can configure the CSP Report listener with the following env vars:

  1. METLO_SECRET_KEY [required] - A secret key to view CSP Reports. Be sure to set this to something secure!
  2. METLO_DATA_PATH [default /tmp/metlo_csp/] - Where to store CSP Report data. By default we store it in a tmp folder so change this if you want your data to be persisted.
  3. METLO_PORT [default 8080] - The port the service will listen on
  4. METLO_LOG_LEVEL [default info] - Set the logging level to debug

Docker Setup

$ docker run -p 8080:8080 --env METLO_SECRET_KEY=<A_RANDOM_STRING> metlo/csp-service

Binary Setup

$ curl https://metlo-releases.s3.us-west-2.amazonaws.com/csp_service_linux_amd64_latest > metlo_csp_service
$ chmod +x metlo_csp_service
$ METLO_SECRET_KEY=<A_RANDOM_STRING> ./metlo_csp_service

Be sure to deploy this service behind a public endpoint so your site can send reports to it. Ping us on discord if you have any questions!

2. Configure Headers

Add the following directive to your CSP Header:

report-uri <METLO_CSP_SERVICE_DOMAIN>

For example your CSP Header might look like this:

Content-Security-Policy: default-src 'self'; script-src https://example.com; report-uri <METLO_CSP_SERVICE_DOMAIN>

If you only want to report violations use the following:

Content-Security-Policy-Report-Only: report-uri <METLO_CSP_SERVICE_DOMAIN>;

csp-report-listener's People

Contributors

akshay288 avatar

Stargazers

Ahren Stevens-Taylor avatar Huub avatar hanke avatar %23D0n9 avatar  avatar cocoonk1d avatar Andrzej Dyjak avatar Israel de la Torre avatar Suri avatar Alexandre Bouijoux avatar Nicolas Vincent avatar guly avatar  avatar  avatar Royce Williams avatar Alexander avatar Nath P. avatar Adrian Bjugård avatar Dan Rubins avatar  avatar Martin avatar xrkk avatar Gutem avatar Ryota Sakai avatar Filipe Oliveira avatar Brad Roether avatar  avatar Samrose avatar Shaeq Ahmed avatar Jagath Vytheeswaran avatar Ninad Sinha avatar Shridhar Sukhani avatar Vignesh Varadarajan avatar Nikhil Shahi avatar  avatar

Watchers

 avatar

csp-report-listener's Issues

Requires insecure CSP

I am all for a certain level of irony, but I find it a bit odd that the interface requires an insecure CSP:

default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' cdnjs.cloudflare.com; style-src 'self' 'unsafe-inline' unpkg.com; report-to 'self' csp.0x6d70.de;

While sure, the risk in this case is likely manageable, I find it less than ideal to require unsafe-inline and unsafe-eval as a script-src. I would also use this moment to suggest serving the assets locally as to make the CSP more concise. I would've loved to use the application to debug the applications CSP though. That would've been awesome.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.