refactor(services): deduplicate container security-hardening config across sidecar builders#3274
Conversation
Extract duplicated security-hardening config (cap_drop, security_opt, mem_limit, memswap_limit, pids_limit, cpu_shares) from three sidecar service builders into a single `buildContainerSecurityHardening` helper in the new `src/services/service-security.ts` module. Each service spreads the result so resource limits remain service-specific while the security fields (cap_drop / security_opt) are guaranteed to stay in sync across all sidecars. Closes #<issue>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR refactors the Docker Compose sidecar service builders to avoid copy-pasted container hardening blocks by introducing a shared helper in src/services/service-security.ts.
Changes:
- Added
buildContainerSecurityHardening()helper to centralizecap_drop,security_opt, and common resource-limit fields. - Updated
api-proxy,cli-proxy, anddoh-proxyservice builders to spread the shared hardening config with service-specific limits.
Show a summary per file
| File | Description |
|---|---|
| src/services/service-security.ts | Introduces a shared helper to build consistent container hardening/resource-limit fields for sidecars. |
| src/services/api-proxy-service.ts | Replaces inline hardening/resource-limit block with the shared helper. |
| src/services/cli-proxy-service.ts | Replaces inline hardening/resource-limit block with the shared helper. |
| src/services/doh-proxy-service.ts | Replaces inline hardening/resource-limit block with the shared helper. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 1
| * | ||
| * Centralises the `cap_drop`, `security_opt`, and resource-limit fields that | ||
| * must be applied uniformly to every sidecar service built by the firewall. | ||
| * Using a single helper means a future hardening change (e.g. adding | ||
| * `read_only: true`) propagates to all sidecars automatically. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot address review feedback |
This comment has been minimized.
This comment has been minimized.
The module and function JSDoc now explicitly name the three proxy sidecars (api-proxy, cli-proxy, doh-proxy) this helper targets and call out that squid-service and agent-service have different hardening requirements and should not use it.
Done in the latest commit. The module-level JSDoc now explicitly names the three proxy sidecars ( |
Smoke Test Results
Total: FAIL (2 pass, 1 fail)
|
🔬 Smoke Test Results
Overall: FAIL — Pre-computed step outputs (
|
Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Overall: FAIL — workflow template variables were not substituted before agent execution; pre-step data unavailable for verification.
|
|
Smoke Test Codex: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Chroot Runtime Version Comparison
Result: Some versions differ between host and chroot. Go matches, but Python and Node.js are on different versions (Python patch version differs; Node.js major version differs: 24 vs 20).
|
|
Gemini Engine Smoke Test: FAIL (MCP missing, Connectivity failed) Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results
Overall: FAIL —
|
cap_drop,security_opt, and the resource-limit fields were copy-pasted verbatim into three sidecar service builders, meaning a hardening change (e.g. addingread_only: true) had to be applied manually in three places and could silently diverge.Changes
New
src/services/service-security.ts— exportsbuildContainerSecurityHardening(limits)which returns the standard hardening block;cap_drop/security_optare fixed, resource limits are per-caller:api-proxy-service.ts,doh-proxy-service.ts,cli-proxy-service.ts— replace the inline blocks with a single spread:Resource limits remain service-specific; security fields are now a single source of truth.