Skip to content

feat(permissions): add global-only GitLab Duo CLI permissions - #3967

Merged
dyoshikawa merged 4 commits into
mainfrom
resolve-issue-3417-gitlabduo-permissions
Nov 25, 2026
Merged

dyoshikawa merged 4 commits into
mainfrom
resolve-issue-3417-gitlabduo-permissions

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

GitLab Duo CLI v10.5.0 added a permissions setting: an array of { action, resource, effect } statements read from the user ~/.gitlab/duo/settings.json and the managed file. Only allow is enforced; ask and deny are accepted but only logged. This PR adds a global-only gitlabduo permissions 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:

  • Client (gitlab-lsp v10.5.0): 7b23cce adds PermissionStatementSchema, user-settings.schema.json and allowedSources: ['managed', 'user']. 93aafcd makes Duo drop invalid statements one at a time. Both commits are in the v10.5.0 tag.
  • Server (gitlab-org/gitlab): CommandPatternMatcher and Workflow approval checks. For run_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

  • New src/features/permissions/gitlabduo-permissions.ts, registered as global-only (supportsProject: false):
    • Each bash allow rule becomes { action: "run_command", resource, effect: "allow" }. A trailing :* is written as *.
    • Duo's matching is never wider than the canonical glob, so a written allow cannot approve more than the canonical rule does.
    • Never writes ask or deny. Any bash or * deny/ask rule withholds every allow that could match the same command (via createShadowingRestrictionsTest). Deny rules are reported as not enforced.
    • Allow rules from other categories are skipped with a warning, because other Duo tools match the raw JSON arguments. Patterns the server refuses or reads differently (quotes, escapes, [...]) are also skipped with a warning.
    • Merges with jsonc-parser modify. Only the run_command statements are replaced; comments, other keys and other tools' statements stay. If no statements are left, the key is removed. A non-array permissions value is left untouched.
    • Import maps run_command statements to bash. It skips allow statements with globs, which the canonical glob would read more widely.
  • Added gitlabduo to the permissions target tuple and the PermissionsConfigSchema tool keys, with unit tests and a global e2e test.
  • Added a GitLab Duo CLI note to the docs and regenerated the tables and docs content.

Skipped and why

Refs #3417

🤖 Generated with Claude Code

https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4

dyoshikawa and others added 4 commits November 25, 2026 10:48
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
@dyoshikawa
dyoshikawa merged commit 8241dd8 into main Nov 25, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3417-gitlabduo-permissions branch November 25, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant