check

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package check implements the check registry and individual site audit checks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FingerprintPage added in v0.1.1

func FingerprintPage(body string) *pageFingerprint

FingerprintPage extracts a structural signature from an HTML page body. It records the title, first h1, total word count, and number of links.

func GenerateProbeURL added in v0.1.1

func GenerateProbeURL(pageURL string) string

GenerateProbeURL creates a random non-existent URL on the same host as the given page. The path is constructed from random hex segments so it is unlikely to collide with any real page.

func GetSoft404Detection added in v0.1.1

func GetSoft404Detection(check *LinksCheck) bool

GetSoft404Detection returns the soft 404 detection setting (used in tests).

func IsSoft404 added in v0.1.1

func IsSoft404(currentPage, notFoundPage *pageFingerprint) bool

IsSoft404 compares the fingerprint of a page suspected to be a soft 404 against a known soft-404 fingerprint from the same host. Returns true when the fingerprints are close enough to indicate the page is not actually serving real content.

func SetSoft404Detector added in v0.1.1

func SetSoft404Detector(check *LinksCheck, d *Soft404Detector)

SetSoft404Detector sets the detector (used in tests to inject a pre-configured detector).

func WithSoft404Detection added in v0.1.1

func WithSoft404Detection(check *LinksCheck, enabled bool)

WithSoft404Detection enables or disables soft 404 false-positive detection on a LinksCheck. When enabled, 200 OK external links are probed to detect pages that return 200 for non-existent URLs.

Types

type A11yAdvancedCheck

type A11yAdvancedCheck struct{}

A11yAdvancedCheck implements WCAG 2.1/2.2 rules beyond basics: ARIA validation, focus management, landmark completeness, color contrast hints.

type A11yCheck

type A11yCheck struct{}

A11yCheck detects accessibility violations: missing alt text, ARIA issues, heading hierarchy problems, and missing landmarks.

func (*A11yCheck) Name

func (a *A11yCheck) Name() string

func (*A11yCheck) Run

func (a *A11yCheck) Run(ctx context.Context, pages []*crawler.Page) []Finding

type AIReadyCheck

type AIReadyCheck struct{}

AIReadyCheck verifies that a site is AI-agent-friendly by checking for emerging standards and best practices that help LLMs and AI agents understand and navigate the site effectively.

Checks performed:

  • /llms.txt endpoint (emerging standard for LLM-readable site descriptions)
  • <link rel="alternate" type="text/markdown"> for markdown alternatives
  • Structured data (JSON-LD, microdata)
  • Clean semantic HTML (proper heading hierarchy, landmarks)
  • Sitemap.xml accessibility

func (*AIReadyCheck) Name

func (a *AIReadyCheck) Name() string

func (*AIReadyCheck) Run

func (a *AIReadyCheck) Run(ctx context.Context, pages []*crawler.Page) []Finding

type Checker

type Checker interface {
	Name() string
	Run(ctx context.Context, pages []*crawler.Page) []Finding
}

Checker is the interface that all checks implement.

type Finding

type Finding struct {
	Severity Severity
	URL      string
	Element  string
	Message  string
	Fix      string
	Evidence string
}

Finding is an internal finding produced by a check.

func RunAdvancedA11y

func RunAdvancedA11y(ctx context.Context, pages []*crawler.Page) []Finding

RunAdvancedA11y runs the advanced accessibility checks on a set of pages. This is called by the A11yCheck.Run as an extension.

type FormsCheck

type FormsCheck struct{}

FormsCheck detects form-related issues: missing actions, CSRF tokens, method problems.

func (*FormsCheck) Name

func (f *FormsCheck) Name() string

func (*FormsCheck) Run

func (f *FormsCheck) Run(ctx context.Context, pages []*crawler.Page) []Finding

type LinksCheck

type LinksCheck struct {
	// AcceptedStatusCodes is the set of HTTP status codes considered acceptable.
	// If empty, defaults to 200-399.
	AcceptedStatusCodes []int

	// Soft404Detection enables detection of pages that return HTTP 200 for
	// non-existent URLs (soft 404s). When enabled, 200 OK external links are
	// probed to determine if the server is returning real content.
	Soft404Detection bool
	// contains filtered or unexported fields
}

LinksCheck detects broken links, redirect chains, and dead anchors.

func (*LinksCheck) Name

func (l *LinksCheck) Name() string

func (*LinksCheck) Run

func (l *LinksCheck) Run(ctx context.Context, pages []*crawler.Page) []Finding

type PerfCheck

type PerfCheck struct{}

PerfCheck detects performance issues: large resources, render-blocking scripts, missing compression, excessive DOM size.

func (*PerfCheck) Name

func (p *PerfCheck) Name() string

func (*PerfCheck) Run

func (p *PerfCheck) Run(ctx context.Context, pages []*crawler.Page) []Finding

type ReachabilityCheck added in v0.1.1

type ReachabilityCheck struct{}

ReachabilityCheck verifies that embedded resources (images, scripts, stylesheets, fonts, media) referenced in HTML are actually reachable.

func (*ReachabilityCheck) Name added in v0.1.1

func (r *ReachabilityCheck) Name() string

func (*ReachabilityCheck) Run added in v0.1.1

func (r *ReachabilityCheck) Run(ctx context.Context, pages []*crawler.Page) []Finding

type Registry

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

Registry holds all registered checks.

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry returns a registry with all built-in checks.

func (*Registry) All

func (r *Registry) All() []Checker

All returns every registered check.

func (*Registry) Filter

func (r *Registry) Filter(enabled []string) []Checker

Filter returns only the checks whose names appear in the enabled list.

func (*Registry) Register

func (r *Registry) Register(c Checker)

Register adds a check to the registry.

type SEOCheck

type SEOCheck struct{}

SEOCheck detects SEO issues: missing meta tags, duplicate titles, missing canonical URLs, and robots directives.

func (*SEOCheck) Name

func (s *SEOCheck) Name() string

func (*SEOCheck) Run

func (s *SEOCheck) Run(ctx context.Context, pages []*crawler.Page) []Finding

type SRICheck

type SRICheck struct{}

SRICheck validates that cross-origin scripts and stylesheets have Subresource Integrity (SRI) attributes with strong hashes.

func (*SRICheck) Name

func (s *SRICheck) Name() string

func (*SRICheck) Run

func (s *SRICheck) Run(ctx context.Context, pages []*crawler.Page) []Finding

type SecurityCheck

type SecurityCheck struct{}

SecurityCheck detects missing security headers, mixed content, and exposed secrets.

func (*SecurityCheck) Name

func (s *SecurityCheck) Name() string

func (*SecurityCheck) Run

func (s *SecurityCheck) Run(ctx context.Context, pages []*crawler.Page) []Finding

type Severity

type Severity = types.Severity

Severity mirrors the public Severity type for internal use.

const (
	SeverityInfo     Severity = types.SeverityInfo
	SeverityLow      Severity = types.SeverityLow
	SeverityMedium   Severity = types.SeverityMedium
	SeverityHigh     Severity = types.SeverityHigh
	SeverityCritical Severity = types.SeverityCritical
)

type Soft404Detector added in v0.1.1

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

Soft404Detector detects servers that return 200 OK for non-existent pages (so-called "soft 404s") by probing random nonexistent URLs on each host and comparing the resulting page fingerprints.

func GetSoft404Detector added in v0.1.1

func GetSoft404Detector(check *LinksCheck) *Soft404Detector

GetSoft404Detector returns the detector (used in tests).

func NewSoft404Detector added in v0.1.1

func NewSoft404Detector() *Soft404Detector

NewSoft404Detector creates a new detector with an empty cache.

func (*Soft404Detector) Detect added in v0.1.1

func (d *Soft404Detector) Detect(ctx context.Context, client *http.Client, page *crawler.Page) (bool, error)

Detect fetches a random non-existent URL on the same host as the given page and compares the returned fingerprint to the current page's fingerprint. Returns true if the current page appears to be a soft 404.

func (*Soft404Detector) GetSoft404Cache added in v0.1.1

func (d *Soft404Detector) GetSoft404Cache() map[string]*pageFingerprint

GetSoft404Cache returns the internal cache (used in tests).

func (*Soft404Detector) SetSoft404Cache added in v0.1.1

func (d *Soft404Detector) SetSoft404Cache(c map[string]*pageFingerprint)

SetSoft404Cache replaces the internal cache (used in tests).

Jump to

Keyboard shortcuts

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