Skip to content

refactor(config): replace hardcoded "docker" literals with DefaultContainerRuntime constant - #10475

Merged
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-for-runtime-wrappers
Jul 31, 2026
Merged

refactor(config): replace hardcoded "docker" literals with DefaultContainerRuntime constant#10475
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-for-runtime-wrappers

Conversation

Copilot AI commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

The two default-runtime wrapper functions in validation_env.go each hardcoded "docker", duplicating a magic string that already had a canonical constant (DefaultContainerRuntime) in config_core.go.

Changes

  • internal/config/validation_env.go: Replace "docker" literals in ValidateExecutionEnvironment and ValidateContainerizedEnvironment with the existing DefaultContainerRuntime constant.
// Before
func ValidateExecutionEnvironment() *EnvValidationResult {
    return ValidateExecutionEnvironmentForRuntime("docker")
}
func ValidateContainerizedEnvironment(containerID string) *EnvValidationResult {
    return ValidateContainerizedEnvironmentForRuntime(containerID, "docker")
}

// After
func ValidateExecutionEnvironment() *EnvValidationResult {
    return ValidateExecutionEnvironmentForRuntime(DefaultContainerRuntime)
}
func ValidateContainerizedEnvironment(containerID string) *EnvValidationResult {
    return ValidateContainerizedEnvironmentForRuntime(containerID, DefaultContainerRuntime)
}

DefaultContainerRuntime = "docker" was already defined in config_core.go; no new constant is introduced.

Copilot AI changed the title [WIP] Remove duplicate code in ForRuntime wrapper functions refactor(config): replace hardcoded "docker" literals with DefaultContainerRuntime constant Jul 31, 2026
Copilot finished work on behalf of lpcox July 31, 2026 20:44
Copilot AI requested a review from lpcox July 31, 2026 20:44
@lpcox
lpcox marked this pull request as ready for review July 31, 2026 21:27
Copilot AI review requested due to automatic review settings July 31, 2026 21:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reuses the canonical container-runtime default in environment validation, resolving #10446 without behavior changes.

Changes:

  • Replaces two hardcoded "docker" values with DefaultContainerRuntime.
Show a summary per file
File Description
internal/config/validation_env.go Uses the shared default-runtime constant in validation wrappers.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default AWF

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads (issues/PRs/file/commits) data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) all refused Error[-32602]: unknown tool BLOCKED
C CLI reads (via github CLI bridge) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) all rejected — gh unauthenticated (no GH_TOKEN) BLOCKED
E CLI GraphQL mutations (addReaction/addStar/createIssue) all rejected — gh unauthenticated (no GH_TOKEN) BLOCKED

Overall: PASS

Note on Part B: Gateway enforces read-only via tool allowlist — write tools return MCP-level Error[-32602]: unknown tool (gateway strips them from the tool registry). No writes leaked.
Note on Parts D/E: gh CLI is unauthenticated in this runtime; all REST/GraphQL write attempts rejected before reaching the API.

References: §30664008041

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — gVisor

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: gVisor (runsc) kernel-level isolation

Part Surface Op Result Expected Status
A MCP reads (list_issues/PRs/commits, get_file_contents) data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) unknown tool [-32602] on all 7 BLOCKED
C CLI reads (list_issues, get_file_contents) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) unauthenticated refusal (no GH_TOKEN) BLOCKED
E CLI GraphQL mutations (addReaction/addStar/createIssue) unauthenticated refusal (no GH_TOKEN) BLOCKED

Overall: PASS

Note — Part B: All 7 write tools returned MCP-level error [-32602]: unknown tool — the gateway enforces read-only by stripping write tools from the tool list entirely. This is a gateway-specific enforcement, not merely backend config.

Note — Parts D & E: gh CLI is unauthenticated in this sandbox (no GH_TOKEN), so all REST/GraphQL write attempts were refused at the CLI auth layer. No write reached the GitHub API.

References: §30664008034

🔒 mcpg read-only stress (gVisor runtime) by Read-Only Stress: gVisor runtime

@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — docker-sbx

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: docker-sbx (KVM-isolated microVM)

Part Surface Op Result Expected Status
A MCP reads (list_issues/list_prs/get_file/list_commits) data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) Error [-32602]: unknown tool BLOCKED
C CLI reads (list_issues/get_file) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) gh unauthenticated — blocked BLOCKED
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh unauthenticated — blocked BLOCKED

Overall: PASS

Notes:

  • Part B gateway enforcement: all 7 write tools refused at MCP level with Error [-32602]: unknown tool — write tools are absent from the gateway-exposed tool set, confirming read-only enforcement.
  • Parts D & E: gh CLI is unauthenticated in this sandbox; all REST and GraphQL write attempts rejected at auth layer.
  • docker-sbx microVM isolation did not affect the enforcement surface.

References: §30664007938

🔒 mcpg read-only stress (docker-sbx runtime) by Read-Only Stress: docker-sbx runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[duplicate-code] Duplicate Code Pattern: Paired ForRuntime default-wrapper functions with hardcoded runtime string

3 participants