git-guard silently weakens protection on mistyped config (on_protected "deny", non-array protected_branches) #38
Labels
No labels
already-shipped
bug
documentation
duplicate
enhancement
good first issue
help wanted
in progress
invalid
needs-decision
proposal
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: crenshawdev/cadence#38
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: high · Area: git-guard · surfaced in the post-v1.2.0 cross-model review sweep
The protected-branch hook reads two config values and trusts both without validation, so a plausible typo silently makes the rail weaker than configured. There is a
config validatecommand, butgit-guardreads the raw merged config, not a validated one.1.
on_protected: "deny"silently degrades to a soft promptThe code recognizes only
"refuse"as the value for a hard block; every other value (including"deny") falls through to a soft"ask".cadence-core/bin/git-guard.mjs:132:const onProtected = git.on_protected || 'ask';git-guard.mjs:139:decide(onProtected === 'refuse' ? 'deny' : 'ask', ...)— anything butrefusemaps toask.The trap: the file's own header comment (
git-guard.mjs:19-20) documents the setting asask (default) | refuse ("deny") | allow, which reads likedenyis a valid alias for the hard block. A user who setson_protected: "deny"expecting commits tomainto be blocked instead gets only a prompt, with no signal that the value was unrecognized.2. A non-array
protected_branchessilently guards the wrong branchesgit-guard.mjs:128-129:Array.isArray(git.protected_branches) ? git.protected_branches : ['main','master'].If a user writes
"protected_branches": "release"(a string rather than a list), the guard falls back to the built-in['main','master']. The branch the user meant to protect (release) is unguarded, and branches they did not configure are guarded — no error surfaced. (The same non-array fallback exists ingit-publish.mjs.)Fix direction
Validate the specific keys
git-guarddepends on before acting on them: enum-checkon_protected(and either acceptdenyas an alias forrefuseor surface an unrecognized value), and array-checkprotected_brancheswith a surfaced fallback rather than a silent one. Fix the header comment at:19-20so the documented value and the accepted value agree. Both manifestations share one root and one fix.