High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: the section vocabulary is derived from FileConfig but the… (PIN-204)
Luigi Agostie11830ec2261
diff --git a/cmd/pinchtab/cmd_config_secret_test.go b/cmd/pinchtab/cmd_config_secret_test.goindex e0ea1fc0..31c4af41 100644--- a/cmd/pinchtab/cmd_config_secret_test.go+++ b/cmd/pinchtab/cmd_config_secret_test.go@@ -6,6 +6,13 @@ import "testing"// back, so every config path holding secret material must be masked. The// schema's secret-bearing fields are capsolverKey, twoCaptchaKey,// stateEncryptionKey, password, token and the credentials subtree.+//+// This is where the masking rule lives, and it is a DISPLAY property of these+// two commands rather than of the field: a surface that publishes config values+// some other way inherits none of it. security.stateEncryptionKey is only+// readable through the editor at all because the section-leaf walk in+// internal/config required every declared leaf to resolve, so this list is what+// keeps that reachability from printing a secret.func TestIsSensitiveConfigPathCoversEverySecretField(t *testing.T) {sensitive := []string{"server.token",diff --git a/internal/config/config_file_json.go b/internal/config/config_file_json.goindex 71fe565d..7122ce30 100644--- a/internal/config/config_file_json.go+++ b/internal/config/config_file_json.go@@ -72,6 +72,7 @@ type instanceDefaultsConfigJSON struct {StealthLevel string `json:"stealthLevel"`TabEvictionPolicy string `json:"tabEvictionPolicy"`TabPolicy *TabPolicyDefaults `json:"tabPolicy,omitempty"`+ DialogAutoAccept *bool `json:"dialogAutoAccept,omitempty"`}type profilesConfigJSON struct {diff --git a/internal/config/config_file_marshal.go b/internal/config/config_file_marshal.goindex 18185ded..b8b84215 100644--- a/internal/config/config_file_marshal.go+++ b/internal/config/config_file_marshal.go@@ -207,6 +207,7 @@ func (fc FileConfig) MarshalJSON() ([]byte, error) {StealthLevel: fc.InstanceDefaults.StealthLevel,TabEvictionPolicy: fc.InstanceDefaults.TabEvictionPolicy,TabPolicy: fc.InstanceDefaults.TabPolicy,+ DialogAutoAccept: fc.InstanceDefaults.DialogAutoAccept,},Security: securityConfigJSON{AllowEvaluate: fc.Security.AllowEvaluate,@@ -423,6 +424,7 @@ func FileConfigFromRuntime(cfg *RuntimeConfig) FileConfig {autoSolverLLMFallback := cfg.AutoSolver.LLMFallbackquarantineKeep := cfg.ProfileQuarantineKeep+ dialogAutoAccept := cfg.DialogAutoAcceptmode := "headless"if !cfg.Headless {@@ -493,6 +495,7 @@ func FileConfigFromRuntime(cfg *RuntimeConfig) FileConfig {StealthLevel: cfg.StealthLevel,TabEvictionPolicy: cfg.TabEvictionPolicy,TabPolicy: tabPolicyDefaultsFromRuntime(cfg),+ DialogAutoAccept: &dialogAutoAccept,},Security: SecurityConfig{AllowEvaluate: &allowEvaluate,diff --git a/internal/config/editor_get.go b/internal/config/editor_get.goindex 9a2d72e5..759e62b2 100644--- a/internal/config/editor_get.go+++ b/internal/config/editor_get.go@@ -32,6 +32,12 @@ func getServerField(s *ServerConfig, field string) (string, error) {return s.StateDir, nilcase "logLevel":return s.LogLevel, nil+ case "networkBufferSize":+ return formatIntPtr(s.NetworkBufferSize), nil+ case "retainNetworkBodies":+ return formatBoolPtr(s.RetainNetworkBodies), nil+ case "retainNetworkBodyMaxBytes":+ return formatIntPtr(s.RetainNetworkBodyMaxBytes), nilcase "trustProxyHeaders":return formatBoolPtr(s.TrustProxyHeaders), nilcase "cookieSecure":@@ -60,6 +66,10 @@ func getBrowserField(b *BrowserConfig, field string) (string, error) {return b.BrowserBinary, nilcase "extraFlags":return b.BrowserExtraFlags, nil+ case "remoteDebuggingPort":+ return formatIntPtr(b.BrowserDebugPort), nil+ case "extensionPaths":+ return strings.Join(b.ExtensionPaths, ","), nilcase "defaultTarget":return b.DefaultTarget, nilcase "fallbackOrder":@@ -268,6 +278,8 @@ func getInstanceDefaultsField(c *InstanceDefaultsConfig, field string) (string,return c.StealthLevel, nilcase "tabEvictionPolicy":return c.TabEvictionPolicy, nil+ case "dialogAutoAccept":+ return formatBoolPtr(c.DialogAutoAccept), nildefault:return "", fmt.Errorf("unknown field instanceDefaults.%s", field)}@@ -284,6 +296,8 @@ func getTabPolicyField(tp *TabPolicyDefaults, field string) (string, error) {return tp.Lifecycle, nilcase "closeDelaySec":return formatIntPtr(tp.CloseDelaySec), nil+ case "restore":+ return formatBoolPtr(tp.Restore), nildefault:return "", fmt.Errorf("unknown field instanceDefaults.tabPolicy.%s", field)}@@ -312,6 +326,8 @@ func getSecurityField(s *SecurityConfig, field string) (string, error) {return formatBoolPtr(s.AllowCookies), nilcase "allowStateExport":return formatBoolPtr(s.AllowStateExport), nil+ case "stateEncryptionKey":+ return formatStringPtr(s.StateEncryptionKey), nilcase "allowNetworkIntercept":return formatBoolPtr(s.AllowNetworkIntercept), nilcase "allowFileScheme":@@ -424,6 +440,10 @@ func getIDPIField(i *IDPIConfig, field string) (string, error) {return strconv.FormatBool(i.WrapContent), nilcase "customPatterns":return strings.Join(i.CustomPatterns, ","), nil+ case "scanTimeoutSec":+ return strconv.Itoa(i.ScanTimeoutSec), nil+ case "shieldThreshold":+ return strconv.Itoa(i.ShieldThreshold), nildefault:return "", fmt.Errorf("unknown field security.idpi.%s", field)}@@ -454,6 +474,13 @@ func formatBoolPtr(b *bool) string {return "false"}+func formatStringPtr(s *string) string {+ if s == nil {+ return ""+ }+ return *s+}+func formatIntPtr(n *int) string {if n == nil {return ""@@ -610,6 +637,20 @@ func addSettledDefaults(resolved *FileConfig, cfg *RuntimeConfig) {if strings.TrimSpace(resolved.Server.LogLevel) == "" {resolved.Server.LogLevel = safelog.LevelName(safelog.DefaultLevel)}+ // The writer omits a false tab-restore (a vanilla tab policy is left out of a file the+ // operator did not ask for) and omits the state encryption key entirely, so a generated+ // child instance config never carries a secret. Both are settled values a reader has to+ // see, taken off the RuntimeConfig rather than restated here.+ if resolved.InstanceDefaults.TabPolicy == nil {+ resolved.InstanceDefaults.TabPolicy = &TabPolicyDefaults{}+ }+ if resolved.InstanceDefaults.TabPolicy.Restore == nil {+ resolved.InstanceDefaults.TabPolicy.Restore = boolPtrValue(cfg.TabRestore)+ }+ if resolved.Security.StateEncryptionKey == nil && cfg.StateEncryptionKey != "" {+ key := cfg.StateEncryptionKey+ resolved.Security.StateEncryptionKey = &key+ }resolved.Scheduler = SchedulerFileConfig{Enabled: boolPtrValue(cfg.Scheduler.Enabled),Strategy: cfg.Scheduler.Strategy,diff --git a/internal/config/editor_get_effective_test.go b/internal/config/editor_get_effective_test.goindex c325202c..3b55504d 100644--- a/internal/config/editor_get_effective_test.go+++ b/internal/config/editor_get_effective_test.go@@ -88,6 +88,8 @@ var blankIsTheAnswer = map[string]string{"browser.cloak.fontsDir": "cloak override, unset","browser.cloak.storageQuotaMB": "cloak override, unset","browser.cloak.disableDefaultStealthArgs": "cloak override, unset",+ "browser.remoteDebuggingPort": "unset means a debugging port is chosen when the browser launches, so there is no configured value to report",+ "security.stateEncryptionKey": "no state encryption key configured, and the CLI masks this leaf when there is one","browser.proxy.server": "no proxy configured","browser.proxy.bypassList": "no proxy configured","browser.proxy.username": "no proxy configured",@@ -123,6 +125,8 @@ var blankIsTheAnswer = map[string]string{// hardcoded value in the print path.var defaultLivesAtItsConsumer = map[string]string{"server.cookieSecure": "there is no single value: the cookie layer decides per request from that request's scheme, so any printed answer would be wrong for half the requests",++ "server.networkBufferSize": "the per-tab buffer default is DefaultNetworkBufferSize in the network buffer itself, applied when the configured size is zero; the config layer never settles it, so reporting a number here would be this package's own guess",}// TestEveryAddressableConfigKeyAnswersOrIsAccountedFor is the standing census behinddiff --git a/internal/config/editor_sections_test.go b/internal/config/editor_sections_test.goindex da90255a..f3de5fa7 100644--- a/internal/config/editor_sections_test.go+++ b/internal/config/editor_sections_test.go@@ -1,7 +1,9 @@package configimport (+ "encoding/json""reflect"+ "sort""strings""testing"@@ -151,3 +153,294 @@ func declaredFileConfigSections(t *testing.T) []string {}return names}++// unreachableConfigLeaves records the leaf paths a section declares that config set/get+// deliberately do NOT address, with the reason each is excluded. The walk below fails both+// ways: a leaf missing from the resolvers and from this table is a gap, and an entry here+// that now resolves is stale and must be deleted. Padding the table to silence the walk is+// therefore visible in review as a reason someone had to write.+var unreachableConfigLeaves = map[string]string{+ "server.engine": "removed setting, parsed only so an old config gets a validation error; making it settable would offer an operator a value nothing honours",++ "instanceDefaults.headless": "superseded by instanceDefaults.mode, which is the spelling the file writer renders; setting both is a validation error, and a settable headless would be dropped by MarshalJSON and read as accepted-then-discarded",++ "sessions.agent.enabled": "owned by the agent-session editor card, which also has to teach MarshalJSON the agent block — the editor half alone would report success and write nothing",+ "sessions.agent.mode": "owned by the agent-session editor card (see sessions.agent.enabled)",+ "sessions.agent.idleTimeoutSec": "owned by the agent-session editor card (see sessions.agent.enabled)",+ "sessions.agent.maxLifetimeSec": "owned by the agent-session editor card (see sessions.agent.enabled)",+}++// unreachableConfigSubtrees are whole blocks excluded by one reason, so the table does not+// have to list every leaf of a retired structure.+var unreachableConfigSubtrees = map[string]string{+ "browsers.config.": "retired block, never applied anywhere and superseded by browser.targets; parsed only so validation can reject it with guidance and so existing files round-trip",+}++// The section walk one level down. The section vocabulary is derived from FileConfig and+// pinned above; the per-field vocabulary was still hand-written switches tied to nothing,+// so a field added to a section struct was honoured by the loader, documented by the+// schema, and silently unaddressable from the CLI. This walks the section structs' json+// tags instead: a leaf that resolves through neither resolver has to be either wired up or+// written down.+func TestEveryDeclaredSectionLeafIsReachableFromBothResolvers(t *testing.T) {+ leaves := declaredSectionLeaves(t)+ if len(leaves) < 100 {+ t.Fatalf("walked %d leaves across the section structs; this walk would be vacuous", len(leaves))+ }++ exempted := map[string]bool{}+ for _, leaf := range leaves {+ reason, key := exemptionFor(leaf.path)++ // The probe carries a value of the type the section struct declares, so a refusal+ // can only be about the PATH. Probing every leaf with one string made a setter that+ // parses before it dispatches answer "invalid boolean" for a string field, which+ // reads as a value complaint and hid a leaf no value could ever set.+ // One config per leaf, written before it is read: a map-keyed block (browser+ // targets) only has the key an operator just created, so reading a fresh config+ // would report "not found" for every one of its leaves.+ fc := newProbeConfig()+ setErr := SetConfigValue(fc, leaf.path, leaf.probe)+ _, getErr := GetConfigValue(fc, leaf.path)++ if reason == "" {+ if policy, refused := refusedByPolicy[leaf.path]; refused {+ if setErr == nil && getErr == nil {+ t.Errorf("%s is recorded as refused by policy (%q) but both resolvers now accept it; delete the entry", leaf.path, policy)+ }+ exempted[leaf.path] = true+ continue+ }+ if setErr != nil {+ t.Errorf("config set %s = %q was refused (%v): the leaf is declared on the section struct and honoured by the loader, so wire it into the setter, or record it in unreachableConfigLeaves / refusedByPolicy with a reason", leaf.path, leaf.probe, setErr)+ }+ if getErr != nil {+ t.Errorf("config get %s was refused (%v): wire it into the getter, or record it with a reason", leaf.path, getErr)+ }+ continue+ }++ exempted[key] = true+ if !isUnknownFieldRefusal(setErr) && !isUnknownFieldRefusal(getErr) {+ t.Errorf("%s resolves through both resolvers but is still recorded as unreachable (%q); delete the entry — a stale exemption hides the next gap", leaf.path, reason)+ }+ }++ // The exemption table cannot outlive what it excuses: an entry naming a path the walk+ // no longer produces would excuse nothing and read as coverage.+ for path := range unreachableConfigLeaves {+ if !exempted[path] {+ t.Errorf("unreachableConfigLeaves records %q, which is not a leaf any section struct declares", path)+ }+ }+ for path := range refusedByPolicy {+ if !exempted[path] {+ t.Errorf("refusedByPolicy records %q, which is not a leaf any section struct declares", path)+ }+ }+ for prefix := range unreachableConfigSubtrees {+ if !exempted[prefix] {+ t.Errorf("unreachableConfigSubtrees records %q, which matches no leaf any section struct declares", prefix)+ }+ }+}++// stateEncryptionKey is a secret and this card made it readable, so the reachability is+// pinned here while the masking stays pinned where the rule lives: isSensitiveConfigPath in+// cmd/pinchtab already lists this exact path, and restating its suffix rule here would be a+// second copy free to drift. What this package owns is the leaf answering at all.+//+// Masking is a DISPLAY property of `pinchtab config get`, not a property of the field: any+// later surface that publishes config values — an HTTP endpoint, a dashboard view — inherits+// none of it and has to mask on its own.+func TestTheStateEncryptionKeyLeafIsReadableSoItsMaskingMatters(t *testing.T) {+ const path = "security.stateEncryptionKey"++ fc := newProbeConfig()+ if err := SetConfigValue(fc, path, "sekret"); err != nil {+ t.Fatalf("set %s: %v", path, err)+ }+ value, err := GetConfigValue(fc, path)+ if err != nil {+ t.Fatalf("get %s: %v", path, err)+ }+ if value != "sekret" {+ t.Fatalf("get %s = %q, want the value just set", path, value)+ }+}++func newProbeConfig() *FileConfig {+ return &FileConfig{}+}++// isUnknownFieldRefusal separates "this resolver does not know the path" from every other+// refusal. A typed rejection (a bad value, a removed setting) means the leaf RESOLVED,+// which is what this walk is about.+func isUnknownFieldRefusal(err error) bool {+ return err != nil && strings.Contains(err.Error(), "unknown field")+}++func exemptionFor(path string) (reason, key string) {+ if reason, ok := unreachableConfigLeaves[path]; ok {+ return reason, path+ }+ for prefix, reason := range unreachableConfigSubtrees {+ if strings.HasPrefix(path, prefix) {+ return reason, prefix+ }+ }+ return "", ""+}++// declaredSectionLeaves walks each section in configSections through the struct FileConfig+// declares for it, so the paths come from the type rather than from a list somebody+// maintains. Map-valued blocks are walked through a synthetic key: their leaves are what+// the resolvers address, and the key itself is the operator's choice.+// refusedByPolicy are leaves both resolvers KNOW and deliberately refuse, which is a+// different answer from not knowing them: the operator is told what to use instead.+var refusedByPolicy = map[string]string{+ "browser.provider": "removed in favour of browsers.default; both resolvers answer with that redirection rather than an unknown-field refusal",++ "observability.activity.stateDir": "derived from server.stateDir so two instances cannot share an activity log directory; the setter refuses it by naming the key to set instead, and the getter still reads it",+}++type sectionLeaf struct {+ path string+ probe string+}++func declaredSectionLeaves(t *testing.T) []sectionLeaf {+ t.Helper()++ fields := map[string]reflect.Type{}+ typ := reflect.TypeOf(FileConfig{})+ for i := 0; i < typ.NumField(); i++ {+ name := strings.Split(typ.Field(i).Tag.Get("json"), ",")[0]+ fields[name] = typ.Field(i).Type+ }++ var leaves []sectionLeaf+ for _, section := range configSections {+ sectionType, ok := fields[section.name]+ if !ok {+ t.Fatalf("configSections lists %q, which FileConfig does not declare", section.name)+ }+ appendLeafPaths(t, section.name, sectionType, &leaves)+ }+ sort.Slice(leaves, func(i, j int) bool { return leaves[i].path < leaves[j].path })+ return leaves+}++// probeValueFor renders a value of the leaf's declared type. Values are chosen to survive+// the validation the setters apply (a hostname for a domain list, a percentage for a+// threshold), because a probe rejected on its content would report a gap that is not one.+func probeValueFor(t *testing.T, path string, typ reflect.Type) string {+ t.Helper()+ for typ.Kind() == reflect.Ptr {+ typ = typ.Elem()+ }+ switch typ.Kind() {+ case reflect.Bool:+ return "true"+ case reflect.Int, reflect.Int64:+ return "7"+ case reflect.Float64:+ return "7"+ case reflect.Slice:+ return "example.com"+ case reflect.String:+ return probeStringFor(path)+ default:+ t.Fatalf("%s has unsupported leaf kind %s; teach the walk how to probe it", path, typ.Kind())+ return ""+ }+}++// probeStringFor supplies the few string leaves whose setter validates the value against a+// vocabulary. Everything else takes a plain marker.+func probeStringFor(path string) string {+ switch path {+ case "server.logLevel":+ return "info"+ case "browsers.default":+ return "chrome"+ case "instanceDefaults.mode":+ return "headless"+ case "browser.targets.probe.provider":+ return "chrome"+ }+ return "probe"+}++func appendLeafPaths(t *testing.T, prefix string, typ reflect.Type, leaves *[]sectionLeaf) {+ t.Helper()+ for typ.Kind() == reflect.Ptr {+ typ = typ.Elem()+ }+ switch typ.Kind() {+ case reflect.Struct:+ for i := 0; i < typ.NumField(); i++ {+ tag := typ.Field(i).Tag.Get("json")+ if tag == "" || tag == "-" {+ t.Errorf("%s.%s has no json tag, so it cannot be addressed by path", prefix, typ.Field(i).Name)+ continue+ }+ appendLeafPaths(t, prefix+"."+strings.Split(tag, ",")[0], typ.Field(i).Type, leaves)+ }+ case reflect.Map:+ appendLeafPaths(t, prefix+".probe", typ.Elem(), leaves)+ default:+ *leaves = append(*leaves, sectionLeaf{path: prefix, probe: probeValueFor(t, prefix, typ)})+ }+}++// The other half of reachable: a value config set accepts has to survive the file writer.+// FileConfig renders through a hand-built JSON twin, so a leaf wired into the editor but+// missing from that twin reports success and writes nothing — accept-and-discard, which is+// worse than the unknown-field refusal it replaced. This drives every settable leaf through+// the same marshal/unmarshal the save path uses.+func TestEverySettableSectionLeafSurvivesTheFileWriter(t *testing.T) {+ leaves := declaredSectionLeaves(t)+ checked := 0++ for _, leaf := range leaves {+ if reason, _ := exemptionFor(leaf.path); reason != "" {+ continue+ }+ if _, refused := refusedByPolicy[leaf.path]; refused {+ continue+ }++ fc := newProbeConfig()+ if err := SetConfigValue(fc, leaf.path, leaf.probe); err != nil {+ continue // the reachability walk above owns this failure+ }+ want, err := GetConfigValue(fc, leaf.path)+ if err != nil {+ continue+ }++ encoded, err := json.Marshal(fc)+ if err != nil {+ t.Fatalf("marshal after setting %s: %v", leaf.path, err)+ }+ var reloaded FileConfig+ if err := json.Unmarshal(encoded, &reloaded); err != nil {+ t.Fatalf("reload after setting %s: %v", leaf.path, err)+ }++ got, err := GetConfigValue(&reloaded, leaf.path)+ if err != nil {+ t.Errorf("%s reads back as an error after a save/load round trip: %v", leaf.path, err)+ continue+ }+ if got != want {+ t.Errorf("config set %s = %q is accepted and then discarded: the value reads %q after the file writer round trip. Add the field to the JSON twin in config_file_json.go and to MarshalJSON, or the CLI reports success and writes nothing", leaf.path, want, got)+ }+ checked+++ }++ if checked < 100 {+ t.Fatalf("only %d settable leaves survived to the round-trip assertion; this guard would be vacuous", checked)+ }+}diff --git a/internal/config/editor_set.go b/internal/config/editor_set.goindex a9709364..1844a286 100644--- a/internal/config/editor_set.go+++ b/internal/config/editor_set.go@@ -35,6 +35,24 @@ func setServerField(s *ServerConfig, field, value string) error {return fmt.Errorf("server.logLevel: %w", err)}s.LogLevel = strings.ToLower(strings.TrimSpace(value))+ case "networkBufferSize":+ n, err := strconv.Atoi(value)+ if err != nil {+ return fmt.Errorf("server.networkBufferSize must be a number: %w", err)+ }+ s.NetworkBufferSize = &n+ case "retainNetworkBodies":+ b, err := parseBool(value)+ if err != nil {+ return fmt.Errorf("server.retainNetworkBodies must be true or false: %w", err)+ }+ s.RetainNetworkBodies = &b+ case "retainNetworkBodyMaxBytes":+ n, err := strconv.Atoi(value)+ if err != nil {+ return fmt.Errorf("server.retainNetworkBodyMaxBytes must be a number: %w", err)+ }+ s.RetainNetworkBodyMaxBytes = &ncase "trustProxyHeaders":b, err := parseBool(value)if err != nil {@@ -78,6 +96,14 @@ func setBrowserField(b *BrowserConfig, field, value string) error {b.BrowserBinary = valuecase "extraFlags":b.BrowserExtraFlags = value+ case "remoteDebuggingPort":+ n, err := strconv.Atoi(value)+ if err != nil {+ return fmt.Errorf("browser.remoteDebuggingPort must be a number: %w", err)+ }+ b.BrowserDebugPort = &n+ case "extensionPaths":+ b.ExtensionPaths = parseCSVList(value)case "defaultTarget":b.DefaultTarget = valuecase "fallbackOrder":@@ -397,6 +423,12 @@ func setInstanceDefaultsField(c *InstanceDefaultsConfig, field, value string) erc.StealthLevel = valuecase "tabEvictionPolicy":c.TabEvictionPolicy = value+ case "dialogAutoAccept":+ b, err := parseBool(value)+ if err != nil {+ return fmt.Errorf("instanceDefaults.dialogAutoAccept: %w", err)+ }+ c.DialogAutoAccept = &bdefault:return fmt.Errorf("unknown field instanceDefaults.%s", field)}@@ -415,12 +447,35 @@ func setTabPolicyField(tp *TabPolicyDefaults, field, value string) error {return fmt.Errorf("instanceDefaults.tabPolicy.closeDelaySec must be a number: %w", err)}tp.CloseDelaySec = &n+ case "restore":+ b, err := parseBool(value)+ if err != nil {+ return fmt.Errorf("instanceDefaults.tabPolicy.restore: %w", err)+ }+ tp.Restore = &bdefault:return fmt.Errorf("unknown field instanceDefaults.tabPolicy.%s", field)}return nil}+// securityBoolFields is the set the shared boolean parse below is allowed to serve. It is+// checked before the parse so an unknown field is refused as unknown.+var securityBoolFields = map[string]bool{+ "allowEvaluate": true,+ "allowClipboard": true,+ "allowMacro": true,+ "allowScreencast": true,+ "allowDownload": true,+ "allowCookies": true,+ "allowStateExport": true,+ "allowUpload": true,+ "allowNetworkIntercept": true,+ "allowFileScheme": true,+ "enableActionGuards": true,+ "trustLoopbackProxy": true,+}+func setSecurityField(s *SecurityConfig, field, value string) error {if strings.HasPrefix(field, "attach.") {return setAttachField(&s.Attach, strings.TrimPrefix(field, "attach."), value)@@ -491,8 +546,19 @@ func setSecurityField(s *SecurityConfig, field, value string) error {}s.MaxRedirects = &nreturn nil+ case "stateEncryptionKey":+ key := value+ s.StateEncryptionKey = &key+ return nil}+ // Everything left in this section is a boolean, so the parse can be shared — but only+ // after the field is known. Parsing first made an unrecognised security field report a+ // boolean complaint about its value, which hid the unknown-field refusal behind a+ // message about the wrong thing.+ if !securityBoolFields[field] {+ return fmt.Errorf("unknown field security.%s", field)+ }b, err := parseBool(value)if err != nil {return fmt.Errorf("security.%s: %w", field, err)@@ -673,6 +739,21 @@ func setIDPIField(s *SecurityConfig, field, value string) error {i.WrapContent = bcase "customPatterns":i.CustomPatterns = parseCSVList(value)+ case "scanTimeoutSec":+ n, err := strconv.Atoi(value)+ if err != nil {+ return fmt.Errorf("security.idpi.scanTimeoutSec must be a number: %w", err)+ }+ i.ScanTimeoutSec = n+ case "shieldThreshold":+ n, err := strconv.Atoi(value)+ if err != nil {+ return fmt.Errorf("security.idpi.shieldThreshold must be a number: %w", err)+ }+ if n < 0 || n > 100 {+ return fmt.Errorf("security.idpi.shieldThreshold must be between 0 and 100")+ }+ i.ShieldThreshold = ndefault:return fmt.Errorf("unknown field security.idpi.%s", field)}