High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
feat(config): retire inert action guard setting (PIN-315)
Luigi Agostib29940581640
diff --git a/internal/bridge/guards_test.go b/internal/bridge/guards_test.goindex fc1cde86..ac31ab7e 100644--- a/internal/bridge/guards_test.go+++ b/internal/bridge/guards_test.go@@ -70,7 +70,7 @@ func TestEveryFormOfANavigatingActionReportsWhereItLanded(t *testing.T) {t.Run(tc.name, func(t *testing.T) {call := 0b := &Bridge{- Config: &config.RuntimeConfig{EnableActionGuards: true},+ Config: &config.RuntimeConfig{},URLReader: func(context.Context) (string, error) {call++if call == 1 {@@ -107,12 +107,8 @@ func TestReadActionURL_NoChromeDPContext(t *testing.T) {}}-func TestExecuteAction_ReportsTheNavigationOutcomeWhateverEnableActionGuardsSays(t *testing.T) {- settings := map[string]*config.RuntimeConfig{- "guards on": {EnableActionGuards: true},- "guards off": {EnableActionGuards: false},- "nil config": nil,- }+func TestExecuteActionAlwaysReportsTheNavigationOutcome(t *testing.T) {+ settings := map[string]*config.RuntimeConfig{"config": {}, "nil config": nil}for name, cfg := range settings {t.Run(name, func(t *testing.T) {t.Run("a navigating click reports where it landed", func(t *testing.T) {@@ -191,9 +187,9 @@ func assertNavigationOutcome(t *testing.T, res map[string]any, before, after str}}-func TestExecuteAction_ClassifiesStaleError_WhenGuardsDisabled(t *testing.T) {+func TestExecuteActionClassifiesStaleError(t *testing.T) {b := &Bridge{- Config: &config.RuntimeConfig{EnableActionGuards: false},+ Config: &config.RuntimeConfig{},Actions: map[string]ActionFunc{ActionType: func(context.Context, ActionRequest) (map[string]any, error) {return nil, errors.New("Node with given identifier does not exist")diff --git a/internal/config/config_action_guards_compat_test.go b/internal/config/config_action_guards_compat_test.gonew file mode 100644index 00000000..6423b608--- /dev/null+++ b/internal/config/config_action_guards_compat_test.go@@ -0,0 +1,23 @@+package config++import (+ "os"+ "path/filepath"+ "testing"+)++func TestLoadFileConfigAcceptsAndIgnoresRetiredEnableActionGuards(t *testing.T) {+ path := filepath.Join(t.TempDir(), "config.json")+ if err := os.WriteFile(path, []byte(`{"security":{"enableActionGuards":false}}`), 0o600); err != nil {+ t.Fatal(err)+ }+ t.Setenv("PINCHTAB_CONFIG", path)++ result := readAndParseConfigFile()+ if result.ParseErr != nil || result.UnknownFields != nil {+ t.Fatalf("legacy config did not load cleanly: parse=%v unknown=%v", result.ParseErr, result.UnknownFields)+ }+ if result.FC == nil {+ t.Fatal("legacy config produced no file config")+ }+}diff --git a/internal/config/config_file.go b/internal/config/config_file.goindex 39a99aba..09fc2bfc 100644--- a/internal/config/config_file.go+++ b/internal/config/config_file.go@@ -128,7 +128,6 @@ func DefaultFileConfig() FileConfig {allowUpload := falseallowClipboard := falseallowStateExport := false- enableActionGuards := trueuploadMaxRequestBytes := DefaultUploadMaxRequestBytesuploadMaxFiles := DefaultUploadMaxFilesuploadMaxFileBytes := DefaultUploadMaxFileBytes@@ -192,7 +191,6 @@ func DefaultFileConfig() FileConfig {AllowUpload: &allowUpload,AllowClipboard: &allowClipboard,AllowStateExport: &allowStateExport,- EnableActionGuards: &enableActionGuards,UploadMaxRequestBytes: &uploadMaxRequestBytes,UploadMaxFiles: &uploadMaxFiles,UploadMaxFileBytes: &uploadMaxFileBytes,diff --git a/internal/config/config_file_json.go b/internal/config/config_file_json.goindex bfec7168..0845b470 100644--- a/internal/config/config_file_json.go+++ b/internal/config/config_file_json.go@@ -96,7 +96,6 @@ type securityConfigJSON struct {AllowClipboard *bool `json:"allowClipboard"`AllowStateExport *bool `json:"allowStateExport"`StateEncryptionKey *string `json:"stateEncryptionKey"`- EnableActionGuards *bool `json:"enableActionGuards"`UploadMaxRequestBytes *int `json:"uploadMaxRequestBytes"`UploadMaxFiles *int `json:"uploadMaxFiles"`UploadMaxFileBytes *int `json:"uploadMaxFileBytes"`diff --git a/internal/config/config_file_marshal.go b/internal/config/config_file_marshal.goindex a6078ae3..5dfe9b90 100644--- a/internal/config/config_file_marshal.go+++ b/internal/config/config_file_marshal.go@@ -329,7 +329,6 @@ func (s SecurityConfig) wire() securityConfigJSON {AllowClipboard: s.AllowClipboard,AllowStateExport: s.AllowStateExport,StateEncryptionKey: s.StateEncryptionKey,- EnableActionGuards: s.EnableActionGuards,UploadMaxRequestBytes: s.UploadMaxRequestBytes,UploadMaxFiles: s.UploadMaxFiles,UploadMaxFileBytes: s.UploadMaxFileBytes,@@ -400,7 +399,6 @@ func FileConfigFromRuntime(cfg *RuntimeConfig) FileConfig {allowUpload := cfg.AllowUploadallowClipboard := cfg.AllowClipboardallowStateExport := cfg.AllowStateExport- enableActionGuards := cfg.EnableActionGuardsuploadMaxRequestBytes := cfg.EffectiveUploadMaxRequestBytes()uploadMaxFiles := cfg.EffectiveUploadMaxFiles()uploadMaxFileBytes := cfg.EffectiveUploadMaxFileBytes()@@ -533,7 +531,6 @@ func FileConfigFromRuntime(cfg *RuntimeConfig) FileConfig {AllowUpload: &allowUpload,AllowClipboard: &allowClipboard,AllowStateExport: &allowStateExport,- EnableActionGuards: &enableActionGuards,UploadMaxRequestBytes: &uploadMaxRequestBytes,UploadMaxFiles: &uploadMaxFiles,UploadMaxFileBytes: &uploadMaxFileBytes,diff --git a/internal/config/config_load.go b/internal/config/config_load.goindex 2448c104..3215babe 100644--- a/internal/config/config_load.go+++ b/internal/config/config_load.go@@ -212,7 +212,6 @@ func LoadConfig() (*RuntimeConfig, []LoadDiagnostic, error) {AllowClipboard: false,AllowStateExport: false,StateEncryptionKey: "",- EnableActionGuards: true,UploadMaxRequestBytes: DefaultUploadMaxRequestBytes,UploadMaxFiles: DefaultUploadMaxFiles,UploadMaxFileBytes: DefaultUploadMaxFileBytes,@@ -486,9 +485,6 @@ func applySecurityConfig(cfg *RuntimeConfig, s SecurityConfig) {if s.StateEncryptionKey != nil {cfg.StateEncryptionKey = *s.StateEncryptionKey}- if s.EnableActionGuards != nil {- cfg.EnableActionGuards = *s.EnableActionGuards- }if s.UploadMaxRequestBytes != nil {cfg.UploadMaxRequestBytes = clampPositiveLimit(*s.UploadMaxRequestBytes, DefaultUploadMaxRequestBytes, MaxUploadMaxRequestBytes)}diff --git a/internal/config/config_load_test.go b/internal/config/config_load_test.goindex ce23f453..d1782a9a 100644--- a/internal/config/config_load_test.go+++ b/internal/config/config_load_test.go@@ -51,9 +51,6 @@ func TestLoadConfigDefaults(t *testing.T) {if cfg.AllowCookies {t.Errorf("default AllowCookies = %v, want false", cfg.AllowCookies)}- if !cfg.EnableActionGuards {- t.Errorf("default EnableActionGuards = %v, want true", cfg.EnableActionGuards)- }if cfg.TrustProxyHeaders {t.Errorf("default TrustProxyHeaders = %v, want false", cfg.TrustProxyHeaders)}@@ -452,9 +449,6 @@ func TestApplyFileConfigToRuntimeResetsSecurityFlagsToSafeDefaults(t *testing.T)if cfg.AllowUpload {t.Errorf("ApplyFileConfigToRuntime AllowUpload = %v, want false", cfg.AllowUpload)}- if !cfg.EnableActionGuards {- t.Errorf("ApplyFileConfigToRuntime EnableActionGuards = %v, want true", cfg.EnableActionGuards)- }if len(cfg.DownloadAllowedDomains) != 0 {t.Errorf("ApplyFileConfigToRuntime DownloadAllowedDomains = %v, want empty list", cfg.DownloadAllowedDomains)}diff --git a/internal/config/config_types.go b/internal/config/config_types.goindex c18bbd1d..890ef0d2 100644--- a/internal/config/config_types.go+++ b/internal/config/config_types.go@@ -40,7 +40,6 @@ type RuntimeConfig struct {AllowClipboard boolAllowStateExport boolStateEncryptionKey string // Key for encrypting state files (AES-256-GCM)- EnableActionGuards bool // Enable bridge-level stale/navigation guard checks around actionsUploadMaxRequestBytes intUploadMaxFiles intUploadMaxFileBytes int@@ -467,7 +466,6 @@ type SecurityConfig struct {AllowClipboard *bool `json:"allowClipboard,omitempty"`AllowStateExport *bool `json:"allowStateExport,omitempty"`StateEncryptionKey *string `json:"stateEncryptionKey,omitempty"`- EnableActionGuards *bool `json:"enableActionGuards,omitempty"`UploadMaxRequestBytes *int `json:"uploadMaxRequestBytes,omitempty"`UploadMaxFiles *int `json:"uploadMaxFiles,omitempty"`UploadMaxFileBytes *int `json:"uploadMaxFileBytes,omitempty"`diff --git a/internal/config/config_unknown_keys.go b/internal/config/config_unknown_keys.goindex f12e665a..d8d51774 100644--- a/internal/config/config_unknown_keys.go+++ b/internal/config/config_unknown_keys.go@@ -37,7 +37,7 @@ func UnknownFileConfigKeys(data []byte) []string {if err := json.Unmarshal(data, &root); err != nil {return nil}- keys := collectUnknownKeys("", root, reflect.TypeOf(FileConfig{}), aliasFileConfigPaths())+ keys := collectUnknownKeys("", root, reflect.TypeOf(FileConfig{}), acceptedUndeclaredFileConfigPaths())sort.Strings(keys)return keys}@@ -157,6 +157,14 @@ func aliasFileConfigPaths() map[string]bool {return exempt}+func acceptedUndeclaredFileConfigPaths() map[string]bool {+ exempt := aliasFileConfigPaths()+ // Retired in PIN-315. Existing config files must continue to load, but the+ // key is deliberately absent from FileConfig, the editor, and the schema.+ exempt["security.enableActionGuards"] = true+ return exempt+}+func declaredPaths(prefix string, structType reflect.Type) []string {structType = derefType(structType)if structType.Kind() != reflect.Struct {diff --git a/internal/config/config_unknown_keys_test.go b/internal/config/config_unknown_keys_test.goindex 45ddc5b5..1351ec5c 100644--- a/internal/config/config_unknown_keys_test.go+++ b/internal/config/config_unknown_keys_test.go@@ -65,6 +65,13 @@ func TestUnknownFileConfigKeysAcceptsADocumentOfDeclaredKeys(t *testing.T) {}}+func TestUnknownFileConfigKeysAcceptsRetiredEnableActionGuards(t *testing.T) {+ keys := UnknownFileConfigKeys([]byte(`{"security":{"enableActionGuards":false}}`))+ if len(keys) != 0 {+ t.Fatalf("retired compatibility key reported as unknown: %v", keys)+ }+}+// browser.targets keys are operator-chosen, so a target name can never be an// unknown key — but a misspelled field INSIDE one still must be.func TestUnknownFileConfigKeysTreatsMapKeysAsOpenAndStillChecksTheirValues(t *testing.T) {diff --git a/internal/config/editor_get.go b/internal/config/editor_get.goindex ca8351b6..99e2f17b 100644--- a/internal/config/editor_get.go+++ b/internal/config/editor_get.go@@ -367,8 +367,6 @@ func getSecurityField(s *SecurityConfig, field string) (string, error) {return formatIntPtr(s.DownloadMaxBytes), nilcase "allowUpload":return formatBoolPtr(s.AllowUpload), nil- case "enableActionGuards":- return formatBoolPtr(s.EnableActionGuards), nilcase "uploadMaxRequestBytes":return formatIntPtr(s.UploadMaxRequestBytes), nilcase "uploadMaxFiles":diff --git a/internal/config/editor_get_test.go b/internal/config/editor_get_test.goindex 2d434905..64e74e1c 100644--- a/internal/config/editor_get_test.go+++ b/internal/config/editor_get_test.go@@ -53,7 +53,6 @@ func TestGetConfigValue_RoundTrip(t *testing.T) {{"security.downloadAllowedDomains", "pinchtab.com,*.pinchtab.com", "pinchtab.com,*.pinchtab.com"},{"security.downloadMaxBytes", "33554432", "33554432"},{"security.allowUpload", "yes", "true"},- {"security.enableActionGuards", "0", "false"},{"security.uploadMaxRequestBytes", "12582912", "12582912"},{"security.uploadMaxFiles", "12", "12"},{"security.uploadMaxFileBytes", "6291456", "6291456"},@@ -118,7 +117,6 @@ func TestGetConfigValue_NilPointerReturnsEmpty(t *testing.T) {"security.allowStateExport","security.downloadMaxBytes","security.allowUpload",- "security.enableActionGuards","security.uploadMaxRequestBytes","security.uploadMaxFiles","security.uploadMaxFileBytes",@@ -182,12 +180,13 @@ func TestGetConfigValue_AttachSlices(t *testing.T) {func TestGetConfigValue_UnknownPaths(t *testing.T) {fc := &FileConfig{}errorCases := []string{- "port", // missing section- "", // empty- "unknown.field", // unknown section- "server.ghost", // unknown field in known section- "security.attach.badfield", // unknown attach field- "security.idpi.badfield", // unknown idpi field+ "port", // missing section+ "", // empty+ "unknown.field", // unknown section+ "server.ghost", // unknown field in known section+ "security.attach.badfield", // unknown attach field+ "security.idpi.badfield", // unknown idpi field+ "security.enableActionGuards", // retired field}for _, path := range errorCases {t.Run(path, func(t *testing.T) {diff --git a/internal/config/editor_set.go b/internal/config/editor_set.goindex f952b2f7..f915f17e 100644--- a/internal/config/editor_set.go+++ b/internal/config/editor_set.go@@ -506,7 +506,6 @@ var securityBoolFields = map[string]bool{"allowUpload": true,"allowNetworkIntercept": true,"allowFileScheme": true,- "enableActionGuards": true,"trustLoopbackProxy": true,}@@ -619,8 +618,6 @@ func setSecurityField(s *SecurityConfig, field, value string) error {s.AllowNetworkIntercept = &bcase "allowFileScheme":s.AllowFileScheme = &b- case "enableActionGuards":- s.EnableActionGuards = &bcase "trustLoopbackProxy":s.TrustLoopbackProxy = &bdefault:diff --git a/internal/config/editor_set_test.go b/internal/config/editor_set_test.goindex b5cfaa70..5f5b0008 100644--- a/internal/config/editor_set_test.go+++ b/internal/config/editor_set_test.go@@ -171,9 +171,6 @@ func TestSetConfigValue_SecurityFields(t *testing.T) {return fc.Security.DownloadMaxBytes != nil && *fc.Security.DownloadMaxBytes == 33554432}, false},{"security.allowUpload", "off", func(fc *FileConfig) bool { return *fc.Security.AllowUpload == false }, false},- {"security.enableActionGuards", "true", func(fc *FileConfig) bool {- return fc.Security.EnableActionGuards != nil && *fc.Security.EnableActionGuards- }, false},{"security.uploadMaxRequestBytes", "12582912", func(fc *FileConfig) bool {return fc.Security.UploadMaxRequestBytes != nil && *fc.Security.UploadMaxRequestBytes == 12582912}, false},@@ -188,7 +185,6 @@ func TestSetConfigValue_SecurityFields(t *testing.T) {}, false},{"security.allowEvaluate", "maybe", nil, true},{"security.allowClipboard", "maybe", nil, true},- {"security.enableActionGuards", "maybe", nil, true},{"security.unknown", "true", nil, true},}@@ -354,11 +350,12 @@ func TestSetConfigValue_TimeoutsFields(t *testing.T) {func TestSetConfigValue_InvalidPaths(t *testing.T) {tests := []string{- "port", // missing section- "", // empty- "unknown.field", // unknown section- "server", // missing field- "a.b.c", // too many parts (we only split on first .)+ "port", // missing section+ "", // empty+ "unknown.field", // unknown section+ "server", // missing field+ "security.enableActionGuards", // retired field+ "a.b.c", // too many parts (we only split on first .)}for _, path := range tests {diff --git a/internal/handlers/action_navigation_invalidation_test.go b/internal/handlers/action_navigation_invalidation_test.goindex 476b9340..12dfbb33 100644--- a/internal/handlers/action_navigation_invalidation_test.go+++ b/internal/handlers/action_navigation_invalidation_test.go@@ -59,10 +59,9 @@ func clickNavHandlers(t *testing.T) (*Handlers, string) {}cfg := &config.RuntimeConfig{- ActionTimeout: 10 * time.Second,- DefaultBrowser: config.BrowserChrome,- StateDir: t.TempDir(),- EnableActionGuards: true,+ ActionTimeout: 10 * time.Second,+ DefaultBrowser: config.BrowserChrome,+ StateDir: t.TempDir(),}b := bridge.New(context.Background(), ctx, cfg)const tabID = "tab-click-nav"diff --git a/internal/handlers/action_stale_submit_test.go b/internal/handlers/action_stale_submit_test.goindex a6dc93ea..d2aeb313 100644--- a/internal/handlers/action_stale_submit_test.go+++ b/internal/handlers/action_stale_submit_test.go@@ -102,13 +102,10 @@ func staleSubmitHandlers(t *testing.T, f orderFixture) (*Handlers, context.Contet.Fatal(err)}- // EnableActionGuards is what turns the unexpected-navigation check on; without it the- // bridge never compares the URL and the navigation half of this card is unobservable.cfg := &config.RuntimeConfig{- ActionTimeout: 10 * time.Second,- DefaultBrowser: config.BrowserChrome,- StateDir: t.TempDir(),- EnableActionGuards: true,+ ActionTimeout: 10 * time.Second,+ DefaultBrowser: config.BrowserChrome,+ StateDir: t.TempDir(),}b := bridge.New(context.Background(), ctx, cfg)const tabID = "tab-stale-submit"diff --git a/internal/schema/config.json b/internal/schema/config.jsonindex e21b8a86..95afc680 100644--- a/internal/schema/config.json+++ b/internal/schema/config.json@@ -503,9 +503,6 @@"stateEncryptionKey": {"$ref": "#/definitions/nullableString"},- "enableActionGuards": {- "$ref": "#/definitions/nullableBoolean"- },"uploadMaxRequestBytes": {"anyOf": [{