Commit 93903cf
feat: phase 1 – gh CLI proxy sidecar with mcpg DIFC proxy (#1730)
* Initial plan
* feat: implement Phase 1 - CLI proxy sidecar with mcpg DIFC proxy
- Add containers/cli-proxy/ with Dockerfile, server.js, entrypoint.sh,
healthcheck.sh, package.json, and server.test.js (49 unit tests)
- Add CLI_PROXY_PORT constant and enableCliProxy/cliProxyWritable/
cliProxyPolicy/githubToken config fields to src/types.ts
- Add cli-proxy service definition in src/docker-manager.ts:
- IP 172.30.0.50 on awf-net
- Passes GH_TOKEN to mcpg DIFC proxy; never exposed to agent
- AWF_CLI_PROXY_URL set in agent environment
- GITHUB_TOKEN/GH_TOKEN excluded from agent when cli-proxy enabled
- AWF_CLI_PROXY_IP propagated to iptables-init
- Log preservation in cleanup
- Add --enable-cli-proxy, --cli-proxy-writable, --cli-proxy-policy flags
to src/cli.ts; add --enable-cli-proxy to predownload subcommand
- Add AWF_CLI_PROXY_IP iptables RETURN rule in setup-iptables.sh
- Add gh-cli-proxy-wrapper.sh to agent container; activated at runtime
via AWF_CLI_PROXY_URL in both chroot and non-chroot modes
- Add 18 new docker-manager tests for CLI proxy service; update existing
container removal test to include awf-cli-proxy
Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/b5f7487a-4993-4737-a01e-8f091a8e84c7
* fix: address code review and CodeQL feedback
- Fix test name: 'should not include cli-proxy when cliProxyIp is missing'
- Fix gh-cli-proxy-wrapper.sh: capture curl exit code in CURL_EXIT variable
before checking it (avoids $? being overwritten by shell); remove set -e
- Fix entrypoint.sh: clarify log message that /tmp/awf-lib/gh is the path
inside the chroot (not the host-prefixed /host/tmp/awf-lib/gh path)
- Fix server.js: sanitize error message in catch block to avoid stack trace
exposure (CodeQL js/stack-trace-exposure)
Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/b5f7487a-4993-4737-a01e-8f091a8e84c7
* fix: address all review feedback on cli-proxy
- Dockerfile: Add USER cliproxy so mcpg and HTTP server run as non-root;
fix log and TLS dir ownership to be writable by cliproxy before USER switch
- entrypoint.sh: Fail closed when GH_TOKEN is missing (exit 1) instead of
starting an unenforced server; fix signal handling by running Node in the
background with wait/trap so cleanup kills both Node and mcpg on SIGTERM
- server.js: Add blocked write actions for codespace (create/delete/edit/stop/
ports), cache (delete), and org (invite) in BLOCKED_ACTIONS_READONLY;
track subcommandIndex during the scan instead of using args.indexOf() to
prevent bypass when the subcommand string appears earlier as a flag value;
add MAX_REQUEST_BODY_BYTES limit in readBody (returns null + 413 on overflow)
- gh-cli-proxy-wrapper.sh: Remove curl -f; capture HTTP status code with -w
and response body with -o so 4xx policy errors (403) surface the actual
.error message instead of "CLI proxy unavailable"
- cli.ts: Read GITHUB_TOKEN || GH_TOKEN for githubToken; update warning to
mention both env var names
- build.yml: Add 'Run CLI proxy unit tests' step parallel to api-proxy step
- server.test.js: Add 11 new tests covering cache/codespace/org blocked
actions and the subcommandIndex indexOf-bypass fix (58 tests total)
Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/4d1512c6-a5af-49dc-9693-2f2c1af0b173
* fix: api read-only deny, trusted-bots, pin mcpg image, comments
- server.js: Remove 'api' from ALLOWED_SUBCOMMANDS_READONLY; raw HTTP
passthrough can mutate via -X POST/PUT/DELETE. 'api' allowed in writable
mode. Add explanatory comment. (61 tests total)
- entrypoint.sh: Add --trusted-bots flag to mcpg so guard policies don't
reject bot-authored content (Dependabot, Copilot, github-actions)
- Dockerfile: Pin ghcr.io/github/gh-aw-mcpg :latest -> :v0.2.2 for
reproducible builds
- docker-manager.ts: Expand GITHUB_TOKEN exclusion comment explaining
design intent and why it is safe in practice
- cli.ts: Restore // -- Logging & Debug -- section header before --log-level
- server.test.js: Add 3 new tests (61 total)
Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/2e1f5421-3e78-44f2-a1c0-d2920f65a173
* feat: add --cli-proxy-mcpg-image for compiler-controlled mcpg version
Make the gh-aw-mcpg source image configurable via CLI so the AWF compiler
can control which mcpg version is pulled and run in the cli-proxy sidecar:
- Dockerfile: use ARG MCPG_IMAGE (default ghcr.io/github/gh-aw-mcpg:v0.2.2)
- src/types.ts: add cliProxyMcpgImage to WrapperConfig
- src/cli.ts: add --cli-proxy-mcpg-image flag under CLI Proxy section
- src/docker-manager.ts: pass MCPG_IMAGE build arg when building locally
- src/docker-manager.test.ts: 3 new tests (320 total)
Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/15ba6c64-db6c-4c47-b813-21878fb57168
* feat: bump default mcpg image to v0.2.15
Update the default MCPG_IMAGE from v0.2.2 to v0.2.15 in:
- containers/cli-proxy/Dockerfile (ARG default)
- src/cli.ts (--cli-proxy-mcpg-image flag default)
- src/types.ts (JSDoc @default)
Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/dba17693-9f82-440d-9284-d2e36ccac016
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* test: add coverage for enableCliProxy in predownload and CLI
Add tests for:
- resolveImages with enableCliProxy
- resolveImages with both enableApiProxy and enableCliProxy
- predownloadCommand with enableCliProxy
- handlePredownloadAction forwarding enableCliProxy
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test: add coverage for emitCliProxyStatusLogs in cli.ts
Extract CLI proxy logging into testable emitCliProxyStatusLogs()
function (same pattern as emitApiProxyTargetWarnings). Add tests for:
- disabled/undefined cli proxy (no-op)
- enabled with token present (read-only and writable modes)
- enabled with missing token (warning messages)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: Landon Cox <landon.cox@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 21616f5 commit 93903cf
19 files changed
Lines changed: 5971 additions & 7 deletions
File tree
- .github/workflows
- containers
- agent
- cli-proxy
- src
- commands
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | | - | |
| 85 | + | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
478 | 478 | | |
479 | 479 | | |
480 | 480 | | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
481 | 499 | | |
482 | 500 | | |
483 | 501 | | |
| |||
782 | 800 | | |
783 | 801 | | |
784 | 802 | | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
785 | 818 | | |
786 | 819 | | |
787 | 820 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
176 | 183 | | |
177 | 184 | | |
178 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments