refactor: split writeConfigs into focused setup phases#5521
Conversation
writeConfigs into focused setup phaseswriteConfigs into focused setup phases
There was a problem hiding this comment.
Pull request overview
This PR refactors writeConfigs in src/config-writer.ts into smaller, focused setup-phase helpers to make security-critical configuration steps easier to review and unit test, while keeping the public writeConfigs(config) API unchanged.
Changes:
- Extracts workdir hardening, seccomp profile copying, SSL-bump initialization, and audit artifact writing into dedicated helper functions.
- Introduces a
NetworkConfiginterface to name and type the shared network-topology object passed across phases. - Exposes the helper functions via
configWriterTestHelpers(marked/** @internal */) to enable isolated unit testing.
Show a summary per file
| File | Description |
|---|---|
src/config-writer.ts |
Splits writeConfigs into explicit setup phases with helper functions and adds typed network topology + internal test helpers. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 4
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
✅ Copilot review passed with no inline comments. @copilot Add the |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓 |
|
Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded. |
|
✅ Smoke Gemini completed. All facets verified. 💎 |
|
✅ Smoke Claude passed |
|
✅ Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓 |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅ |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
🔌 Smoke Services — All services reachable! ✅ |
|
🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅ |
|
✅ Contribution Check completed successfully! Contribution guidelines check complete for PR #5521: no important missing items found in the pre-fetched PR context, so no PR comment was needed. |
|
✅ Build Test Suite completed successfully! |
|
✅ Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓 |
|
🚀 Security Guard has started processing this pull request |
Smoke Test: Claude Engine Validation
Overall result: PASS
|
🔬 Smoke Test Results — PASS
PR: refactor: split Overall: PASS ✅
|
Smoke Test: Copilot BYOK (Direct) Mode ✅ PASSTests:
Mode: Direct BYOK via Status: All systems operational.
|
🔬 Smoke Test: Copilot PAT Auth — FAIL
Overall: FAIL — pre-computed step outputs ( PR: refactor: split Auth mode: PAT (COPILOT_GITHUB_TOKEN)
|
🔭 Smoke Test: API Proxy OpenTelemetry Tracing
All scenarios pass. ✅
|
Chroot Version Smoke Test Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.
|
Smoke Test Results: Gemini Engine
✅ GitHub MCP Testing Overall status: PASS 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.
|
|
Reviewed PRs: 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.
|
Smoke Test Results — FAIL
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
|
|
|
Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)
|
writeConfigsinsrc/config-writer.tswas a 171-line monolith performing seven sequential phases — including three security-critical ones (seccomp, SSL-bump, Squid ACL) — buried in the same linear function body as orchestration boilerplate, making them hard to review and impossible to test in isolation.Changes
validateAndPrepareWorkDir(config)— workdir0o700hardening + symlink guardcopySeccompProfile(config)— three-path fallback (embedded → source → dist); throws if missinginitializeSslBump(config)— OpenSSL preflight + per-session CA + SSL DB init; returnsSslConfig | undefinedwriteAuditArtifacts(config, networkConfig, dockerCompose, squidConfig)— redacted compose, squid.conf copy, policy-manifest.jsonwriteConfigsreduced to a ~65-line orchestration facade with labeled phase commentsconfigWriterTestHelpersexports the four helpers for independent unit testing, following the/** @internal */+// ts-prune-ignore-nextpattern used inworkdir-setup.tsAdded a
NetworkConfiginterface to give the inline network topology object a named type, used across phases 1–7.All existing tests pass unchanged; no callers modified.