Repository navigation
feat(permissions): add global-only GitLab Duo CLI permissions - #3967
Merged
Merged
Conversation
GitLab Duo CLI 10.5.0 reads a `permissions` array of
`{ action, resource, effect }` statements from the user
`~/.gitlab/duo/settings.json`, and enforces only `allow`. Project
settings files are deliberately not read for it.
Write canonical `bash` allow rules as `run_command` allow statements,
global scope only. Never write `ask`/`deny`; instead withhold any allow
that overlaps a bash or `*` deny/ask rule and warn that deny is not
enforced. Skip patterns the GitLab server refuses or reads differently.
Keep other keys, comments and statements for other tools in the file.
Import skips allow statements whose resource holds a glob, since the
canonical glob would match more than Duo's token matcher.
Refs #3417
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
Normalize trailing `:*` and whitespace the way Duo's token matcher reads a command before the overlap test, on both the written resource and the deny/ask restrictions (including all-tools `*` ones), so `git:*` beside a `git push` deny, or `git push` beside `git push`, no longer slips an allow past the restriction. Refuse a bare `:*`. Import an allow only when the server would accept its resource as written. Narrow the docs claim about kept comments to those outside the `permissions` array. Refs #3417 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
Duo splits both its pattern and the command shell-style, taking quotes and backslashes off, so a `git 'push'` deny names the same command as a `git push` allow. Compare each deny/ask restriction a third time with quotes and backslashes stripped, so such an allow is withheld rather than written. Also correct the class comment on what import skips. Refs #3417 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…tlabduo-permissions # Conflicts: # src/generated/docs-content.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GitLab Duo CLI v10.5.0 added a
permissionssetting: an array of{ action, resource, effect }statements read from the user~/.gitlab/duo/settings.jsonand the managed file. Onlyallowis enforced;askanddenyare accepted but only logged. This PR adds a global-onlygitlabduopermissions adapter that writes allow statements and never widens access.I checked the format against primary sources, since docs.gitlab.com does not cover it yet:
PermissionStatementSchema,user-settings.schema.jsonandallowedSources: ['managed', 'user']. 93aafcd makes Duo drop invalid statements one at a time. Both commits are in thev10.5.0tag.CommandPatternMatcherandWorkflowapproval checks. Forrun_command, a pattern is matched token by token. A literal token must match exactly, and*matches exactly one token that does not start with-. The server rejects a lone*,**, shell metacharacters and patterns over 256 characters. Programs without a registered validator fail closed: they only get exact-match approval.What changed
src/features/permissions/gitlabduo-permissions.ts, registered as global-only (supportsProject: false):bashallow rule becomes{ action: "run_command", resource, effect: "allow" }. A trailing:*is written as*.askordeny. Anybashor*deny/ask rule withholds every allow that could match the same command (viacreateShadowingRestrictionsTest). Deny rules are reported as not enforced.[...]) are also skipped with a warning.modify. Only therun_commandstatements are replaced; comments, other keys and other tools' statements stay. If no statements are left, the key is removed. A non-arraypermissionsvalue is left untouched.run_commandstatements tobash. It skips allow statements with globs, which the canonical glob would read more widely.gitlabduoto the permissions target tuple and thePermissionsConfigSchematool keys, with unit tests and a global e2e test.Skipped and why
.gitlab/duo/settings*.jsonforpermissionsuntil it has a project-trust opt-in (work item 3588).ask/denystatements for forward compatibility: Duo ignores them today, so they are warned about and not written.bashcategories and MCP tools: non-command tools are matched withfnmatchagainst raw JSON arguments, so there is no spelling known to be no wider than the canonical rule..agents/agents/subagent decision,gitlabduo-plugintarget) still need a maintainer decision.Refs #3417
🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4