Skip to content

Commit d676b90

Browse files
Copilotlpcox
andauthored
Stop relying on GITHUB_ENV for proxy TLS trust propagation
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/6579536c-4790-47dc-8c0c-eed5aaaf2030 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
1 parent 0ed4820 commit d676b90

3 files changed

Lines changed: 2 additions & 57 deletions

File tree

docs/PROXY_MODE.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,6 @@ export SSL_CERT_FILE=/tmp/gh-aw/mcp-logs/proxy-tls/ca.crt
227227
export GIT_SSL_CAINFO=/tmp/gh-aw/mcp-logs/proxy-tls/ca.crt
228228
```
229229

230-
When `GITHUB_ENV` is present (GitHub Actions), `awmg proxy --tls` appends these TLS trust
231-
variables automatically for downstream steps.
232-
233230
**System-wide (Ubuntu)**:
234231
```bash
235232
cp /tmp/gh-aw/mcp-logs/proxy-tls/ca.crt /usr/local/share/ca-certificates/mcpg-proxy.crt

internal/cmd/proxy.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"crypto/tls"
66
"fmt"
7-
"io"
87
"log"
98
"net"
109
"net/http"
@@ -328,28 +327,5 @@ func configureTLSTrustEnvironment(caCertPath string) error {
328327
return fmt.Errorf("failed to set %s: %w", key, err)
329328
}
330329
}
331-
332-
githubEnvPath := os.Getenv("GITHUB_ENV")
333-
if githubEnvPath == "" {
334-
return nil
335-
}
336-
337-
// Best-effort append: the proxy should still start even if GITHUB_ENV cannot be opened.
338-
// Mode is intentionally 0 because O_CREATE is not used (existing runner-managed file only).
339-
f, err := os.OpenFile(githubEnvPath, os.O_APPEND|os.O_WRONLY, 0)
340-
if err != nil {
341-
logger.LogWarn("startup", "Skipping GITHUB_ENV TLS trust export: open failed for %s: %v", githubEnvPath, err)
342-
return nil
343-
}
344-
defer f.Close()
345-
346-
for _, key := range tlsTrustEnvKeys {
347-
if _, err := io.WriteString(f, key+"="+caCertPath+"\n"); err != nil {
348-
logger.LogWarn("startup", "Skipping GITHUB_ENV TLS trust export: write failed for %s (%s): %v", githubEnvPath, key, err)
349-
return nil
350-
}
351-
}
352-
353-
logProxyCmd.Printf("Appended TLS trust environment to GITHUB_ENV: %s", githubEnvPath)
354330
return nil
355331
}

internal/cmd/proxy_test.go

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ func TestConfigureTLSTrustEnvironment(t *testing.T) {
415415

416416
t.Run("sets trust environment variables in process", func(t *testing.T) {
417417
assert := assert.New(t)
418-
t.Setenv("GITHUB_ENV", "")
419418
for _, key := range tlsTrustEnvKeys {
420419
t.Setenv(key, "")
421420
}
@@ -428,35 +427,8 @@ func TestConfigureTLSTrustEnvironment(t *testing.T) {
428427
}
429428
})
430429

431-
t.Run("skips GITHUB_ENV append when env var is unset or empty", func(t *testing.T) {
432-
t.Setenv("GITHUB_ENV", "")
433-
require.NoError(t, configureTLSTrustEnvironment(caPath))
434-
})
435-
436-
t.Run("appends trust environment variables to GITHUB_ENV", func(t *testing.T) {
437-
assert := assert.New(t)
438-
githubEnvFile := t.TempDir() + "/github_env"
439-
require.NoError(t, os.WriteFile(githubEnvFile, []byte{}, 0o644))
440-
t.Setenv("GITHUB_ENV", githubEnvFile)
441-
for _, key := range tlsTrustEnvKeys {
442-
t.Setenv(key, "")
443-
}
444-
445-
err := configureTLSTrustEnvironment(caPath)
446-
require.NoError(t, err)
447-
448-
content, err := os.ReadFile(githubEnvFile)
449-
require.NoError(t, err)
450-
for _, key := range tlsTrustEnvKeys {
451-
assert.Contains(string(content), key+"="+caPath+"\n")
452-
}
453-
})
454-
455-
t.Run("treats GITHUB_ENV write failures as best-effort", func(t *testing.T) {
456-
if _, err := os.Stat("/dev/full"); err != nil {
457-
t.Skip("/dev/full not available on this platform")
458-
}
459-
t.Setenv("GITHUB_ENV", "/dev/full")
430+
t.Run("does not rely on GITHUB_ENV", func(t *testing.T) {
431+
t.Setenv("GITHUB_ENV", "/path/that/does/not/exist/github_env")
460432
require.NoError(t, configureTLSTrustEnvironment(caPath))
461433
})
462434

0 commit comments

Comments
 (0)