MCPcopy Create free account
hub / github.com/diillson/chatcli / hijackPageRequests

Function hijackPageRequests

cli/plugins/webfetch_render.go:367–381  ·  view source on GitHub ↗

hijackPageRequests installs the in-browser SSRF layer: every network request the rendered page issues is validated before it leaves Chromium, mirroring the dial-time guard of the plain HTTP path.

(page *rod.Page)

Source from the content-addressed store, hash-verified

365// request the rendered page issues is validated before it leaves Chromium,
366// mirroring the dial-time guard of the plain HTTP path.
367func hijackPageRequests(page *rod.Page) error {
368 router := page.HijackRequests()
369 err := router.Add("*", "", func(h *rod.Hijack) {
370 if renderRequestAllowed(h.Request.URL().String()) {
371 h.ContinueRequest(&proto.FetchContinueRequest{})
372 return
373 }
374 h.Response.Fail(proto.NetworkErrorReasonBlockedByClient)
375 })
376 if err != nil {
377 return fmt.Errorf("installing request guard: %w", err)
378 }
379 go router.Run()
380 return nil
381}
382
383// ── SSRF policy for in-page sub-requests ────────────────────────────
384

Callers 1

preparePageFunction · 0.85

Calls 5

renderRequestAllowedFunction · 0.85
AddMethod · 0.80
ErrorfMethod · 0.80
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected