Skip to content

ci: confine dependencies with gomodjail (static mode) - #7411

Open
AkihiroSuda wants to merge 1 commit into
docker:masterfrom
AkihiroSuda:gomodjail
Open

AkihiroSuda wants to merge 1 commit into
docker:masterfrom
AkihiroSuda:gomodjail

Conversation

@AkihiroSuda

Copy link
Copy Markdown
Collaborator

Summary

Mark all the modules in vendor.mod as confined by default with gomodjail, and run gomodjail analyze (static mode) in CI to verify that confined modules cannot reach privileged capabilities such as file, network, exec, syscall, etc.

Modules that already need such capabilities are annotated as "gomodjail:unconfined".
Newly added dependencies are confined by default, so an update that newly gains a privileged capability fails the check and gets more review.

https://github.com/AkihiroSuda/gomodjail

See:

Release notes (optional)

A picture of a cute animal (not mandatory but encouraged)


Created with: Claude Code

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Mark all the modules in vendor.mod as confined by default with
gomodjail, and run `gomodjail analyze` (static mode) in CI to verify
that confined modules cannot reach privileged capabilities such as
file, network, exec, syscall, etc.

Modules that already need such capabilities are annotated as
"gomodjail:unconfined".
Newly added dependencies are confined by default, so an
update that newly gains a privileged capability fails the check and
gets more review.

https://github.com/AkihiroSuda/gomodjail

Assisted-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Comment thread vendor.mod
Comment on lines +19 to +20
github.com/containerd/log v0.2.0 // gomodjail:unconfined
github.com/containerd/platforms v1.0.0-rc.5 // gomodjail:unconfined

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are there ways to configure this other than through go.mod ? Also considering that (parts of?) a separate config could be more easily shared / maintained centrally.

@AkihiroSuda AkihiroSuda Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Are there ways to configure this other than through go.mod ?

gomodjail analyze has --policy flag, but the UX doesn't scale for dozens of deps

--policy stringToString       e.g., example.com/module=confined (overrides go.mod) (default [])

Maybe we should consider having a separate file like go.mod.policy.yaml? (or toml? hcl?)

Comment thread vendor.mod
Comment on lines +81 to 82
// gomodjail:unconfined
github.com/docker/go-events v0.1.0 // indirect

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

.. and for the indirects; this feels brittle; a comment can (and will?) be left behind, now describing the wrong dependency

@AkihiroSuda AkihiroSuda Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The comment could be also written as // indirect // gomodjail:unconfined but IIRC dependabot didn't work well with it.
This docker/cli repo doesn't use dependabot though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: add gomodjail (static analysis mode) to check whether Go dependencies can reach unexpected capabilities

3 participants