preloadlist

package
v0.0.0-...-8b52744 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 12 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// Domains with an unspecified policy type.
	UnspecifiedPolicyType = ""
	// Test domains.
	Test PolicyType = "test"
	// Google-owned sites.
	Google = "google"
	// Entries without includeSubdomains or with HPKP.
	Custom = "custom"
	// Bulk entries preloaded before Chrome 50.
	BulkLegacy = "bulk-legacy"
	// Bulk entries with max-age >= 18 weeks (Chrome 50-63).
	Bulk18Weeks = "bulk-18-weeks"
	// Bulk entries with max-age >= 1 year (after Chrome 63).
	Bulk1Year = "bulk-1-year"
	// Public suffixes (e.g. TLDs or other public suffix list entries) preloaded at the owner's request.
	PublicSuffix = "public-suffix"
	// Domains under a public suffix that have been preloaded at the request of the the public suffix owner
	// (e.g. the registry for the TLD).
	PublicSuffixRequested = "public-suffix-requested"
)

Possible PolicyType values are as defined by https://source.chromium.org/chromium/chromium/src/+/main:net/http/transport_security_state_static.json

View Source
const (
	// ForceHTTPS indicates that all requests should be upgraded from HTTP to
	// HTTPS using the HSTS mechanism (https://tools.ietf.org/html/rfc6797).
	ForceHTTPS = "force-https"
)
View Source
const (
	// LatestChromiumURL is the URL of the latest preload list in the Chromium source.
	LatestChromiumURL = "https://chromium.googlesource.com/chromium/src/+/main/net/http/transport_security_state_static.json?format=TEXT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Name              string     `json:"name"`
	Mode              string     `json:"mode"`
	IncludeSubDomains bool       `json:"include_subdomains"`
	Policy            PolicyType `json:"policy"`
}

A Entry contains the data from an entry in the Chromium Preload list.

- Name: The domain name.

- Mode: The only valid non-empty value is ForceHTTPS

  • IncludeSubDomains: If Mode == ForceHTTPS, forces HSTS to apply to all subdomains.
  • Policy: The policy that was enforced when the the domain was added to the preload list. Will be used to filter lists for automated removal from preload list as domains under different policies may adhere to different dynamic hsts requirements.

type HstsPreloadEntryFound

type HstsPreloadEntryFound int

HstsPreloadEntryFound indicates if a domain is preloaded.

A domain can be preloaded by virtue of itself being on the preload list, or by having one of its ancestor domains on the list and having "include_subdomains" set to true on that ancestor domain.

const (
	// EntryNotFound indicates that domain not preloaded.
	EntryNotFound HstsPreloadEntryFound = iota
	// ExactEntryFound indicates that the domain itself is on the preload list.
	ExactEntryFound
	// AncestorEntryFound indicates that the domain is preloaded
	// because one of its ancestor domains is on the preload list and has
	// "include_subdomains" set to true.
	AncestorEntryFound
)

type IndexedEntries

type IndexedEntries struct {
	// contains filtered or unexported fields
}

IndexedEntries is case-insensitive index of the entries from the given PreloadList.

func (IndexedEntries) Get

func (idx IndexedEntries) Get(domain string) (Entry, HstsPreloadEntryFound)

Get returns an entry from the index preload list along with a status indicating how the entry is found. If the domain itself is on the preload list, its entry is returned. If one of its ancestor domains with "include_subdomains" set to true is on the list, the closest such ancestor entry is returned. Failing all that, a zero-value entry is returned.

type PolicyType

type PolicyType string

PolicyType represents the policy under which the domain was added to the preload list.

type PreloadList

type PreloadList struct {
	Entries []Entry `json:"entries"`
}

PreloadList contains a parsed form of the Chromium Preload list.

The full list contains information about more than just HSTS, but only HSTS-related contents are currently exposed in this struct.

func NewFromChromiumURL

func NewFromChromiumURL(u string) (PreloadList, error)

NewFromChromiumURL retrieves the PreloadList from a URL that returns the list in base 64.

func NewFromFile

func NewFromFile(fileName string) (PreloadList, error)

NewFromFile reads a PreloadList from a JSON file.

In a Chromium checkout, the file is at src/net/http/transport_security_state_static.json

func NewFromLatest

func NewFromLatest() (PreloadList, error)

NewFromLatest retrieves the latest PreloadList from the Chromium source at https://chromium.googlesource.com/chromium/src/+/master/net/http/transport_security_state_static.json

Note that this list may be up to 12 weeks fresher than the list used by the current stable version of Chrome. See https://www.chromium.org/developers/calendar for a calendar of releases.

func Parse

func Parse(r io.Reader) (PreloadList, error)

Parse reads a preload list in JSON format (with certain possible comments) and returns a parsed version.

func (PreloadList) Index

func (p PreloadList) Index() (idx IndexedEntries)

Index creates an index out of the given list.

Jump to

Keyboard shortcuts

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