Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

feat: ingest seaportal results and route enrichment via browserRecommended

Luigi Agostie1c0f543d853
diff --git a/cmd/pinchtab/cmd_audit.go b/cmd/pinchtab/cmd_audit.go
index b030db50..64c35579 100644
--- a/cmd/pinchtab/cmd_audit.go
+++ b/cmd/pinchtab/cmd_audit.go
@@ -6,23 +6,35 @@ import (
)
var auditCmd = &cobra.Command{
- Use: "audit <url>",
+ Use: "audit [url]",
Short: "Run a browser-level site audit",
Long: `Audit one or more pages with full browser enrichment: screenshots,
console logs, network requests and broken assets, interactive elements,
accessibility score, and timing metrics.
The argument is a page URL, or a sitemap URL with --sitemap (pages are then
-discovered from it). With --output-dir the report is written to
-<dir>/report.json and screenshots to <dir>/screenshots/; --json prints the
-full report to stdout.
+discovered from it). With --seaportal-report the pages come from a SeaPortal
+results JSON file instead, and only pages SeaPortal marked browserRecommended
+are browser-enriched (the rest keep their HTTP-extraction summary); pass
+--enrich-all to browser-enrich every page. With --output-dir the report is
+written to <dir>/report.json and screenshots to <dir>/screenshots/; --json
+prints the full report to stdout.
Pages that fail to load do not fail the run: the command still exits 0 and
the failing page's report entry carries an "error" field.`,
- Args: cobra.ExactArgs(1),
+ Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
+ seaportalReport, _ := cmd.Flags().GetString("seaportal-report")
+ if len(args) == 0 && seaportalReport == "" {
+ cmd.PrintErrln("audit needs a URL argument or --seaportal-report")
+ return
+ }
+ target := ""
+ if len(args) > 0 {
+ target = args[0]
+ }
runCLI(func(rt cliRuntime) {
- browseractions.Audit(rt.client, rt.base, rt.token, cmd, args[0])
+ browseractions.Audit(rt.client, rt.base, rt.token, cmd, target)
})
},
}
diff --git a/cmd/pinchtab/cmd_cli_register.go b/cmd/pinchtab/cmd_cli_register.go
index a519bdfc..3fbb0523 100644
--- a/cmd/pinchtab/cmd_cli_register.go
+++ b/cmd/pinchtab/cmd_cli_register.go
@@ -362,6 +362,8 @@ func configureBrowserFlags() {
auditCmd.Flags().String("output-dir", "", "Write report.json and screenshots/ to this directory")
auditCmd.Flags().Int("concurrency", 0, "Pages audited in parallel (default 2, max 8)")
auditCmd.Flags().Bool("json", false, "Print the full report JSON to stdout")
+ auditCmd.Flags().String("seaportal-report", "", "Audit pages from a SeaPortal results JSON file (array of Result objects)")
+ auditCmd.Flags().Bool("enrich-all", false, "Browser-enrich every seaportal page, ignoring browserRecommended routing")
addTabFlag(consoleCmd, errorsCmd)
}
diff --git a/go.mod b/go.mod
index b121e3bb..c4db3047 100644
--- a/go.mod
+++ b/go.mod
@@ -9,6 +9,7 @@ require (
github.com/gost-dom/browser v0.11.0
github.com/mark3labs/mcp-go v0.49.0
github.com/pinchtab/idpishield v0.1.4
+ github.com/pinchtab/seaportal v0.1.1
github.com/pinchtab/semantic v0.1.3
github.com/shirou/gopsutil/v4 v4.26.3
github.com/spf13/cobra v1.10.2
@@ -18,24 +19,36 @@ require (
)
require (
+ github.com/JohannesKaufmann/dom v0.2.0 // indirect
+ github.com/JohannesKaufmann/html-to-markdown/v2 v2.5.0 // indirect
+ github.com/andybalholm/brotli v1.2.0 // indirect
+ github.com/andybalholm/cascadia v1.3.3 // indirect
+ github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
github.com/chromedp/sysutil v1.1.0 // indirect
github.com/ebitengine/purego v0.10.0 // indirect
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
+ github.com/go-shiori/dom v0.0.0-20230515143342-73569d674e1c // indirect
+ github.com/go-shiori/go-readability v0.0.0-20251205110129-5db1dc9836f0 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
+ github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f // indirect
github.com/google/jsonschema-go v0.4.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gost-dom/css v0.1.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
+ github.com/klauspost/compress v1.18.6 // indirect
+ github.com/ledongthuc/pdf v0.0.0-20250511090121-5959a4027728 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
+ github.com/refraction-networking/utls v1.8.2 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.9 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
+ golang.org/x/crypto v0.51.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
)
diff --git a/go.sum b/go.sum
index 3a6f8efe..fd69fd01 100644
--- a/go.sum
+++ b/go.sum
@@ -1,3 +1,13 @@
+github.com/JohannesKaufmann/dom v0.2.0 h1:1bragmEb19K8lHAqgFgqCpiPCFEZMTXzOIEjuxkUfLQ=
+github.com/JohannesKaufmann/dom v0.2.0/go.mod h1:57iSUl5RKric4bUkgos4zu6Xt5LMHUnw3TF1l5CbGZo=
+github.com/JohannesKaufmann/html-to-markdown/v2 v2.5.0 h1:mklaPbT4f/EiDr1Q+zPrEt9lgKAkVrIBtWf33d9GpVA=
+github.com/JohannesKaufmann/html-to-markdown/v2 v2.5.0/go.mod h1:D56Cl9r8M5i3UwAchE+LlLc5hPN3kJtdZNVJn06lSHU=
+github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
+github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
+github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
+github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
+github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhPwqqXc4/vE0f7GvRjuAsbW+HOIe8KnA=
+github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw=
github.com/chromedp/cdproto v0.0.0-20260405000525-47a8ff65b46a h1:Kk4P1W58eAf+OUGtx51cM7CcJokJuBEmOxxwPdHFH4Q=
github.com/chromedp/cdproto v0.0.0-20260405000525-47a8ff65b46a/go.mod h1:cbyjALe67vDvlvdiG9369P8w5U2w6IshwtyD2f2Tvag=
github.com/chromedp/chromedp v0.15.1 h1:EJWiPm7BNqDqjYy6U0lTSL5wNH+iNt9GjC3a4gfjNyQ=
@@ -5,6 +15,7 @@ github.com/chromedp/chromedp v0.15.1/go.mod h1:CdTHtUqD/dqaFw/cvFWtTydoEQS44wLBu
github.com/chromedp/sysutil v1.1.0 h1:PUFNv5EcprjqXZD9nJb9b/c9ibAbxiYo4exNWZyipwM=
github.com/chromedp/sysutil v1.1.0/go.mod h1:WiThHUdltqCNKGc4gaU50XgYjwjYIhKWoHGPTUfWTJ8=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ebitengine/purego v0.10.0 h1:QIw4xfpWT6GWTzaW5XEKy3HXoqrJGx1ijYHzTF0/ISU=
@@ -15,13 +26,20 @@ github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 h1:vymEbVw
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
+github.com/go-shiori/dom v0.0.0-20230515143342-73569d674e1c h1:wpkoddUomPfHiOziHZixGO5ZBS73cKqVzZipfrLmO1w=
+github.com/go-shiori/dom v0.0.0-20230515143342-73569d674e1c/go.mod h1:oVDCh3qjJMLVUSILBRwrm+Bc6RNXGZYtoh9xdvf1ffM=
+github.com/go-shiori/go-readability v0.0.0-20251205110129-5db1dc9836f0 h1:A3B75Yp163FAIf9nLlFMl4pwIj+T3uKxfI7mbvvY2Ls=
+github.com/go-shiori/go-readability v0.0.0-20251205110129-5db1dc9836f0/go.mod h1:suxK0Wpz4BM3/2+z1mnOVTIWHDiMCIOGoKDCRumSsk0=
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.4.0 h1:CTaoG1tojrh4ucGPcoJFiAQUAsEWekEWvLy7GsVNqGs=
github.com/gobwas/ws v1.4.0/go.mod h1:G3gNqMNtPppf5XUz7O4shetPpcZ1VJ7zt18dlUeakrc=
+github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f h1:3BSP1Tbs2djlpprl7wCLuiqMaUh5SJkkzI2gDs+FgLs=
+github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f/go.mod h1:Pcatq5tYkCW2Q6yrR2VRHlbHpZ/R4/7qyL1TCF7vl14=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8=
@@ -36,31 +54,44 @@ github.com/gost-dom/fixture v0.1.0 h1:7PnEpkuww1QBOh4gyoR8updPfyosHJfxmFRY+2t05+
github.com/gost-dom/fixture v0.1.0/go.mod h1:7mSGaBhOfi/NO+YiD426CQ1DTkko62vYxoSVRmveqqY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/klauspost/compress v1.18.6 h1:2jupLlAwFm95+YDR+NwD2MEfFO9d4z4Prjl1XXDjuao=
+github.com/klauspost/compress v1.18.6/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
-github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo=
-github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs=
+github.com/ledongthuc/pdf v0.0.0-20250511090121-5959a4027728 h1:QwWKgMY28TAXaDl+ExRDqGQltzXqN/xypdKP86niVn8=
+github.com/ledongthuc/pdf v0.0.0-20250511090121-5959a4027728/go.mod h1:1fEHWurg7pvf5SG6XNE5Q8UZmOwex51Mkx3SLhrW5B4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/mark3labs/mcp-go v0.49.0 h1:7Ssx4d7/T86qnWoJIdye7wEEvUzv39UIbnZb/FqUZMY=
github.com/mark3labs/mcp-go v0.49.0/go.mod h1:BflTAZAzXlrTpiO44gmjMu89n2FO56rJ9m31fp4zd5k=
+github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde h1:x0TT0RDC7UhAVbbWWBzr41ElhJx5tXPWkIHA2HWPRuw=
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
github.com/pinchtab/idpishield v0.1.4 h1:zuIofkQ6c9tzdrYsaNWA10w78OuMcgiBlsCOz4Zk34E=
github.com/pinchtab/idpishield v0.1.4/go.mod h1:i6MNCo1Y03KvpqblGAsGviox1WKpsn11gwOSeIlzYm0=
+github.com/pinchtab/seaportal v0.1.1 h1:Ved+O3ILv07mADGuMbNiPZLz+3nJRYea8xtqE3GMDcU=
+github.com/pinchtab/seaportal v0.1.1/go.mod h1:9YteZzZJ7CKIeVTrykOTK6ZKlryvK+ETifK6JgR7mwI=
github.com/pinchtab/semantic v0.1.3 h1:4nzJby6CZlqag5tfmeZux8mjB2xKgS4uWUi9GMtSqSM=
github.com/pinchtab/semantic v0.1.3/go.mod h1:SPKIra6m26faxTxn4dxa1ex1TbGkZDKbJ2r5rCngWoQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
+github.com/refraction-networking/utls v1.8.2 h1:j4Q1gJj0xngdeH+Ox/qND11aEfhpgoEvV+S9iJ2IdQo=
+github.com/refraction-networking/utls v1.8.2/go.mod h1:jkSOEkLqn+S/jtpEHPOsVv/4V4EVnelwbMQl4vCWXAM=
+github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=
+github.com/sebdah/goldie/v2 v2.8.0 h1:dZb9wR8q5++oplmEiJT+U/5KyotVD+HNGCAc5gNr8rc=
+github.com/sebdah/goldie/v2 v2.8.0/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI=
+github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
+github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/shirou/gopsutil/v4 v4.26.3 h1:2ESdQt90yU3oXF/CdOlRCJxrP+Am1aBYubTMTfxJ1qc=
github.com/shirou/gopsutil/v4 v4.26.3/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ=
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
@@ -69,38 +100,108 @@ github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=
github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=
+github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
+github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
+github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+github.com/yuin/goldmark v1.7.13 h1:GPddIs617DnBLFFVJFgpo1aBfe/4xcvMc3SB5t/D0pA=
+github.com/yuin/goldmark v1.7.13/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
+golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
+golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
+golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
+golang.org/x/crypto v0.51.0 h1:IBPXwPfKxY7cWQZ38ZCIRPI50YLeevDLlLnyC5wRGTI=
+golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
+golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
+golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
+golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
+golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
+golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
+golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
+golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
+golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
+golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
+golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
+golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
+golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
+golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
+golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
+golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
+golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4=
golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
+golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
+golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
+golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
+golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
+golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
+golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
+golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
+golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/internal/audit/run.go b/internal/audit/run.go
index ea8cb971..d5e6f9f4 100644
--- a/internal/audit/run.go
+++ b/internal/audit/run.go
@@ -1,7 +1,6 @@
package audit
import (
- "encoding/xml"
"errors"
"fmt"
"sync"
@@ -24,7 +23,10 @@ type RunOptions struct {
// Concurrency is the number of pages audited in parallel, clamped to
// [1, MaxConcurrency].
Concurrency int
- // Page selects the collectors for every page.
+ // EnrichAll browser-enriches every seaportal page, overriding the
+ // per-page BrowserRecommended routing.
+ EnrichAll bool
+ // Page selects the collectors for every enriched page.
Page PageOptions
}
@@ -52,27 +54,6 @@ func PlanURLs(urls []string) []string {
return plan
}
-type sitemapURLSet struct {
- URLs []struct {
- Loc string `xml:"loc"`
- } `xml:"url"`
-}
-
-// ParseSitemap extracts the <loc> URLs from a sitemap.xml document.
-func ParseSitemap(data []byte) ([]string, error) {
- var set sitemapURLSet
- if err := xml.Unmarshal(data, &set); err != nil {
- return nil, fmt.Errorf("parse sitemap: %w", err)
- }
- urls := make([]string, 0, len(set.URLs))
- for _, u := range set.URLs {
- if u.Loc != "" {
- urls = append(urls, u.Loc)
- }
- }
- return urls, nil
-}
-
// clampConcurrency normalizes a requested concurrency into [1, MaxConcurrency].
func clampConcurrency(n int) int {
switch {
@@ -85,41 +66,93 @@ func clampConcurrency(n int) int {
}
}
-// RunAudit audits every planned URL and assembles the versioned AuditReport.
-// The entry URL (first in the plan) is always audited first, synchronously;
-// the rest run with bounded concurrency. Page failures are report data, not
-// errors — RunAudit only errors when there is nothing to audit.
-func RunAudit(input AuditInput, opts RunOptions, discover SitemapFetcher, auditPage PageAuditor) (AuditReport, error) {
+// pagePlan is one planned page of a run: where to go, whether the browser
+// enriches it, and the seaportal metadata to merge into its report entry.
+type pagePlan struct {
+ url string
+ enrich bool
+ sp *SeaportalPage
+}
+
+// planRun resolves the input into the ordered page plan. Seaportal pages
+// route through BrowserRecommended (overridden by EnrichAll); URL-list and
+// sitemap inputs enrich everything.
+func planRun(input *AuditInput, seaportalPages []SeaportalPage, opts RunOptions, discover SitemapFetcher) ([]pagePlan, error) {
+ if len(seaportalPages) > 0 {
+ input.SeaportalFormat = SeaportalReportFormat
+ meta := make(map[string]*SeaportalPage, len(seaportalPages))
+ urls := make([]string, 0, len(seaportalPages))
+ for i := range seaportalPages {
+ sp := &seaportalPages[i]
+ if meta[sp.URL] == nil {
+ meta[sp.URL] = sp
+ urls = append(urls, sp.URL)
+ }
+ }
+ plan := SamplePages(urls, opts.SampleSize, nil)
+ plans := make([]pagePlan, len(plan))
+ for i, u := range plan {
+ sp := meta[u]
+ plans[i] = pagePlan{url: u, enrich: sp.BrowserRecommended || opts.EnrichAll, sp: sp}
+ }
+ return plans, nil
+ }
+
urls := input.URLs
if len(urls) == 0 && input.SitemapURL != "" {
if discover == nil {
- return AuditReport{}, errors.New("sitemap input requires a sitemap fetcher")
+ return nil, errors.New("sitemap input requires a sitemap fetcher")
}
discovered, err := discover(input.SitemapURL)
if err != nil {
- return AuditReport{}, fmt.Errorf("sitemap discovery: %w", err)
+ return nil, fmt.Errorf("sitemap discovery: %w", err)
}
urls = discovered
}
plan := SamplePages(PlanURLs(urls), opts.SampleSize, nil)
- if len(plan) == 0 {
+ plans := make([]pagePlan, len(plan))
+ for i, u := range plan {
+ plans[i] = pagePlan{url: u, enrich: true}
+ }
+ return plans, nil
+}
+
+// RunAudit audits every planned page and assembles the versioned
+// AuditReport. The entry page (first in the plan) is always processed first,
+// synchronously; the rest run with bounded concurrency. Page failures are
+// report data, not errors — RunAudit only errors when there is nothing to
+// audit.
+func RunAudit(input AuditInput, seaportalPages []SeaportalPage, opts RunOptions, discover SitemapFetcher, auditPage PageAuditor) (AuditReport, error) {
+ plans, err := planRun(&input, seaportalPages, opts, discover)
+ if err != nil {
+ return AuditReport{}, err
+ }
+ if len(plans) == 0 {
return AuditReport{}, errors.New("no URLs to audit")
}
concurrency := clampConcurrency(opts.Concurrency)
- results := make([]PageAudit, len(plan))
- results[0] = auditPage(plan[0], opts.Page)
+ results := make([]PageResult, len(plans))
+ exec := func(i int) {
+ p := plans[i]
+ if !p.enrich {
+ results[i] = seaportalOnlyResult(p)
+ return
+ }
+ results[i] = mergeSeaportal(auditPage(p.url, opts.Page).ToPageResult(), p.sp)
+ }
+ exec(0)
sem := make(chan struct{}, concurrency)
var wg sync.WaitGroup
- for i := 1; i < len(plan); i++ {
+ for i := 1; i < len(plans); i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
sem <- struct{}{}
defer func() { <-sem }()
- results[i] = auditPage(plan[i], opts.Page)
+ exec(i)
}(i)
}
wg.Wait()
@@ -133,11 +166,8 @@ func RunAudit(input AuditInput, opts RunOptions, discover SitemapFetcher, auditP
NetworkMonitor: opts.Page.Network,
Concurrency: concurrency,
}
- report.Pages = make([]PageResult, len(results))
- for i, pa := range results {
- report.Pages[i] = pa.ToPageResult()
- }
- report.SummaryScore = summaryScore(results)
+ report.Pages = results
+ report.SummaryScore = summaryScore(plans, results)
return report, nil
}
@@ -152,15 +182,42 @@ func (pa PageAudit) ToPageResult() PageResult {
}
}
-// summaryScore is the mean accessibility score across pages that were
-// audited without error, 0 when none were.
-func summaryScore(results []PageAudit) int {
+// seaportalOnlyResult is the report entry for a page seaportal marked as not
+// needing the browser: its HTTP-extraction summary without browser data.
+func seaportalOnlyResult(p pagePlan) PageResult {
+ return PageResult{
+ URL: p.url,
+ Title: p.sp.Title,
+ StatusCode: p.sp.StatusCode,
+ Seaportal: p.sp.Summary,
+ }
+}
+
+// mergeSeaportal embeds the seaportal summary into an enriched page entry,
+// filling title/status where the browser did not provide them.
+func mergeSeaportal(pr PageResult, sp *SeaportalPage) PageResult {
+ if sp == nil {
+ return pr
+ }
+ pr.Seaportal = sp.Summary
+ if pr.Title == "" {
+ pr.Title = sp.Title
+ }
+ if pr.StatusCode == 0 {
+ pr.StatusCode = sp.StatusCode
+ }
+ return pr
+}
+
+// summaryScore is the mean accessibility score across browser-enriched
+// pages that were audited without error, 0 when none were.
+func summaryScore(plans []pagePlan, results []PageResult) int {
sum, n := 0, 0
- for _, pa := range results {
- if pa.Error != "" {
+ for i, pr := range results {
+ if !plans[i].enrich || pr.Error != "" {
continue
}
- sum += pa.AccessibilityScore
+ sum += pr.Browser.AccessibilityScore
n++
}
if n == 0 {
diff --git a/internal/audit/run_test.go b/internal/audit/run_test.go
index 9d0ca463..af174170 100644
--- a/internal/audit/run_test.go
+++ b/internal/audit/run_test.go
@@ -19,27 +19,6 @@ func TestPlanURLs(t *testing.T) {
}
}
-func TestParseSitemap(t *testing.T) {
- data := []byte(`<?xml version="1.0" encoding="UTF-8"?>
-<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
- <url><loc>http://fixtures/a.html</loc></url>
- <url><loc>http://fixtures/b.html</loc></url>
- <url><loc></loc></url>
-</urlset>`)
- got, err := ParseSitemap(data)
- if err != nil {
- t.Fatalf("ParseSitemap: %v", err)
- }
- want := []string{"http://fixtures/a.html", "http://fixtures/b.html"}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("ParseSitemap = %v, want %v", got, want)
- }
-
- if _, err := ParseSitemap([]byte("not xml at all <")); err == nil {
- t.Error("ParseSitemap should error on malformed XML")
- }
-}
-
func fakeAuditor() (PageAuditor, *[]string, *sync.Mutex) {
var mu sync.Mutex
var calls []string
@@ -55,6 +34,7 @@ func TestRunAuditOrderingAndDedupe(t *testing.T) {
auditor, calls, _ := fakeAuditor()
report, err := RunAudit(
AuditInput{URLs: []string{"http://x/home", "http://x/a", "http://x/home", "http://x/b"}},
+ nil,
RunOptions{Concurrency: 1},
nil, auditor,
)
@@ -92,6 +72,7 @@ func TestRunAuditEntryFirstSynchronously(t *testing.T) {
}
if _, err := RunAudit(
AuditInput{URLs: []string{"http://x/entry", "http://x/a", "http://x/b", "http://x/c"}},
+ nil,
RunOptions{Concurrency: 4},
nil, auditor,
); err != nil {
@@ -116,7 +97,7 @@ func TestRunAuditConcurrencyBound(t *testing.T) {
for i := range 20 {
urls = append(urls, "http://x/p"+string(rune('a'+i)))
}
- report, err := RunAudit(AuditInput{URLs: urls}, RunOptions{Concurrency: 3}, nil, auditor)
+ report, err := RunAudit(AuditInput{URLs: urls}, nil, RunOptions{Concurrency: 3}, nil, auditor)
if err != nil {
t.Fatalf("RunAudit: %v", err)
}
@@ -135,7 +116,7 @@ func TestRunAuditConcurrencyYieldsSameURLSet(t *testing.T) {
urls := []string{"http://x/1", "http://x/2", "http://x/3", "http://x/4", "http://x/5"}
pageSet := func(concurrency int) map[string]bool {
auditor, _, _ := fakeAuditor()
- report, err := RunAudit(AuditInput{URLs: urls}, RunOptions{Concurrency: concurrency}, nil, auditor)
+ report, err := RunAudit(AuditInput{URLs: urls}, nil, RunOptions{Concurrency: concurrency}, nil, auditor)
if err != nil {
t.Fatalf("RunAudit(concurrency=%d): %v", concurrency, err)
}
@@ -158,7 +139,7 @@ func TestRunAuditSitemapMode(t *testing.T) {
}
return []string{"http://x/a", "http://x/b"}, nil
}
- report, err := RunAudit(AuditInput{SitemapURL: "http://x/sitemap.xml"}, RunOptions{}, discover, auditor)
+ report, err := RunAudit(AuditInput{SitemapURL: "http://x/sitemap.xml"}, nil, RunOptions{}, discover, auditor)
if err != nil {
t.Fatalf("RunAudit: %v", err)
}
@@ -166,7 +147,7 @@ func TestRunAuditSitemapMode(t *testing.T) {
t.Errorf("pages = %d, want 2", len(report.Pages))
}
- if _, err := RunAudit(AuditInput{SitemapURL: "http://x/sitemap.xml"}, RunOptions{}, func(string) ([]string, error) {
+ if _, err := RunAudit(AuditInput{SitemapURL: "http://x/sitemap.xml"}, nil, RunOptions{}, func(string) ([]string, error) {
return nil, errors.New("fetch failed")
}, auditor); err == nil {
t.Error("RunAudit should surface sitemap fetch errors")
@@ -177,6 +158,7 @@ func TestRunAuditSampleSizeAndEmpty(t *testing.T) {
auditor, _, _ := fakeAuditor()
report, err := RunAudit(
AuditInput{URLs: []string{"http://x/p1.html", "http://x/p2.html", "http://x/p3.html"}},
+ nil,
RunOptions{SampleSize: 2},
nil, auditor,
)
@@ -187,7 +169,7 @@ func TestRunAuditSampleSizeAndEmpty(t *testing.T) {
t.Errorf("pages = %d, want 2 (template group sampled)", len(report.Pages))
}
- if _, err := RunAudit(AuditInput{}, RunOptions{}, nil, auditor); err == nil {
+ if _, err := RunAudit(AuditInput{}, nil, RunOptions{}, nil, auditor); err == nil {
t.Error("RunAudit with no input should error")
}
}
@@ -201,6 +183,7 @@ func TestRunAuditErrorsAreData(t *testing.T) {
}
report, err := RunAudit(
AuditInput{URLs: []string{"http://x/up", "http://x/down"}},
+ nil,
RunOptions{},
nil, auditor,
)
diff --git a/internal/audit/seaportal.go b/internal/audit/seaportal.go
new file mode 100644
index 00000000..aa5848f1
--- /dev/null
+++ b/internal/audit/seaportal.go
@@ -0,0 +1,74 @@
+package audit
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "time"
+
+ seaportal "github.com/pinchtab/seaportal"
+)
+
+// SeaportalReportFormat versions the interim seaportal input format: a JSON
+// array of seaportal Result objects (seaportal has no site-level SiteReport
+// yet). Recorded on AuditInput so report consumers can detect format changes.
+const SeaportalReportFormat = "seaportal-results/v0"
+
+// SeaportalPage is the audit-facing view of one seaportal Result: the
+// summary fields merged into report pages plus the browser-routing decision.
+type SeaportalPage struct {
+ URL string
+ Title string
+ StatusCode int
+ BrowserRecommended bool
+ // Summary is embedded verbatim into PageResult.Seaportal.
+ Summary map[string]any
+}
+
+// ParseSeaportalReport parses the interim JSON array of seaportal Results
+// into audit pages. Entries without a URL are dropped.
+func ParseSeaportalReport(data []byte) ([]SeaportalPage, error) {
+ var results []seaportal.Result
+ if err := json.Unmarshal(data, &results); err != nil {
+ return nil, fmt.Errorf("parse seaportal report: %w", err)
+ }
+ pages := make([]SeaportalPage, 0, len(results))
+ for _, r := range results {
+ if r.URL == "" {
+ continue
+ }
+ pages = append(pages, SeaportalPage{
+ URL: r.URL,
+ Title: r.Title,
+ StatusCode: r.StatusCode,
+ BrowserRecommended: r.Profile.BrowserRecommended,
+ Summary: map[string]any{
+ "title": r.Title,
+ "description": r.Description,
+ "confidence": r.Confidence,
+ "quality": r.Quality,
+ "decision": string(r.Profile.Decision),
+ "browserRecommended": r.Profile.BrowserRecommended,
+ },
+ })
+ }
+ return pages, nil
+}
+
+// FlattenSitemapURLs discovers page URLs from a sitemap (recursively for
+// sitemap indexes) via seaportal.FlattenSitemap.
+func FlattenSitemapURLs(ctx context.Context, sitemapURL string) ([]string, error) {
+ entries, err := seaportal.FlattenSitemap(ctx, sitemapURL, seaportal.FlattenSitemapOptions{
+ Timeout: 15 * time.Second,
+ })
+ if err != nil {
+ return nil, err
+ }
+ urls := make([]string, 0, len(entries))
+ for _, e := range entries {
+ if e.Loc != "" {
+ urls = append(urls, e.Loc)
+ }
+ }
+ return urls, nil
+}
diff --git a/internal/audit/seaportal_test.go b/internal/audit/seaportal_test.go
new file mode 100644
index 00000000..7e8dd6af
--- /dev/null
+++ b/internal/audit/seaportal_test.go
@@ -0,0 +1,113 @@
+package audit
+
+import (
+ "context"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "reflect"
+ "testing"
+)
+
+func TestParseSeaportalReport(t *testing.T) {
+ data := []byte(`[
+ {"url":"http://fixtures/audit-site/index.html","title":"Home","description":"Landing page","confidence":90,"statusCode":200,
+ "profile":{"decision":"browser-needed","browserRecommended":true}},
+ {"url":"http://fixtures/audit-site/clean.html","title":"Clean","description":"Static page","confidence":95,"statusCode":200,
+ "profile":{"decision":"static-high-confidence","browserRecommended":false}},
+ {"url":"","title":"dropped"}
+ ]`)
+ pages, err := ParseSeaportalReport(data)
+ if err != nil {
+ t.Fatalf("ParseSeaportalReport: %v", err)
+ }
+ if len(pages) != 2 {
+ t.Fatalf("pages = %d, want 2 (empty URL dropped)", len(pages))
+ }
+ if !pages[0].BrowserRecommended || pages[1].BrowserRecommended {
+ t.Errorf("BrowserRecommended routing wrong: %+v", pages)
+ }
+ if pages[1].Summary["title"] != "Clean" || pages[1].Summary["description"] != "Static page" {
+ t.Errorf("Summary = %+v", pages[1].Summary)
+ }
+ if pages[1].Summary["decision"] != "static-high-confidence" {
+ t.Errorf("decision = %v", pages[1].Summary["decision"])
+ }
+
+ if _, err := ParseSeaportalReport([]byte("{not an array}")); err == nil {
+ t.Error("ParseSeaportalReport should error on malformed input")
+ }
+}
+
+func TestFlattenSitemapURLsAgainstFixture(t *testing.T) {
+ data, err := os.ReadFile("../../tests/e2e/fixtures/audit-site/sitemap.xml")
+ if err != nil {
+ t.Fatalf("read fixture sitemap: %v", err)
+ }
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/xml")
+ _, _ = w.Write(data)
+ }))
+ defer srv.Close()
+
+ urls, err := FlattenSitemapURLs(context.Background(), srv.URL+"/sitemap.xml")
+ if err != nil {
+ t.Fatalf("FlattenSitemapURLs: %v", err)
+ }
+ if len(urls) != 12 {
+ t.Errorf("urls = %d, want 12", len(urls))
+ }
+ if urls[0] != "http://fixtures/audit-site/index.html" {
+ t.Errorf("first url = %q", urls[0])
+ }
+}
+
+func TestRunAuditSeaportalRouting(t *testing.T) {
+ pages := []SeaportalPage{
+ {URL: "http://x/spa", Title: "SPA", BrowserRecommended: true, Summary: map[string]any{"title": "SPA"}},
+ {URL: "http://x/static", Title: "Static", StatusCode: 200, BrowserRecommended: false, Summary: map[string]any{"title": "Static", "description": "d"}},
+ }
+ var audited []string
+ auditor := func(url string, opts PageOptions) PageAudit {
+ audited = append(audited, url)
+ return PageAudit{URL: url, Title: "browser " + url, BrowserPageData: BrowserPageData{AccessibilityScore: 100}}
+ }
+
+ report, err := RunAudit(AuditInput{SeaportalFile: "report.json"}, pages, RunOptions{Concurrency: 1}, nil, auditor)
+ if err != nil {
+ t.Fatalf("RunAudit: %v", err)
+ }
+ if !reflect.DeepEqual(audited, []string{"http://x/spa"}) {
+ t.Errorf("audited = %v, want only the browserRecommended page", audited)
+ }
+ if report.Input.SeaportalFormat != SeaportalReportFormat {
+ t.Errorf("SeaportalFormat = %q", report.Input.SeaportalFormat)
+ }
+ if len(report.Pages) != 2 {
+ t.Fatalf("pages = %d, want 2", len(report.Pages))
+ }
+
+ static := report.Pages[1]
+ if static.URL != "http://x/static" || static.Title != "Static" || static.StatusCode != 200 {
+ t.Errorf("static page = %+v", static)
+ }
+ if static.Seaportal["description"] != "d" {
+ t.Errorf("static Seaportal = %+v", static.Seaportal)
+ }
+ if static.Browser.AccessibilityScore != 0 || static.Screenshot != "" {
+ t.Errorf("static page should not be browser-enriched: %+v", static)
+ }
+
+ enriched := report.Pages[0]
+ if enriched.Seaportal["title"] != "SPA" {
+ t.Errorf("enriched page should carry seaportal summary: %+v", enriched)
+ }
+
+ audited = nil
+ if _, err := RunAudit(AuditInput{}, pages, RunOptions{EnrichAll: true, Concurrency: 1}, nil, auditor); err != nil {
+ t.Fatalf("RunAudit enrichAll: %v", err)
+ }
+ if len(audited) != 2 {
+ t.Errorf("enrichAll audited = %v, want both pages", audited)
+ }
+}
diff --git a/internal/audit/types.go b/internal/audit/types.go
index b9f508b3..25115bd0 100644
--- a/internal/audit/types.go
+++ b/internal/audit/types.go
@@ -183,6 +183,9 @@ type AuditInput struct {
SitemapURL string `json:"sitemapUrl,omitempty"`
// SeaportalFile is the path to a SeaPortal results JSON file.
SeaportalFile string `json:"seaportalFile,omitempty"`
+ // SeaportalFormat versions the ingested seaportal payload
+ // (SeaportalReportFormat); empty for non-seaportal inputs.
+ SeaportalFormat string `json:"seaportalFormat,omitempty"`
}
// AuditOptions are the run options an audit was executed with.
diff --git a/internal/cli/actions/actions_audit.go b/internal/cli/actions/actions_audit.go
index 8c704add..30003bb2 100644
--- a/internal/cli/actions/actions_audit.go
+++ b/internal/cli/actions/actions_audit.go
@@ -17,12 +17,35 @@ import (
// per-request client timeout, which a site audit easily exceeds.
const auditTimeout = 10 * time.Minute
+func mustString(cmd *cobra.Command, name string) string {
+ v, _ := cmd.Flags().GetString(name)
+ return v
+}
+
+func mustBool(cmd *cobra.Command, name string) bool {
+ v, _ := cmd.Flags().GetBool(name)
+ return v
+}
+
// Audit runs a multi-page site audit via POST /audit and writes artifacts.
func Audit(client *http.Client, base, token string, cmd *cobra.Command, target string) {
body := map[string]any{}
- if v, _ := cmd.Flags().GetBool("sitemap"); v {
+ switch {
+ case mustString(cmd, "seaportal-report") != "":
+ path := mustString(cmd, "seaportal-report")
+ data, err := os.ReadFile(path)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "read seaportal report: %v\n", err)
+ os.Exit(1)
+ }
+ body["seaportalResults"] = json.RawMessage(data)
+ body["seaportalFile"] = path
+ if v, _ := cmd.Flags().GetBool("enrich-all"); v {
+ body["enrichAll"] = true
+ }
+ case mustBool(cmd, "sitemap"):
body["sitemapUrl"] = target
- } else {
+ default:
body["urls"] = []string{target}
}
diff --git a/internal/handlers/audit.go b/internal/handlers/audit.go
index 3cfd10eb..eaff2aa7 100644
--- a/internal/handlers/audit.go
+++ b/internal/handlers/audit.go
@@ -1,25 +1,25 @@
package handlers
import (
+ "context"
"encoding/json"
"fmt"
- "io"
"net/http"
- "time"
"github.com/pinchtab/pinchtab/internal/audit"
"github.com/pinchtab/pinchtab/internal/config"
"github.com/pinchtab/pinchtab/internal/httpx"
)
-const maxSitemapBytes = 5 << 20
-
type auditRequest struct {
- URLs []string `json:"urls"`
- SitemapURL string `json:"sitemapUrl"`
- Options *auditPageOptionsBody `json:"options"`
- Concurrency int `json:"concurrency"`
- SampleSize int `json:"sampleSize"`
+ URLs []string `json:"urls"`
+ SitemapURL string `json:"sitemapUrl"`
+ SeaportalResults json.RawMessage `json:"seaportalResults"`
+ SeaportalFile string `json:"seaportalFile"`
+ EnrichAll bool `json:"enrichAll"`
+ Options *auditPageOptionsBody `json:"options"`
+ Concurrency int `json:"concurrency"`
+ SampleSize int `json:"sampleSize"`
}
// @Endpoint POST /audit
@@ -29,11 +29,20 @@ func (h *Handlers) HandleAudit(w http.ResponseWriter, r *http.Request) {
httpx.Error(w, 400, fmt.Errorf("decode: %w", err))
return
}
- if len(req.URLs) == 0 && req.SitemapURL == "" {
- httpx.Error(w, 400, fmt.Errorf("urls or sitemapUrl required"))
+ if len(req.URLs) == 0 && req.SitemapURL == "" && len(req.SeaportalResults) == 0 {
+ httpx.Error(w, 400, fmt.Errorf("urls, sitemapUrl, or seaportalResults required"))
return
}
+ var seaportalPages []audit.SeaportalPage
+ if len(req.SeaportalResults) > 0 {
+ var err error
+ if seaportalPages, err = audit.ParseSeaportalReport(req.SeaportalResults); err != nil {
+ httpx.Error(w, 400, err)
+ return
+ }
+ }
+
routing, ok := h.resolveNavigateBrowser(w, r, "", "")
if !ok {
return
@@ -51,10 +60,12 @@ func (h *Handlers) HandleAudit(w http.ResponseWriter, r *http.Request) {
}
report, err := audit.RunAudit(
- audit.AuditInput{URLs: req.URLs, SitemapURL: req.SitemapURL},
+ audit.AuditInput{URLs: req.URLs, SitemapURL: req.SitemapURL, SeaportalFile: req.SeaportalFile},
+ seaportalPages,
audit.RunOptions{
SampleSize: req.SampleSize,
Concurrency: req.Concurrency,
+ EnrichAll: req.EnrichAll,
Page: req.Options.pageOptions(),
},
h.fetchSitemap(routing.EffectiveCfg),
@@ -68,25 +79,13 @@ func (h *Handlers) HandleAudit(w http.ResponseWriter, r *http.Request) {
}
// fetchSitemap returns a SitemapFetcher that applies the same URL/IDPI/SSRF
-// validation as page navigation before fetching over plain HTTP.
+// validation as page navigation, then discovers pages through
+// seaportal.FlattenSitemap (recursive sitemap-index support).
func (h *Handlers) fetchSitemap(cfg *config.RuntimeConfig) audit.SitemapFetcher {
return func(sitemapURL string) ([]string, error) {
if _, err := h.validateAuditTarget(sitemapURL, cfg); err != nil {
return nil, err
}
- client := &http.Client{Timeout: 15 * time.Second}
- resp, err := client.Get(sitemapURL)
- if err != nil {
- return nil, fmt.Errorf("fetch sitemap: %w", err)
- }
- defer func() { _ = resp.Body.Close() }()
- if resp.StatusCode != http.StatusOK {
- return nil, fmt.Errorf("fetch sitemap: HTTP %d", resp.StatusCode)
- }
- data, err := io.ReadAll(io.LimitReader(resp.Body, maxSitemapBytes))
- if err != nil {
- return nil, fmt.Errorf("read sitemap: %w", err)
- }
- return audit.ParseSitemap(data)
+ return audit.FlattenSitemapURLs(context.Background(), sitemapURL)
}
}
diff --git a/tests/e2e/fixtures/audit-site/seaportal-report.json b/tests/e2e/fixtures/audit-site/seaportal-report.json
new file mode 100644
index 00000000..abdcb16b
--- /dev/null
+++ b/tests/e2e/fixtures/audit-site/seaportal-report.json
@@ -0,0 +1,44 @@
+[
+ {
+ "url": "http://fixtures/audit-site/index.html",
+ "title": "Audit Fixture Site",
+ "description": "Deterministic audit fixture site for PinchTab e2e tests.",
+ "confidence": 60,
+ "statusCode": 200,
+ "quality": 0.7,
+ "profile": {
+ "class": "hydrated",
+ "decision": "browser-needed",
+ "browserRecommended": true,
+ "confidence": 60
+ }
+ },
+ {
+ "url": "http://fixtures/audit-site/clean.html",
+ "title": "Clean Page — Audit Fixture Site",
+ "description": "Defect-free control page for audit e2e scenarios.",
+ "confidence": 95,
+ "statusCode": 200,
+ "quality": 0.9,
+ "profile": {
+ "class": "static",
+ "decision": "static-high-confidence",
+ "browserRecommended": false,
+ "confidence": 95
+ }
+ },
+ {
+ "url": "http://fixtures/audit-site/broken-assets.html",
+ "title": "Broken Assets — Audit Fixture Site",
+ "description": "Page referencing exactly three missing assets and one missing fetch.",
+ "confidence": 55,
+ "statusCode": 200,
+ "quality": 0.6,
+ "profile": {
+ "class": "hydrated",
+ "decision": "browser-needed",
+ "browserRecommended": true,
+ "confidence": 55
+ }
+ }
+]
diff --git a/tests/e2e/scenarios/cli/audit-seaportal-basic.sh b/tests/e2e/scenarios/cli/audit-seaportal-basic.sh
new file mode 100755
index 00000000..54a58c03
--- /dev/null
+++ b/tests/e2e/scenarios/cli/audit-seaportal-basic.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+# audit-seaportal-basic.sh — pinchtab audit --seaportal-report ingestion.
+
+GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+source "${GROUP_DIR}/../../helpers/cli.sh"
+
+SEAPORTAL_REPORT="${GROUP_DIR}/../../fixtures/audit-site/seaportal-report.json"
+CLEAN_URL="http://fixtures/audit-site/clean.html"
+
+# ─────────────────────────────────────────────────────────────────
+start_test "seaportal report drives routing via browserRecommended"
+
+pt_ok audit --seaportal-report "$SEAPORTAL_REPORT" --json
+
+PAGE_COUNT=$(echo "$PT_OUT" | jq '.pages | length' 2>/dev/null)
+if [ "${PAGE_COUNT:-0}" -eq 3 ] 2>/dev/null; then
+ pass_assert "all 3 report pages present"
+else
+ fail_assert "all 3 report pages present (got: $PAGE_COUNT)"
+fi
+
+if echo "$PT_OUT" | jq -e '.input.seaportalFormat == "seaportal-results/v0"' >/dev/null 2>&1; then
+ pass_assert "input carries seaportal format version"
+else
+ fail_assert "input carries seaportal format version"
+fi
+
+CLEAN_PAGE=$(echo "$PT_OUT" | jq --arg url "$CLEAN_URL" '.pages[] | select(.url == $url)')
+
+if echo "$CLEAN_PAGE" | jq -e 'has("screenshot") | not' >/dev/null 2>&1; then
+ pass_assert "browserRecommended=false page has no screenshot"
+else
+ fail_assert "browserRecommended=false page has no screenshot"
+fi
+
+if echo "$CLEAN_PAGE" | jq -e '.seaportal.title == "Clean Page — Audit Fixture Site"' >/dev/null 2>&1; then
+ pass_assert "non-enriched page keeps seaportal title"
+else
+ fail_assert "non-enriched page keeps seaportal title (got: $(echo "$CLEAN_PAGE" | jq -c '.seaportal'))"
+fi
+
+if echo "$CLEAN_PAGE" | jq -e '.seaportal.description == "Defect-free control page for audit e2e scenarios."' >/dev/null 2>&1; then
+ pass_assert "non-enriched page keeps seaportal description"
+else
+ fail_assert "non-enriched page keeps seaportal description"
+fi
+
+ENRICHED=$(echo "$PT_OUT" | jq '.pages[] | select(.url | endswith("index.html"))')
+if echo "$ENRICHED" | jq -e '.screenshot | length > 0' >/dev/null 2>&1; then
+ pass_assert "browserRecommended=true page is enriched (screenshot)"
+else
+ fail_assert "browserRecommended=true page is enriched (screenshot)"
+fi
+if echo "$ENRICHED" | jq -e '.seaportal.description | length > 0' >/dev/null 2>&1; then
+ pass_assert "enriched page also carries seaportal fields"
+else
+ fail_assert "enriched page also carries seaportal fields"
+fi
+
+end_test
+
+# ─────────────────────────────────────────────────────────────────
+start_test "--enrich-all overrides browserRecommended routing"
+
+pt_ok audit --seaportal-report "$SEAPORTAL_REPORT" --enrich-all --json
+
+CLEAN_PAGE=$(echo "$PT_OUT" | jq --arg url "$CLEAN_URL" '.pages[] | select(.url == $url)')
+if echo "$CLEAN_PAGE" | jq -e '.screenshot | length > 0' >/dev/null 2>&1; then
+ pass_assert "clean.html enriched under --enrich-all"
+else
+ fail_assert "clean.html enriched under --enrich-all"
+fi
+
+end_test