csp

package
v2.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package csp captures browser security reports: Content Security Policy violations (report-uri, application/csp-report) and Reporting API reports (report-to, application/reports+json: csp-violation, deprecation, intervention, crash, ...). Point a policy at http://<buggregator>/csp or /csp/<project>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	module.BaseModule
}

Module is the CSP / Reporting API catcher.

func New

func New() *Module

New returns the module.

func (*Module) HTTPHandler

func (m *Module) HTTPHandler() module.HTTPIngestionHandler

func (*Module) Name

func (m *Module) Name() string

func (*Module) PreviewMapper

func (m *Module) PreviewMapper() event.PreviewMapper

func (*Module) Type

func (m *Module) Type() string

type Payload

type Payload struct {
	Format  string   `json:"format"` // csp-report or reports+json
	Reports []Report `json:"reports"`
}

Payload is the stored event: one request's reports.

type Report

type Report struct {
	// Type: csp-violation for CSP (both formats), else the Reporting API
	// type (deprecation, intervention, crash, network-error, ...).
	Type      string `json:"type"`
	URL       string `json:"url"` // the page that reported
	UserAgent string `json:"user_agent,omitempty"`
	// CSP violations.
	Directive   string `json:"directive,omitempty"` // effective directive: script-src-elem
	Blocked     string `json:"blocked,omitempty"`   // blocked URL, or inline / eval
	Disposition string `json:"disposition,omitempty"`
	SourceFile  string `json:"source_file,omitempty"`
	Line        int    `json:"line,omitempty"`
	Column      int    `json:"column,omitempty"`
	Sample      string `json:"sample,omitempty"`
	Policy      string `json:"policy,omitempty"`
	// Other report types: the message and id (deprecation, intervention).
	Message string `json:"message,omitempty"`
	ID      string `json:"id,omitempty"`
	// Body is the report as the browser sent it.
	Body json.RawMessage `json:"body"`
}

Report is one report, the same shape for both formats.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL