Skip to content

feat: add security-focused container image flavor - #86

Merged
pavelanni merged 3 commits into
mainfrom
feature/security-container-image
Jun 3, 2026
Merged

pavelanni merged 3 commits into
mainfrom
feature/security-container-image

Conversation

@pavelanni

@pavelanni pavelanni commented Jun 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Tools included

Category Tools
Code scanning semgrep, gosec, shellcheck, bandit
Secrets detection gitleaks, trufflehog
Vulnerability/SBOM trivy, grype, syft
Supply chain skopeo, cosign
Base utilities git, make, python3, curl, jq

Design decisions

  • Three-stage build: Go builder → tool downloader (UBI9) → hardened runtime assembly. The hi/go image lacks curl/tar, so downloads use a standard UBI stage (discarded after build)
  • SHA256 checksum verification: All 7 downloaded binaries are verified against pinned checksums. Build fails on mismatch.
  • Version pinning: All tools version-pinned via Dockerfile ARGs, including pip packages (semgrep==1.164.0, bandit==1.9.4)
  • systemd-sysusers stub: tpm2-tss (transitive dep of skopeo) ships a %sysusers scriptlet that fails in the hardened runtime; a no-op stub is created before dnf and removed after
  • Floating :latest base images: Intentional — Red Hat Hardened Images receive continuous CVE fixes; pinning digests would freeze those updates. Trade-off documented in Containerfile.
  • Non-root execution (uid 65532) with writable cache dirs for trivy/grype via env vars
  • Image size: ~1.25 GB (semgrep + Python runtime dominate; acceptable for a specialized scanning image vs. 63 MB base)

Test plan

  • Full build on RHEL 10 x86_64 via podman -c rhel build
  • All 13 tools verified working inside container (--entrypoint sh)
  • SHA256 checksums verified for all 7 downloaded binaries (all OK)
  • Runs as non-root (uid 65532)
  • Test with security-scanner skill on OpenShift

Follow-up

Closes #85

Summary by CodeRabbit

  • New Features

    • A security-focused container image is now available, bundled with industry-standard security and supply-chain analysis tools for vulnerability scanning, secrets detection, and code analysis.
  • Chores

    • Build infrastructure updated to support building and pushing the security container image variant.

Add containers/Containerfile.security with Red Hat Hardened Images base,
bundling code scanning, vulnerability detection, and supply chain
security tools (trivy, gosec, semgrep, gitleaks, grype, cosign, etc.).

Three-stage build: Go compile, tool download (UBI9), hardened runtime
assembly. All tools version-pinned via ARGs. Runs as non-root (uid
65532) with writable cache dirs for trivy/grype.

Add Makefile targets: image-security, image-security-push.

Closes #85

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: c12ad133-ec1f-4f29-892b-f03229fbc9a8

📥 Commits

Reviewing files that changed from the base of the PR and between 02db400 and f479d13.

📒 Files selected for processing (2)
  • Makefile
  • containers/Containerfile.security

📝 Walkthrough

Walkthrough

This pull request adds a security-focused container image variant to DocsClaw. A new Containerfile.security implements a multi-stage build: a builder stage compiles the DocsClaw binary, a tools stage downloads and verifies security scanning tool binaries with pinned versions and SHA-256 checksums, and a runtime stage assembles the final hardened image with all tools, dependencies, and workspace configuration. The Makefile adds corresponding image-security and image-security-push targets to build and push this image variant.

Changes

Security-focused Container Image Flavor

Layer / File(s) Summary
Builder and tools stages
containers/Containerfile.security
Builder stage compiles the DocsClaw Go binary with CGO disabled. Tools stage downloads, verifies with SHA-256 checksums, and extracts security scanning binaries (Trivy, Gosec, Gitleaks, Trufflehog, Grype, Syft, Cosign) with pinned versions.
Runtime stage and image configuration
containers/Containerfile.security
Runtime stage based on hardened core-runtime installs dnf packages (curl, jq, git-core, make, Python tooling, ShellCheck, Skopeo), Python packages (Semgrep, Bandit), copies compiled binary and downloaded tools, sets up writable workspace with cache directories for Trivy and Grype, configures non-root user execution, and defines port/entrypoint.
Build automation targets
Makefile
Makefile declares image-security and image-security-push phony targets; image-security builds amd64 image with -security tag suffix using the new Containerfile, and image-security-push pushes the tag to registry.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a security-focused container image flavor, which is the primary objective of the PR.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #85: security tools bundled (13 tools across scanning, secrets detection, vulnerability analysis), multi-stage build with SHA256 verification, version pinning, non-root execution, and Makefile targets for building and pushing the security image.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #85 objectives: Containerfile.security, Makefile targets for the security image, and container build infrastructure. No unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/security-container-image

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

Address review findings:
- Verify SHA256 checksums for all 7 downloaded tool binaries (trivy,
  gosec, gitleaks, trufflehog, grype, syft, cosign). Build fails if
  any checksum mismatches.
- Pin semgrep==1.164.0 and bandit==1.9.4 for reproducible builds,
  matching the version-pinning pattern used for binary tools.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Red Hat Hardened Images use :latest intentionally to receive continuous
CVE fixes. Document this trade-off per review feedback (Kimi-2.6).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@pavelanni
pavelanni marked this pull request as ready for review June 3, 2026 22:18
@pavelanni
pavelanni merged commit 83c7ffa into main Jun 3, 2026
4 checks passed
@pavelanni
pavelanni deleted the feature/security-container-image branch June 3, 2026 22:23
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.

feat: add security-focused container image flavor

1 participant