High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix(dialog): storage, state capture/save/load and fingerprint rotate refuse a dialog-blocked tab with 409 dialog_blocked, and the census places every allow-listed row under a fixed reason vocabulary (PIN-425)
Luigi Agosti16e315ef40a7
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.goindex 8e643078..4917d22f 100644--- a/internal/handlers/handlers.go+++ b/internal/handlers/handlers.go@@ -398,7 +398,7 @@ func (h *Handlers) bridgeBindings() []routeBinding {{pattern: "POST /clipboard/copy", root: h.HandleClipboardCopy, guards: guardNone},{pattern: "GET /clipboard/paste", root: h.HandleClipboardPaste, guards: guardNone},{pattern: "GET /stealth/status", root: h.HandleStealthStatus, guards: guardNone},- {pattern: "POST /fingerprint/rotate", root: h.HandleFingerprintRotate, guards: guardDomainPolicy | guardHandoffPause},+ {pattern: "POST /fingerprint/rotate", root: h.HandleFingerprintRotate, guards: guardDialogBlocked | guardDomainPolicy | guardHandoffPause},{pattern: "GET /solvers", root: h.HandleListSolvers, guards: guardNone},{pattern: "GET /config/autosolver", root: h.HandleAutoSolverConfig, guards: guardNone},{pattern: "POST /solve", root: h.HandleSolve, tab: h.HandleTabSolve, guards: guardDialogBlocked | guardDomainPolicy | guardHandoffPause},@@ -411,14 +411,14 @@ func (h *Handlers) bridgeBindings() []routeBinding {{pattern: "POST /emulation/media", root: h.HandleSetMedia, tab: h.HandleTabSetMedia, guards: guardDialogBlocked | guardDomainPolicy | guardHandoffPause},{pattern: "POST /cache/clear", root: h.HandleCacheClear, guards: guardNone},{pattern: "GET /cache/status", root: h.HandleCacheStatus, guards: guardNone},- {pattern: "POST /storage", root: h.HandleStorage, tab: h.HandleTabStorageSet, guards: guardDomainPolicy | guardHandoffPause},- {pattern: "DELETE /storage", root: h.HandleStorage, tab: h.HandleTabStorageDelete, guards: guardDomainPolicy | guardHandoffPause},- {pattern: "GET /storage", root: h.HandleStorage, tab: h.HandleTabStorageGet, guards: guardDomainPolicy}, // no handoff-pause: read probe; the POST/DELETE siblings carry it- {pattern: "GET /state", root: h.HandleStateCurrent, guards: guardDomainPolicy}, // no handoff-pause: captures a snapshot, writes nothing to the tab+ {pattern: "POST /storage", root: h.HandleStorage, tab: h.HandleTabStorageSet, guards: guardDialogBlocked | guardDomainPolicy | guardHandoffPause},+ {pattern: "DELETE /storage", root: h.HandleStorage, tab: h.HandleTabStorageDelete, guards: guardDialogBlocked | guardDomainPolicy | guardHandoffPause},+ {pattern: "GET /storage", root: h.HandleStorage, tab: h.HandleTabStorageGet, guards: guardDialogBlocked | guardDomainPolicy}, // no handoff-pause: read probe; the POST/DELETE siblings carry it+ {pattern: "GET /state", root: h.HandleStateCurrent, guards: guardDialogBlocked | guardDomainPolicy}, // no handoff-pause: captures a snapshot, writes nothing to the tab{pattern: "GET /state/list", root: h.HandleStateList, guards: guardNone},{pattern: "GET /state/show", root: h.HandleStateShow, guards: guardNone},- {pattern: "POST /state/save", root: h.HandleStateSave, guards: guardDomainPolicy}, // no handoff-pause: POST writes a file, not the tab; /state/load is the write and carries it- {pattern: "POST /state/load", root: h.HandleStateLoad, guards: guardDomainPolicy | guardHandoffPause},+ {pattern: "POST /state/save", root: h.HandleStateSave, guards: guardDialogBlocked | guardDomainPolicy}, // no handoff-pause: POST writes a file, not the tab; /state/load is the write and carries it+ {pattern: "POST /state/load", root: h.HandleStateLoad, guards: guardDialogBlocked | guardDomainPolicy | guardHandoffPause},{pattern: "DELETE /state", root: h.HandleStateDelete, guards: guardNone},{pattern: "POST /state/clean", root: h.HandleStateClean, guards: guardNone},{pattern: "POST /evaluate", root: h.HandleEvaluate, tab: h.HandleTabEvaluate, guards: guardDialogBlocked | guardDomainPolicy | guardHandoffPause},diff --git a/internal/handlers/state.go b/internal/handlers/state.goindex 59793e76..52bf00ff 100644--- a/internal/handlers/state.go+++ b/internal/handlers/state.go@@ -101,7 +101,7 @@ func (h *Handlers) HandleStateSave(w http.ResponseWriter, r *http.Request) {}}- ctx, resolvedTabID, ok := h.guardedTabContext(w, r, req.TabID, guardDomainPolicy)+ ctx, resolvedTabID, ok := h.guardedTabContext(w, r, req.TabID, guardDialogBlocked|guardDomainPolicy)if !ok {return}diff --git a/internal/handlers/state_capture.go b/internal/handlers/state_capture.goindex 40712c87..b027e414 100644--- a/internal/handlers/state_capture.go+++ b/internal/handlers/state_capture.go@@ -38,7 +38,7 @@ func (h *Handlers) HandleStateCurrent(w http.ResponseWriter, r *http.Request) {}tabID := r.URL.Query().Get("tabId")- ctx, resolvedTabID, ok := h.guardedTabContext(w, r, tabID, guardDomainPolicy)+ ctx, resolvedTabID, ok := h.guardedTabContext(w, r, tabID, guardDialogBlocked|guardDomainPolicy)if !ok {return}@@ -119,7 +119,7 @@ func (h *Handlers) HandleStateLoad(w http.ResponseWriter, r *http.Request) {return}- ctx, resolvedTabID, ok := h.guardedTabContext(w, r, req.TabID, guardDomainPolicy|guardHandoffPause)+ ctx, resolvedTabID, ok := h.guardedTabContext(w, r, req.TabID, guardDialogBlocked|guardDomainPolicy|guardHandoffPause)if !ok {return}diff --git a/internal/handlers/stealth.go b/internal/handlers/stealth.goindex 3741d888..ace5bbc7 100644--- a/internal/handlers/stealth.go+++ b/internal/handlers/stealth.go@@ -36,7 +36,7 @@ func (h *Handlers) HandleFingerprintRotate(w http.ResponseWriter, r *http.Requesreturn}- ctx, resolvedTabID, ok := h.guardedTabContext(w, r, req.TabID, guardDomainPolicy|guardHandoffPause)+ ctx, resolvedTabID, ok := h.guardedTabContext(w, r, req.TabID, guardDialogBlocked|guardDomainPolicy|guardHandoffPause)if !ok {return}diff --git a/internal/handlers/storage.go b/internal/handlers/storage.goindex 72408ac2..0ecb70f2 100644--- a/internal/handlers/storage.go+++ b/internal/handlers/storage.go@@ -96,7 +96,7 @@ func (h *Handlers) handleStorageGet(w http.ResponseWriter, r *http.Request) {key := r.URL.Query().Get("key")script := buildStorageGetScript(storageType, key)- h.runStorageOp(w, r, tabID, script, "get", "storage.read", storageType, key, guardDomainPolicy)+ h.runStorageOp(w, r, tabID, script, "get", "storage.read", storageType, key, guardDialogBlocked|guardDomainPolicy)}type storageSetRequest struct {@@ -147,7 +147,7 @@ func (h *Handlers) handleStorageSet(w http.ResponseWriter, r *http.Request) {}`, storageObj, string(keyJSON), string(valueJSON))- h.runStorageOp(w, r, req.TabID, script, "set", "storage.write", req.Type, req.Key, guardDomainPolicy|guardHandoffPause)+ h.runStorageOp(w, r, req.TabID, script, "set", "storage.write", req.Type, req.Key, guardDialogBlocked|guardDomainPolicy|guardHandoffPause)}// handleStorageDelete removes a storage item or clears storage.@@ -191,7 +191,7 @@ func (h *Handlers) handleStorageDelete(w http.ResponseWriter, r *http.Request) {}script := buildStorageDeleteScript(req.Type, req.Key)- h.runStorageOp(w, r, req.TabID, script, "delete", "storage.delete", req.Type, req.Key, guardDomainPolicy|guardHandoffPause)+ h.runStorageOp(w, r, req.TabID, script, "delete", "storage.delete", req.Type, req.Key, guardDialogBlocked|guardDomainPolicy|guardHandoffPause)}// buildStorageGetScript builds a JS expression that reads from localStoragediff --git a/internal/handlers/tab_guards_test.go b/internal/handlers/tab_guards_test.goindex 55fcf847..90716559 100644--- a/internal/handlers/tab_guards_test.go+++ b/internal/handlers/tab_guards_test.go@@ -485,6 +485,37 @@ func TestRootStorageMethodDispatchSplitsTheGuard(t *testing.T) {}}+func TestRootStorageRefusesADialogBlockedTabForEveryMethod(t *testing.T) {+ cases := []struct {+ method string+ body string+ }{+ {http.MethodGet, ""},+ {http.MethodPost, `{"type":"local","key":"probe","value":"1"}`},+ {http.MethodDelete, `{"type":"local","key":"probe"}`},+ }++ for _, tc := range cases {+ t.Run(tc.method, func(t *testing.T) {+ b := &guardProbeBridge{currentURL: "https://allowed.example/", dialogs: pendingDialogManager()}+ h := New(b, allCapabilities(t, t.TempDir()), nil, nil, nil)++ req := httptest.NewRequest(tc.method, "/storage?tabId=tab1&type=local&key=probe", strings.NewReader(tc.body))+ req.Header.Set("Content-Type", "application/json")+ w := httptest.NewRecorder()+ h.HandleStorage(w, req)++ var resp struct {+ Code string `json:"code"`+ }+ _ = json.Unmarshal(w.Body.Bytes(), &resp)+ if resp.Code != dialogBlockedCode {+ t.Fatalf("%s /storage on a dialog-blocked tab answered %d %s, want %s", tc.method, w.Code, w.Body.String(), dialogBlockedCode)+ }+ })+ }+}+var mustDeclareDialogGuard = []string{"POST /navigate", "POST /back", "POST /forward", "POST /reload","GET /snapshot", "GET /screenshot", "GET /annotate", "GET /capture", "GET /text", "GET /title", "GET /url", "GET /html", "GET /styles",@@ -494,6 +525,21 @@ var mustDeclareDialogGuard = []string{"POST /upload", "POST /solve", "POST /solve/{name}", "GET /download","POST /emulation/viewport", "POST /emulation/geolocation", "POST /emulation/offline","POST /emulation/headers", "POST /emulation/credentials", "POST /emulation/media",+ "POST /fingerprint/rotate",+ "GET /storage", "POST /storage", "DELETE /storage",+ "GET /state", "POST /state/save", "POST /state/load",+}++var dialogGuardAllowReasons = map[string]bool{+ "dialog": true,+ "frame": true,+ "tabs": true,+ "handoff": true,+ "own-tab": true,+ "browser-side": true,+ "buffer": true,+ "server-side": true,+ "screencast": true,}var dialogGuardAllowList = map[string]string{@@ -538,20 +584,13 @@ var dialogGuardAllowList = map[string]string{"POST /console/clear": "buffer","GET /errors": "buffer","POST /errors/clear": "buffer",- "GET /clipboard/read": "unprobed",- "POST /clipboard/write": "unprobed",- "POST /clipboard/copy": "unprobed",- "GET /clipboard/paste": "unprobed",- "POST /fingerprint/rotate": "unprobed",- "GET /storage": "unprobed",- "POST /storage": "unprobed",- "DELETE /storage": "unprobed",- "GET /state": "unprobed",- "POST /state/save": "unprobed",- "POST /state/load": "unprobed",- "GET /screencast": "unprobed",- "POST /record/start": "unprobed",- "POST /record/stop": "unprobed",+ "GET /clipboard/read": "server-side",+ "POST /clipboard/write": "server-side",+ "POST /clipboard/copy": "server-side",+ "GET /clipboard/paste": "server-side",+ "GET /screencast": "screencast",+ "POST /record/start": "screencast",+ "POST /record/stop": "screencast",}func TestEveryBindingIsPlacedForTheDialogGuard(t *testing.T) {@@ -572,8 +611,8 @@ func TestEveryBindingIsPlacedForTheDialogGuard(t *testing.T) {t.Errorf("%s drives the page through CDP but does not declare guardDialogBlocked", b.pattern)case allowed && declared:t.Errorf("%s declares guardDialogBlocked but is allow-listed (%s); move it to the must-declare set", b.pattern, reason)- case allowed && reason == "":- t.Errorf("%s is allow-listed without a reason", b.pattern)+ case allowed && !dialogGuardAllowReasons[reason]:+ t.Errorf("%s is allow-listed with %q, which places nothing; give it one of the reasons in dialogGuardAllowReasons or move it to the must-declare set", b.pattern, reason)case !must[b.pattern] && !allowed:t.Errorf("%s is in neither the must-declare set nor the allow-list; place it with a one-word reason", b.pattern)}