Repository navigation
feat: Options.Fetch and html2pdf.Offline (render with no network access) - #47
Merged
Merged
Conversation
Export fetched stylesheets (<link>, @import) and images (<img>) with the engine's default client: redirects followed to any host, no allow-list. A server rendering HTML built from untrusted text then depended on its HTML escaping alone to stay out of its own network (go-llmflow/gateway#123). Options.Fetch is the engine's Engine.Fetcher hook (engine.go:68-74), which every http(s) sub-resource goes through (engine.go:234-256). Offline refuses all of them with ErrOffline; a refused resource is treated as missing and Options.OnRefused is told its URL. data: URLs are decoded by the engine before the hook, file: URLs are refused by the engine (FileRoot is empty and Export now pins it so). CLI: --offline. Tests: a loopback server records hits for every kind of sub-resource (zero under Offline, a control that sees a hit without it), data: images still render, a file: BaseURL reads nothing, hostile URL table, fuzz target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Options.Fetch(aFetcher, the engine'sEngine.Fetcherhook) replaces the network client for every http(s) sub-resource;html2pdf.Offlinerefuses all of them.Options.OnRefused(url)is called for each refusal, so callers can count them. CLI:--offline.A server that renders HTML built from untrusted text (the llmflow gateway's decision report, go-llmflow/gateway#123) no longer depends on HTML escaping alone to stay out of its own network.
Fetch sites (go-webengine/engine v0.18.1, as pinned)
Reached by
Export:<link rel=stylesheet>and@import(engine.go:787-806, viae.get-> Fetcher at engine.go:234-243),<img>incl. svg (images.go:307, fetchImageBytes images.go:578-611 ->fetchBytesengine.go:248-257).Not reached: JS/fetch/XHR (no script engine in
Export),@font-face(LoadFontFacesnot called), iframe/object/embed/video (never loaded), CSS background images (loadOneBackgroundimages.go:482 is not on theLoadImageSetpath; measured: zero hits).file:URLs: refused by the engine unlessFileRootis set (fileurl.go:53-56);Exportpins it empty.Redirects: followed by the default client (Go limit of 10, any host); documented on
Options.Fetch.Offlinesends nothing.Tests
Loopback
httptestrecorder over 23 document shapes: zero hits underOffline; the control (default options) sees a hit for every kind the engine loads and fails if a kind not expected to load starts to.data:images render byte-identically; afile:BaseURL reads nothing; hostile URL table (userinfo, IPv6-mapped, decimal/hex hosts,//, backslashes, 70 kB URL, NUL, redirect);FuzzOfflineMakesNoRequest(20 s, no finding); CLI--offlinetest.🤖 Generated with Claude Code