Skip to content

feat: store plugin packs and fetch them from Git - #200

Merged
ibetitsmike merged 4 commits into
mainfrom
mike/plugin-packs-2-install
Nov 11, 2026
Merged

ibetitsmike merged 4 commits into
mainfrom
mike/plugin-packs-2-install

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Second step of plugin packs (R7.2): store installed packs and fetch a pack from Git, pinned to one commit. The API that installs, lists, updates and deletes packs, and the per-organization host allowlist, come in the next PR, which stacks on this one.

What changes

  • Schema: chatdmig node plugin_packs adds two tables. plugin_packs has one row per pack: organization, name (unique per organization), source URL, path and ref, plus the commit the stored files come from. plugin_pack_resources holds the files of a pack (path, content, SHA-256), deleted with the pack.
  • Queries (forkdb/queries/plugin_packs.sql): pack CRUD, plus batch insert, read and delete of a pack's files (unnest over bytea[]). Every query has a dbauthz and a dbmetrics wrapper.
  • RBAC: packs reuse ResourceOrganizationSkill. Only organization admins and auditors can read or manage packs. Members get no access to packs; they reach pack content later, when it is materialized into the workspace. This PR adds no RBAC resource.
  • Fetcher (coderd/x/pluginpacks):
    • Uses go-git's smart HTTP upload-pack session directly and installs no global transport.
    • Fetches over https only, rejects URLs with credentials, and checks every request against the host allowlist, redirects included.
    • Accepts a tag (annotated tags are peeled), a branch or a full commit SHA, and fetches only that commit (depth 1) into memory.
    • Returns the regular files under the pack directory and skips symlinks and submodules.
    • Caps are constants: 64 MiB transferred, 256 MiB of unpacked objects (checked from the pack headers before go-git inflates anything), 2000 files, 1 MiB per file, 16 MiB in total.

Nothing calls these yet, so behavior does not change.

Validation

  • In a container: forkdb/generate.sh regen, chatdmig check, go build ./coderd/... ./enterprise/..., and vet.
  • Tests passed for ./coderd/x/pluginpacks/ (a real git http-backend behind an httptest TLS server: tag, branch, SHA, rejected hosts and schemes that never reach the server, unknown ref, oversized file), forkdb TestPluginPackResources, and dbauthz TestForkQuerier.
  • ./coderd/database/migrations/chatdmig/ passed in a container against Postgres 17 with a matching pg_dump, and TestCheckUnpackedSize covers the unpacked cap with a delta-compressed pack.

Adds the plugin_packs and plugin_pack_resources tables (chatdmig node),
their forkdb queries with dbauthz and dbmetrics wrappers, and
coderd/x/pluginpacks, which fetches one commit of a pack directory over
smart HTTP with a host allowlist and fixed size caps.

Packs reuse the organization skill RBAC object, so only organization
admins and auditors read or manage them.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 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-11T15:35:48.486218Z 63f5d8c 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0b2a885aa5

ℹ️ 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".

Comment thread coderd/x/pluginpacks/fetch.go Resolved
Comment thread coderd/x/pluginpacks/fetch.go Resolved
Comment thread coderd/x/pluginpacks/fetch_test.go Resolved
The 64 MiB transfer cap does not bound memory, because go-git inflates
every fetched object into memory storage before the per-file limits run.
Read the pack first and reject it when its object headers, and the target
sizes of its deltas, add up to more than 256 MiB.
@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. 🚀

Reviewed commit: b633a322fd

ℹ️ 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".

…nstall

# Conflicts:
#	coderd/database/forkdb/sqlc.yaml
…server

The rejected-source subtest asserted that no request reached the server,
but the parallel subtests shared that server and its counter, so a sibling
fetch could make it fail.
@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. Another round soon, please!

Reviewed commit: 63f5d8c5de

ℹ️ 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
ibetitsmike merged commit 5b3e7ca into main Nov 11, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/plugin-packs-2-install branch November 11, 2026 15:49
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum merged this PR on behalf of @ibetitsmike.

Merged as a squash of head 63f5d8c5de, on top of main 7fda6490ba (#197).

  • CI: fork-ci run 43049189682 passed on the exact head, which contains main 7fda6490ba. The merge with main only resolved the forkdb sqlc.yaml node list. The lead checked that the non-test, non-generated diff matches b633a322fd exactly.
  • Codex: clean receipt 6800086604 on 63f5d8c5de. The unpack-size P1 was fixed in b633a322fd. One P2 (shared test counter) was fixed, and the other (unadvertised SHA wants) was dropped because GitHub serves reachable SHAs. 0 unresolved threads.
  • UAT: nothing in this PR is reachable on its own. The behavior was exercised by UAT201 on feat: add plugin pack install API #201 at ac807c1972, which contains b633a322fd: install from github.com at a pinned SHA, explicit update refetch, non-allowlisted hosts rejected before any outbound request, and admin-only access.

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