Skip to content

🧪 test(integration): Podman rootful+rootless CI integration for libpod surface (#148) - #192

Merged
scttbnsn merged 5 commits into
dev/v1.6from
feat/148-podman-ci
Aug 5, 2026
Merged

scttbnsn merged 5 commits into
dev/v1.6from
feat/148-podman-ci

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

PR6 of the #148 Podman/libpod train: CI integration tests against a real Podman socket, mirroring the existing -tags=integration Docker suite's structure.

  • app/integration/podman_libpod_integration_test.go (new, //go:build podmanintegration) — starts sockguard's real middleware chain in front of a genuine podman system service socket:
    • plain POST /libpod/containers/create body is allowed and actually creates a container
    • privileged container-create is denied with a "libpod "-prefixed reason
    • host-network and disallowed-infra-image-registry POST /libpod/pods/create bodies are denied with "libpod "-prefixed reasons
    • libpod exec create/start honor the shared request_body.exec config (feat(runtime): support Podman Docker-compatible and native libpod APIs #148 design decision C3): a disallowed command is denied before ever reaching Podman, an allowlisted one is forwarded through a real create→start→exec-create→exec-start round trip
    • libpod_volume/libpod_network/libpod_secret driver gates fire against real create requests
  • app/integration/podman_helpers_test.go (new, same tag) — podman-specific pinger/cleanup helpers; reuses the daemon-agnostic handler/rule-compilation helpers from helpers_test.go (see below) rather than duplicating them.
  • app/integration/helpers_test.go — build tag broadened to integration || podmanintegration so both suites share newIntegrationProxyHandlerWithOptions, compileRulesForTest, dockerHTTPClient, etc. (all daemon-agnostic; only the Docker-specific helpers stay under integration alone).
  • app/internal/cmd/rules_podman_integration_test.go (new, same tag) — proves the POST /libpod/play/kube blind-write acknowledgment gate (feat(runtime): support Podman Docker-compatible and native libpod APIs #148 design decision C2) against a live daemon via validateAndCompileRules, not just the synthetic configs already in rules_test.go.
  • .github/workflows/quality-integration-podman.yml (new) — runs the suite on ubuntu-latest against:
    • rootful podman (required leg): sudo podman system service on the well-known root socket (/run/podman/podman.sock), chmod'd 666 so the unprivileged test process can dial it directly without running the whole Go test binary under sudo.
    • rootless podman (continue-on-error: true): verified newuidmap/newgidmap and /etc/subuid//etc/subgid ranges exist for the runner user (ubuntu-latest ships both), then creates and chowns /run/user/<uid> by hand before starting a per-user podman system service there — the runner has no logind session, so XDG_RUNTIME_DIR is never auto-created via pam_systemd the way it would be on an interactive login. That's more failure-prone than the rootful path most sockguard deployments actually run behind, so a transient rootless-only failure never blocks a PR. Full rationale is in the workflow's comments.
  • CHANGELOG.md — new ### Tests entry under ## [Unreleased].

Tests t.Skip cleanly when SOCKGUARD_TEST_PODMAN_SOCKET is unset, so plain go test ./... and the existing dockerd -tags=integration suite are unaffected.

Local verification

  • go build ./... / go vet ./... — clean, no tags
  • go build -tags=integration ./... and go build -tags=podmanintegration ./... — clean
  • go test -tags=podmanintegration ./integration/... ./internal/cmd/... — all new tests SKIP cleanly without SOCKGUARD_TEST_PODMAN_SOCKET (verified with -v)
  • go test ./... — green (one internal/ownership flake from a leftover /tmp unix socket from a prior parallel run, confirmed pre-existing/unrelated — passes clean in isolation)
  • Coverage gate: go list ./... | grep -v testcert | xargs go test -race -coverprofile=... -covermode=atomic, then filtered differential/testcert/testhelp out of the profile before go tool cover -func → 96.2% (gate is 96%)
  • golangci-lint run (no tags, matches CI/lefthook exactly) — 0 issues; also re-ran with --build-tags=integration,podmanintegration for extra rigor — 0 issues
  • zizmor .github/workflows/ — no findings
  • Pushed through the full pre-push hook chain (go-lint → go-test → biome → build) — passed

Test plan

  • CI's new 🦭 Quality: Integration (Podman) workflow runs on this PR and the rootful leg passes (required)
  • Rootless leg completes or fails gracefully via continue-on-error without blocking the PR
  • CodeRabbit review addressed

✨ Added

  • Added podmanintegration-tagged integration tests for real podman system service sockets.
  • Added coverage for container, pod, exec, volume, network, secret, and /libpod/play/kube endpoints.
  • Added shared integration helpers for Docker and Podman test suites.
  • Added skip logic when SOCKGUARD_TEST_PODMAN_SOCKET is unset.
  • Added an Unreleased changelog test entry.

🔧 Changed

  • Updated app/integration/helpers_test.go to build with integration or podmanintegration.
  • Added app/integration/podman_helpers_test.go for socket discovery, availability checks, version fetch, container polling, and forced removal.
  • Added app/integration/podman_libpod_integration_test.go to verify real Libpod proxy behavior and denial paths.
  • Added .github/workflows/quality-integration-podman.yml with rootful and rootless Podman jobs.
  • Added CI setup checks and socket permission handling for both Podman modes.

🐛 Fixed

  • Fixed CI environment issues for rootful socket directory permissions.

  • Fixed rootless validation for subuid and subgid setup.

  • Fixed allow-rule coverage for /libpod/play/kube when insecure_allow_body_blind_writes=true is required.

  • Rootful Podman CI is required. Confirm it does not expand default socket access.

  • Rootless Podman CI is non-blocking. Confirm failures cannot hide regressions in tagged tests.

  • Review the new Podman helpers for overlap with existing Docker integration utilities.

  • Check that all skip paths fail closed when SOCKGUARD_TEST_PODMAN_SOCKET is missing.

PR6 of the #148 Podman/libpod train: real-daemon coverage for the
libpod inspectors built in PR2-PR5, mirroring the existing
integration-tagged Docker suite's structure and skip-cleanly
convention.

- app/integration/podman_libpod_integration_test.go and
  podman_helpers_test.go (new, //go:build podmanintegration): plain
  libpod container-create passes; privileged container-create and
  host-network / disallowed-infra-image-registry pod-create are
  denied with "libpod "-prefixed reasons; exec create/start honor
  the shared request_body.exec config via a real create+start+exec
  round trip; libpod_volume/network/secret driver gates fire.
- app/internal/cmd/rules_podman_integration_test.go (new, same tag):
  proves the POST /libpod/play/kube blind-write acknowledgment gate
  against a live daemon, not just rules_test.go's synthetic configs.
- app/integration/helpers_test.go: broaden the build tag to
  `integration || podmanintegration` so the podman suite reuses the
  daemon-agnostic handler/rule-compilation helpers instead of
  duplicating them.

All tests t.Skip cleanly when SOCKGUARD_TEST_PODMAN_SOCKET is unset,
so `go test ./...` and the existing dockerd suite are unaffected;
the 96% coverage gate excludes nothing new (verified locally at
96.2% after filtering differential/testcert/testhelp).
…man (#148)

New workflow .github/workflows/quality-integration-podman.yml runs
the podmanintegration-tagged tests added in the prior commit on
ubuntu-latest, mirroring quality-integration.yml's real-dockerd
structure (harden-runner, pinned action SHAs, pre-pulled pinned
sentinel image).

Two jobs against the distro-packaged podman:
- rootful: required leg, `sudo podman system service` on the
  well-known root socket, chmod'd so the unprivileged test process
  can dial it directly.
- rootless: continue-on-error. ubuntu-latest has usable
  newuidmap/newgidmap and /etc/subuid /etc/subgid ranges for the
  runner user (verified with an explicit prerequisite-check step),
  but the runner has no logind session, so XDG_RUNTIME_DIR has to be
  created and chowned by hand rather than relying on pam_systemd.
  That's more failure-prone than the rootful path most sockguard
  deployments actually run behind, so a transient rootless-only
  failure never blocks a PR.
@vercel

vercel Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sockguard-website Ready Ready Preview Aug 5, 2026 4:22pm

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@scttbnsn, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: afa0b01f-5aa4-4d28-b725-83d4f8e2a1e5

📥 Commits

Reviewing files that changed from the base of the PR and between f406b51 and 6130201.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
📒 Files selected for processing (3)
  • .github/workflows/quality-integration-podman.yml
  • app/integration/podman_helpers_test.go
  • app/integration/podman_libpod_integration_test.go
📝 Walkthrough

Walkthrough

The PR adds rootful and rootless Podman GitHub Actions jobs. The jobs validate Podman sockets, pre-pull a digest-pinned BusyBox image, and run Podman-tagged Go integration suites. New helpers handle socket checks, libpod API requests, container polling, and cleanup. New tests exercise real libpod version, container, pod, exec, volume, network, secret, and kube-rule policies.

Possibly related issues

  • CodesWhat/sockguard issue 148 — Adds the Podman native libpod API support and default-deny integration coverage described by the issue.

Possibly related PRs

  • CodesWhat/sockguard#165 — Both workflows pre-pull the digest-pinned BusyBox reference from app/integration/helpers_test.go.
  • CodesWhat/sockguard#190 — This PR adds real Podman tests for the libpod policies and endpoints introduced there.
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/148-podman-ci

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Both legs of the new podman integration workflow failed on the real
runner (run 31021161589):

- Rootful (92357909184): every test hit "stat
  /run/podman/podman.sock: permission denied". The socket chmod
  alone wasn't enough — /run/podman itself is root-owned 0700, so
  the unprivileged test process can't even traverse into the
  directory to reach the (now world-writable) socket file. chmod the
  directory too, and add a curl --unix-socket _ping check as the
  runner user right after starting the service, so a future
  regression here fails loudly at setup instead of inside the suite.
- Rootless (92357909108): "Verify rootless prerequisites" died on
  `getent subuid runner` with "Unknown database: subuid" — glibc on
  ubuntu-latest has no subuid/subgid NSS database registered at all,
  so getent can't answer the question regardless of what
  /etc/subuid contains. Check the files directly with grep instead.
…#148)

Run 31021969781's rootful leg fixed the earlier permission-denied issue but
surfaced new failures once tests actually hit real Podman 4.9.3:

- Bare (unversioned) libpod routes other than GET /libpod/_ping 404 on real
  Podman, unlike dockerd. Container-create and exec-create now fetch the
  daemon's Libpod-Api-Version via _ping and prefix every request that needs
  to reach Podman with /v<version>/libpod/...; TestProxyReachesRealPodmanVersion
  (which hit bare /libpod/version) is removed as no longer viable.
- Deny-reason assertions used raw strings.Contains against JSON bodies whose
  %q-quoted values are escaped (\") — switched to decoding filter.DenialResponse
  and comparing .Reason.
- The exec test's denied/allowed Cmd payloads had no explicit User, so
  isRootUser("") tripped the root-exec-user gate before the command-allowlist
  gate ever ran; added "User":"nobody" to isolate the allowlist check.
- removeLibpodContainer force-removes a RUNNING container, which makes Podman
  stop it first (SIGTERM + grace period) — that alone exceeds the shared
  5s HTTP client timeout. Gave it its own 30s client instead of widening the
  shared one.
- POST /libpod/exec/{id}/start is hijack-capable, and internal/proxy/hijack.go
  always forwards the version-stripped path upstream by design (pinned by
  existing hijack tests) — fine for dockerd, currently incompatible with real
  Podman's non-_ping versioning requirement. Dropped the real exec-start round
  trip with a comment explaining why; exec's shared-config enforcement is
  already fully proven by the exec-create deny/allow pair.

All changes verified locally against a real `podman machine` socket (macOS,
Podman Engine 5.8.1), not just compiled.
@scttbnsn
scttbnsn merged commit 0427b33 into dev/v1.6 Aug 5, 2026
48 checks passed
@scttbnsn
scttbnsn deleted the feat/148-podman-ci branch August 5, 2026 16:27
scttbnsn added a commit that referenced this pull request Aug 8, 2026
…eam leg (#203)

* 🐛 fix(proxy): forward the original versioned path on the hijack upstream leg

writeHijackUpstreamRequest built the outbound attach/exec-start request
from the filter-normalized (version-stripped) path instead of the
client's original path. dockerd tolerates a bare unversioned path, but
real Podman requires the version prefix (/v5.x.y/libpod/...) on every
libpod route but the bare _ping, so a hijacked POST
/libpod/exec/{id}/start proxied through sockguard 404ed against a real
daemon even when policy allowed it. The non-hijack reverse-proxy path
(proxy.go's Rewrite, which only touches Scheme/Host) never had this bug.

- newUpstreamHijackRequest now takes the wire path directly; the
  production caller passes r.URL.Path. The normalized path is still
  used for endpoint matching (isHijackEndpointNormalized) and logging.
- New internal/proxy/hijack_libpod_test.go regression test
  (TestHandleHijack_LibpodExecStartPreservesVersionPrefix) reproduces
  the mangle directly; two existing tests that pinned the old
  stripped-path behavior (hijack_test.go, internal/cmd/serve_chain_test.go)
  are updated to assert the fixed contract.
- New podmanintegration-tagged acceptance test
  (TestLibpodExecStartEndToEndHijackAgainstRealPodman) drives a real
  create -> exec-create -> exec-start round trip through the hijack
  path against a live Podman daemon, closing the gap PR #192 left open.
- Removes the now-resolved "Known Limitations" entry from the Podman
  guide and records the fix in CHANGELOG.md.

Fixes #194

* 🐛 fix(proxy): preserve RawPath on the hijack upstream request

newUpstreamHijackRequest built the outbound URL from r.URL.Path alone,
which is decoded (%2F becomes a literal /). With no RawPath set, a
url.URL re-derives EscapedPath() from the decoded Path, so an encoded
segment in a hijacked attach/exec-start target would collapse into a
different path on the wire than the client actually sent.

Now carries r.URL.RawPath into the constructed upstream URL whenever
path equals r.URL.Path (the production caller's case); left unset when
a caller substitutes a different path, since a stale RawPath wouldn't
describe it.

New tests: TestNewUpstreamHijackRequest_PreservesRawPathForEncodedSegments
and its negative counterpart (unit level), plus
TestHandleHijack_PreservesEncodedPathBytesUpstream, which checks the
actual forwarded bytes rather than just the parsed URL struct.

CodeRabbit review on #203.

* ✅ test(proxy): table-drive the libpod hijack regression tests

Convert TestHandleHijack_LibpodExecStartPreservesVersionPrefix and
TestLibpodExecStartEndToEndHijackAgainstRealPodman to table-driven
tests per repo coding guidelines (t.Run subtests, case table for
what varies), matching the existing convention across the suite.

hijack_libpod_test.go gains a two-part Docker-style version prefix
case alongside the original three-part Podman semver case, plus a
case covering the RawPath/%2F fix from the preceding commit — an
encoded exec-ID segment must survive onto the wire unchanged.

podman_libpod_integration_test.go's acceptance test now runs the
full create -> exec-create -> exec-start round trip for two commands
(echo, with a trailing newline; printf, without), proving the
hijack frame decoding path for both shapes. Re-verified against a
real Podman machine (Podman 6.0.2 client / Libpod 5.8.1 server):
both subtests pass.

CodeRabbit review on #203.

This branch was successfully deployed

1 active deployment
Preview — 6130201b Deployed Aug 5, 2026 by vercel[bot]
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