Help us shape the future of Go! Take the 2026 Go Developer Survey

cspbuilder

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 4 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// Fetch Directives.
	ChildSrc      = "child-src"
	ConnectSrc    = "connect-src"
	DefaultSrc    = "default-src"
	FontSrc       = "font-src"
	FrameSrc      = "frame-src"
	ImgSrc        = "img-src"
	ManifestSrc   = "manifest-src"
	MediaSrc      = "media-src"
	ObjectSrc     = "object-src"
	PrefetchSrc   = "prefetch-src"
	ScriptSrc     = "script-src"
	ScriptSrcAttr = "script-src-attr"
	ScriptSrcElem = "script-src-elem"
	StyleSrc      = "style-src"
	StyleSrcAttr  = "style-src-attr"
	StyleSrcElem  = "style-src-elem"
	WorkerSrc     = "worker-src"

	// Document Directives.
	BaseURI = "base-uri"
	Sandbox = "sandbox"

	// Navigation directives.
	FormAction     = "form-action"
	FrameAncestors = "frame-ancestors"
	NavigateTo     = "navigate-to"

	// Reporting directives.
	ReportURI = "report-uri"
	ReportTo  = "report-to"

	// Other directives.
	RequireTrustedTypesFor  = "require-trusted-types-for"
	TrustedTypes            = "trusted-types"
	UpgradeInsecureRequests = "upgrade-insecure-requests"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	Directives map[string]([]string)
}

func (*Builder) Build

func (builder *Builder) Build() (string, error)

Build creates a content security policy string from the specified directives. If any directive contains invalid values, an error is returned instead.

func (*Builder) MustBuild

func (builder *Builder) MustBuild() string

MustBuild is like Build but panics if an error occurs.

Jump to

Keyboard shortcuts

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