Documentation
¶
Overview ¶
Package check implements the check registry and individual site audit checks.
Index ¶
- func FingerprintPage(body string) *pageFingerprint
- func GenerateProbeURL(pageURL string) string
- func GetSoft404Detection(check *LinksCheck) bool
- func IsSoft404(currentPage, notFoundPage *pageFingerprint) bool
- func SetSoft404Detector(check *LinksCheck, d *Soft404Detector)
- func WithSoft404Detection(check *LinksCheck, enabled bool)
- type A11yAdvancedCheck
- type A11yCheck
- type AIReadyCheck
- type Checker
- type Finding
- type FormsCheck
- type LinksCheck
- type PerfCheck
- type ReachabilityCheck
- type Registry
- type SEOCheck
- type SRICheck
- type SecurityCheck
- type Severity
- type Soft404Detector
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
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.
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
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.
type FormsCheck ¶
type FormsCheck struct{}
FormsCheck detects form-related issues: missing actions, CSRF tokens, method problems.
func (*FormsCheck) Name ¶
func (f *FormsCheck) Name() string
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
type PerfCheck ¶
type PerfCheck struct{}
PerfCheck detects performance issues: large resources, render-blocking scripts, missing compression, excessive DOM size.
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
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.
type SEOCheck ¶
type SEOCheck struct{}
SEOCheck detects SEO issues: missing meta tags, duplicate titles, missing canonical URLs, and robots directives.
type SRICheck ¶
type SRICheck struct{}
SRICheck validates that cross-origin scripts and stylesheets have Subresource Integrity (SRI) attributes with strong hashes.
type SecurityCheck ¶
type SecurityCheck struct{}
SecurityCheck detects missing security headers, mixed content, and exposed secrets.
func (*SecurityCheck) Name ¶
func (s *SecurityCheck) Name() string
type 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).