All Projects → jacobbednarz → go-csp-collector

jacobbednarz / go-csp-collector

Licence: MIT license
A CSP collector written in Golang

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
Mustache
554 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to go-csp-collector

nuxt-security
Module for Nuxt.js to configure security headers and more
Stars: ✭ 46 (-37.84%)
Mutual labels:  csp, content-security-policy
gatsby-plugin-csp
A Gatsby plugin which adds strict Content Security Policy to your project.
Stars: ✭ 40 (-45.95%)
Mutual labels:  csp, content-security-policy
Secure headers
Manages application of security headers with many safe defaults
Stars: ✭ 2,942 (+3875.68%)
Mutual labels:  csp, content-security-policy
So 5 5
SObjectizer: it's all about in-process message dispatching!
Stars: ✭ 87 (+17.57%)
Mutual labels:  csp
Securityheaders
Check any website (or set of websites) for insecure security headers.
Stars: ✭ 104 (+40.54%)
Mutual labels:  csp
Chymyst Core
Declarative concurrency in Scala - The implementation of the chemical machine
Stars: ✭ 142 (+91.89%)
Mutual labels:  csp
AspNetCore6Experiments
ASP.NET Core Blazor BFF with Azure AD and Razor page
Stars: ✭ 43 (-41.89%)
Mutual labels:  csp
Libcsp
A concurrency C library 10x faster than Golang.
Stars: ✭ 1,160 (+1467.57%)
Mutual labels:  csp
Javasecurity
Java web and command line applications demonstrating various security topics
Stars: ✭ 182 (+145.95%)
Mutual labels:  csp
Archer
基于协程Swoole的Task组件,支持多种模式。轻松实现协程Task的队列、并发、Defer、计时器等 | Swoole coroutine task kit - Swoole Humanization Library
Stars: ✭ 132 (+78.38%)
Mutual labels:  csp
Csp Bypass
A Burp Plugin for Detecting Weaknesses in Content Security Policies
Stars: ✭ 130 (+75.68%)
Mutual labels:  csp
Csp Html Webpack Plugin
A plugin which, when combined with HTMLWebpackPlugin, adds CSP tags to the HTML output.
Stars: ✭ 109 (+47.3%)
Mutual labels:  csp
Content Security Policy.com
Source code for the content-security-policy.com website
Stars: ✭ 148 (+100%)
Mutual labels:  csp
Csp
Given a list of hosts, this small utility fetches all whitelisted domains from the hosts' CSPs.
Stars: ✭ 89 (+20.27%)
Mutual labels:  csp
Csp
The source for this module has moved to the Helmet repository.
Stars: ✭ 225 (+204.05%)
Mutual labels:  csp
Chan
Pure C implementation of Go channels.
Stars: ✭ 1,208 (+1532.43%)
Mutual labels:  csp
Sobjectizer
An implementation of Actor, Publish-Subscribe, and CSP models in one rather small C++ framework. With performance, quality, and stability proved by years in the production.
Stars: ✭ 172 (+132.43%)
Mutual labels:  csp
Csp Auditor
Burp and ZAP plugin to analyse Content-Security-Policy headers or generate template CSP configuration from crawling a Website
Stars: ✭ 121 (+63.51%)
Mutual labels:  csp
Venice
Coroutines, structured concurrency and CSP for Swift on macOS and Linux.
Stars: ✭ 1,501 (+1928.38%)
Mutual labels:  csp
Asynquence
Asynchronous flow control (promises, generators, observables, CSP, etc)
Stars: ✭ 1,737 (+2247.3%)
Mutual labels:  csp

This is a content security policy violation collector written in Golang.

It has been designed to listen on port 8080 and accept POST payloads containing the violation report. It captures the report and will write it to STDOUT via Go's logger.

A neat little feature of this tool is that it automatically ignores unactionable reports. Check out the default list if you're interested.

Installation

$ go get github.com/jacobbednarz/go-csp-collector

Alternatively, you can download the binaries from the release page.

Running

$ go build main.go -p csp-collector
$ ./csp-collector

Endpoints

  • POST /: accepts a CSP violation report (recommended to use /csp for future proofing though).
  • POST /csp: accepts a CSP violation report.
  • POST /csp/report-only: same as /csp but appends a report-only attribute to the log line. Helpful if you have enforced and report only violations and wish to separate them.

Building for Docker

You will either need to build within a docker container for the purpose, or use CGO_ENABLED=0 flag to make the build compatible with alpine linux in a docker container.

$ CGO_ENABLED=0 go build main.go -p csp-collector

Command Line Options

Flag Description
version Shows the version string before exiting
debug Runs in debug mode producing more verbose output
port Port to run on, default 8080
filter-file Reads the blocked URI filter list from the specified file. Note one filter per line
health-check-path Sets path for health checkers to use, default /_healthcheck
log-client-ip Include a field in the log with the IP delivering the report, or the value of the X-Forwarded-For header, if present.
log-truncated-client-ip Include a field in the log with the truncated IP (to /24 for IPv4, /64 for IPv6) delivering the report, or the value of the X-Forwarded-For header, if present. Conflicts with log-client-ip.
truncate-query-fragment Remove all query strings and fragments (if set) from all URLs transmitted by the client
query-params-metadata Log all query parameters of the report URL as a map in the metadata field

See the sample.filterlist.txt file as an example of the filter list in a file

Request metadata

Additional information can be attached to each report by adding a metadata url parameter to each report. That value will be copied verbatim into the logged report.

For example a report sent to https://collector.example.com/?metadata=foobar will include field metadata with value foobar.

If query-params-metadata is set, instead all query parameters are logged as a map, e.g. https://collector.example.com/?env=production&mode=enforce will result in "metadata": {"env": "production", "mode": "enforce"} in JSON format, and metadata="map[env:production mode:enforce]" in default format.

report-only mode

If you'd like to recieve report only violations on a different URL

Output formats

The output format can be controlled by passing --output-format <type> to the executable. Available formats are:

  • Text: A key/value output that quotes all the values. Example: blocked_uri="about:blank" ...
  • JSON: Single line, compressed JSON object. Example: {"blocked_uri":"about:blank"}

The default formatter is text.

Writing to a file instead of just STDOUT

If you'd rather have these violations end up in a file, I suggest just redirecting the output into a file like so:

$ ./csp-collector 2>> /path/to/violations.log

Visualisation

This project purposely doesn't try to solve the problem of visualing the violation data because there are already a bunch of great solutions out there. Once you have your violations being collected, be sure to slurp them into your favourite log aggregation tool.

Deployments

Currently supported deployment mechanisms:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].