Repository navigation
feat(sandboxpolicy): one image with the exec restart fence, dormant unless the chart enables it #1209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sandboxpolicy): one image with the exec restart fence, dormant unless the chart enables it #1209
Changes from all commits
4f184c9
be633fc
fe81169
2bae37b
59e08f6
d75e535
afdccc4
9d36880
efe532e
40a48a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| name: Exec Fence Build | ||
|
|
||
| # Builds the single node-agent image, which always carries the exec restart | ||
| # fence (node-agent with fence_retirement_helper, Go 1.27) and IG's node-local | ||
| # fence provisioner (cmd/fence-provision, tags fence_retirement_helper + | ||
| # fence_retirement_provisioner, Go 1.27, from the IG module version go.mod | ||
| # pins), and tests the provisioner and node-agent's decoding of its outcome. | ||
| # The fence is switched on at runtime (EXEC_RESTART_FENCE=enabled); the Go | ||
| # unit tests (go-basic-tests) run with fence_retirement_helper. | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - "go.mod" | ||
| - "go.sum" | ||
| - "**.go" | ||
| - "build/Dockerfile" | ||
| - ".github/workflows/exec-fence-build.yaml" | ||
|
|
||
| permissions: read-all | ||
|
|
||
| jobs: | ||
| image: | ||
| name: exec-fence-build | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 45 | ||
| env: | ||
| PROVISION_TAGS: fence_retirement_helper,fence_retirement_provisioner | ||
| PROVISION_PKG: github.com/inspektor-gadget/inspektor-gadget/gadgets/enforce_exec/restartfence | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 | ||
|
|
||
| - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 | ||
| name: Setup Go | ||
| with: | ||
| go-version: "1.27.4" | ||
|
|
||
| # The Dockerfile copies tracers.tar; an empty stand-in is enough to | ||
| # build the binaries and check the image layout. | ||
| - name: Build the image | ||
| run: | | ||
| tar -cf tracers.tar --files-from /dev/null | ||
| docker build -f build/Dockerfile -t node-agent:fence-ci . | ||
|
|
||
| - name: Check the image ships fence-provision | ||
| run: | | ||
| id=$(docker create node-agent:fence-ci) | ||
| docker cp "$id:/usr/bin/fence-provision" "$RUNNER_TEMP/fence-provision" | ||
| docker rm "$id" | ||
| test -x "$RUNNER_TEMP/fence-provision" | ||
|
|
||
| - name: Refuse the removed FENCE_DESIGNATED build arg | ||
| run: | | ||
| if docker build -f build/Dockerfile --build-arg FENCE_DESIGNATED=true . > "$RUNNER_TEMP/designated.log" 2>&1; then | ||
| echo "FENCE_DESIGNATED=true built" >&2; exit 1 | ||
| fi | ||
| grep -Eq "^#[0-9]+ [0-9.]+ FENCE_DESIGNATED is gone" "$RUNNER_TEMP/designated.log" | ||
|
|
||
| # Unprivileged, it refuses before touching the host and still prints | ||
| # its outcome and exits 0: the wire format node-agent decodes. | ||
| - name: Smoke-run fence-provision | ||
| run: | | ||
| out=$("$RUNNER_TEMP/fence-provision" -node=ci-node -namespace=kubescape -release=kubescape) | ||
| echo "$out" | ||
| echo "$out" | jq -e '.outcome == "refused" and .reason == "not-root" and .recorded == false' | ||
|
|
||
| # IG's provisioner, record and command tests at the pinned version | ||
| # (kernel tests skip without IG_RESTARTFENCE_KERNEL_TEST). | ||
| - name: Test IG fence provisioning | ||
| run: go test -tags "$PROVISION_TAGS" -count=1 -timeout 10m "$PROVISION_PKG/..." | ||
|
|
||
| # node-agent's decoding of the outcome against IG's own type. | ||
| - name: Test the provisioning contract | ||
| run: go test -tags "$PROVISION_TAGS" -count=1 -run '^TestFenceProvisionOutcomeContract$' ./pkg/sandboxpolicy/integration/ | ||
|
|
||
| # A build without fence_retirement_helper (a plain `go build`/`go test`) | ||
| # compiles the no-fence files instead: it must still build, refuse the | ||
| # gate loudly and report the status the docs describe. | ||
| - name: Vet and test without the fence tag | ||
| run: | | ||
| go vet ./pkg/sandboxpolicy/... ./cmd/... | ||
| go test -exec "sudo --preserve-env=CI" -count=1 -timeout 20m ./pkg/sandboxpolicy/ ./pkg/sandboxpolicy/integration/ ./pkg/config/... |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,18 +31,15 @@ docker buildx build \ | |
| --push . | ||
| ``` | ||
|
|
||
| ### Designated Exec Restart Fence Build | ||
| ### Exec Restart Fence | ||
|
|
||
| The designated fence build (see `docs/features/sandbox-policy.md`) compiles | ||
| node-agent with the tags `fence_designated_agent,fence_retirement_helper` | ||
| and ships IG's node-local fence provisioner as `/usr/bin/fence-provision`, | ||
| built from the same Inspektor Gadget module version as node-agent: | ||
|
|
||
| ```bash | ||
| docker buildx build --build-arg FENCE_DESIGNATED=true -t node-agent:fence -f build/Dockerfile --load . | ||
| # or | ||
| make docker-build FENCE_DESIGNATED=true | ||
| ``` | ||
| Every image carries the exec restart fence (see | ||
| `docs/features/sandbox-policy.md`): node-agent is built with the tag | ||
| `fence_retirement_helper`, and IG's node-local fence provisioner ships as | ||
| `/usr/bin/fence-provision`, built from the same Inspektor Gadget module | ||
| version as node-agent. The fence stays dormant unless the DaemonSet sets | ||
| `EXEC_RESTART_FENCE=enabled`. The former `FENCE_DESIGNATED` build argument is | ||
|
Comment on lines
+40
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document the retirement-name activation path. When Document both activation paths. Update the matching comment in
|
||
| gone; setting it fails the build. | ||
|
|
||
| ### Debug Build | ||
|
|
||
|
|
@@ -109,7 +106,7 @@ docker buildx build \ | |
| | Image | Dockerfile | Description | | ||
| |-------|------------|-------------| | ||
| | `node-agent:latest` | `Dockerfile` | Production image, minimal size | | ||
| | `node-agent:debug` | `Dockerfile.debug` | Includes debug tools (delve, shell) | | ||
| | `node-agent:debug` | `Dockerfile.debug` | Includes debug tools (delve, shell); like the release image, it ships `/usr/bin/fence-provision` | | ||
|
|
||
| ## Building Gadgets | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug builds accept the removed
FENCE_DESIGNATEDargument.Setting
FENCE_DESIGNATEDon a debug image build succeeds. This Dockerfile does not declare or check the argument, so Docker ignores it and prints only a warning. The README states that setting this argument fails the build for every image. A user who sets it expects the former designated flow, but the debug image gets a dormant fence unlessEXEC_RESTART_FENCE=enabledis set at runtime.Declare
ARG FENCE_DESIGNATED=in the build stage before theRUNinstruction. Then add the same guard thatbuild/Dockerfileuses:Reject the removed build argument