Skip to content

fix(enterprise/dbcrypt): handle plugin configs in key rotate, decrypt and delete - #142

Merged
ibetitsmike merged 1 commit into
mainfrom
mike/issue-122-dbcrypt-plugins
Nov 10, 2026
Merged

ibetitsmike merged 1 commit into
mainfrom
mike/issue-122-dbcrypt-plugins

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Xum (AI agent) opened this on behalf of @ibetitsmike.

Fixes #122

coder server dbcrypt rotate, decrypt and delete skipped plugins.config, which the fork encrypts with dbcrypt and whose config_key_id references dbcrypt_keys. Rotate and decrypt left configs on the old key, so revoking it failed on plugins_config_key_id_fkey; delete left ciphertext, so the same foreign key blocked revoking the keys.

This adds a plugins step behind the hooks that #119 added for chat_secret_answers in enterprise/dbcrypt/fork_cliutil.go:

  • Rotate and decrypt: the two cliutil.go hook lines now call forkRecryptSecrets, which runs the existing chat secret answer step and then the new plugin step. The plugin step pages through plugins whose key is not the target by ID, decrypts each config and encrypts it again with the primary cipher, or writes it back as plaintext when there is none. The update only applies when the row still holds the config that was read, so a config changed meanwhile is never overwritten. It leaves updated_at alone, because the plugin manager restarts a plugin whenever updated_at changes. Blank configs stay plaintext with no key, as on insert; the blank check moved from forkCrypt to dbCrypt so both paths share it.
  • Delete: upstream deletes rows that a user can recreate (OAuth links, user secrets) and clears values on rows that must survive (gitsshkeys.private_key, ai_providers.settings, workspace_secrets.value). A plugin row carries the installed module, its grants and its user links, so deleting it would uninstall the plugin. Delete therefore clears it like ai_providers.settings: config = '' (the column default), config_key_id = NULL. It bumps updated_at, so running plugins restart with the cleared config, and an admin sets the config again.

cliutil.go changes by two lines (the hook name); Delete already calls forkDeleteEncryptedSecrets.

Validation

  • TestPluginConfigsKeyCommands (fork_cliutil_test.go) runs each command on plugins with a config, with each command's own check that key revocation succeeds:
    • Rotate: 101 plugins (more than one page) end on cipher B with the same plaintext and the same updated_at, and a blank-config plugin stays plaintext.
    • Decrypt: the config is plaintext and config_key_id is NULL.
    • Delete: every key is revoked, the encrypted config is cleared with a newer updated_at, and a plaintext plugin keeps its config.
  • Negative controls, each restored afterwards:
    • With the plugin step removed from forkRecryptSecrets, Rotate and Decrypt fail with violates foreign key constraint "plugins_config_key_id_fkey".
    • With the plugin UPDATE in delete disabled, Delete fails the same way.
  • gofmt, go vet ./enterprise/dbcrypt/ and go test ./enterprise/dbcrypt/... on Postgres 17 pass.
  • golangci-lint v2.0.2 on ./enterprise/dbcrypt/... reports 0 issues, both with --new-from-merge-base=origin/main and without it.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T13:36:47.161099Z b382f61 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: b382f61d65

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this on behalf of @ibetitsmike.

Closing and reopening only to make GitHub recompute the merge ref against current main (77b20734d2) and run fork-ci on it. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this again on behalf of @ibetitsmike.

The merge ref now points at current main (77b20734d2), but the run started by the first reopen was queued against the old merge ref. This second reopen starts fork-ci on the recomputed merge. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike
ibetitsmike merged commit 69f04bd into main Nov 10, 2026
27 of 35 checks passed
@ibetitsmike
ibetitsmike deleted the mike/issue-122-dbcrypt-plugins branch November 10, 2026 14:13
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Merge evidence for head b382f61d65c0a60a0e79fa886315085378929ebe:

  • fork-ci pull_request run 42826905978 passed; its build job checked out Merge b382f61d65 into 77b20734d2. Main then gained only fix: port the final computer use validation from upstream #31895 #143 (upstream computer use port under coderd/x/chatd and codersdk/chats.go), which shares no file with this PR, and both merge into one commit that main fork-ci checks before the deploy. All checks green.
  • Codex on this exact head: no major issues (comment 6768767738). 0 unresolved review threads.
  • UAT: these are offline coder server dbcrypt commands. The Postgres tests in fork_cliutil_test.go cover rotate, decrypt and delete for plugin configs, and their negative controls fail as they should (Fork ops). The server-side change in fork_forkdb.go only moves encryptPluginConfig to the shared receiver. The daily PAIRED checks that the plugins list still loads.
  • No migration. Fixes bug(enterprise/dbcrypt): key rotate, decrypt and delete skip plugin configs #122.

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.

bug(enterprise/dbcrypt): key rotate, decrypt and delete skip plugin configs

1 participant