codex-copilot-dx 0.4.17 → 0.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/bin/cli.mjs +3 -5
- package/package.json +1 -1
- package/src/security.mjs +13 -0
package/README.md
CHANGED
|
@@ -83,8 +83,9 @@ Environment variables:
|
|
|
83
83
|
|
|
84
84
|
| Variable | Default | Description |
|
|
85
85
|
|----------|---------|-------------|
|
|
86
|
-
| `ADAPTER_HOST` | `127.0.0.1` | Host for the adapter;
|
|
86
|
+
| `ADAPTER_HOST` | `127.0.0.1` | Host for the adapter; only loopback hosts are allowed by default |
|
|
87
87
|
| `ADAPTER_PORT` | `2026` | Port for the adapter |
|
|
88
|
+
| `CCDX_ALLOW_LAN` | unset | Set to `1` to allow non-loopback `ADAPTER_HOST` values such as `0.0.0.0`; exposes your Copilot-backed adapter beyond this machine |
|
|
88
89
|
| `CCDX_MAX_BODY_BYTES` | `134217728` | Maximum compressed/raw request body size |
|
|
89
90
|
| `CCDX_MAX_DECODED_BODY_BYTES` | `268435456` | Maximum decoded request body size after decompression |
|
|
90
91
|
| `CCDX_UPSTREAM_TIMEOUT_MS` | `120000` | Timeout for non-streaming upstream Copilot requests |
|
package/bin/cli.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { printUsageSummary } from "../src/usage.mjs";
|
|
|
12
12
|
import { checkForUpdate, localPackageVersion } from "../src/version.mjs";
|
|
13
13
|
import { runDoctor } from "../src/doctor.mjs";
|
|
14
14
|
import { checkRunningAdapter } from "../src/running-adapter.mjs";
|
|
15
|
+
import { assertSafeAdapterHost, isLoopbackHost } from "../src/security.mjs";
|
|
15
16
|
|
|
16
17
|
const ADAPTER_PORT = parseInt(process.env.ADAPTER_PORT || "2026");
|
|
17
18
|
const ADAPTER_HOST = process.env.ADAPTER_HOST || "127.0.0.1";
|
|
@@ -21,10 +22,6 @@ const LOCAL_VERSION = localPackageVersion();
|
|
|
21
22
|
const command = process.argv[2];
|
|
22
23
|
const CONFIGURE_CLAUDE_DESKTOP = command === "--configure-claude-desktop" || process.env.CCDX_CONFIGURE_CLAUDE_DESKTOP === "1";
|
|
23
24
|
|
|
24
|
-
function isLoopbackHost(host) {
|
|
25
|
-
return ["127.0.0.1", "localhost", "::1"].includes(String(host).toLowerCase());
|
|
26
|
-
}
|
|
27
|
-
|
|
28
25
|
async function refreshClaudeDesktopModelDefs() {
|
|
29
26
|
if (parseModelAliasEnv(process.env.CCDX_CLAUDE_MODEL_ALIASES).length) {
|
|
30
27
|
console.log(status("info", "Using CCDX_CLAUDE_MODEL_ALIASES for Claude models"));
|
|
@@ -128,6 +125,7 @@ checkForUpdate({ currentVersion: LOCAL_VERSION }).then(({ latestVersion, updateA
|
|
|
128
125
|
});
|
|
129
126
|
|
|
130
127
|
try {
|
|
128
|
+
assertSafeAdapterHost(ADAPTER_HOST, process.env);
|
|
131
129
|
if (await reuseRunningAdapterIfAvailable()) process.exit(0);
|
|
132
130
|
|
|
133
131
|
// Ensure GitHub login, using device flow if no token exists.
|
|
@@ -138,7 +136,7 @@ try {
|
|
|
138
136
|
const claudeDesktopModelDefs = await refreshClaudeDesktopModelDefs();
|
|
139
137
|
|
|
140
138
|
if (!isLoopbackHost(ADAPTER_HOST)) {
|
|
141
|
-
console.log(status("warn", `ADAPTER_HOST=${ADAPTER_HOST} exposes the adapter beyond loopback. Use only on trusted networks.`));
|
|
139
|
+
console.log(status("warn", `ADAPTER_HOST=${ADAPTER_HOST} exposes the adapter beyond loopback because CCDX_ALLOW_LAN=1 is set. Use only on trusted networks.`));
|
|
142
140
|
}
|
|
143
141
|
|
|
144
142
|
const claudeDesktopApiKey = CONFIGURE_CLAUDE_DESKTOP
|
package/package.json
CHANGED
package/src/security.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function isLoopbackHost(host) {
|
|
2
|
+
const normalized = String(host || "").toLowerCase().replace(/^\[(.*)\]$/, "$1");
|
|
3
|
+
return ["127.0.0.1", "localhost", "::1"].includes(normalized);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function isLanAllowed(env = process.env) {
|
|
7
|
+
return ["1", "true", "yes"].includes(String(env.CCDX_ALLOW_LAN || "").toLowerCase());
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function assertSafeAdapterHost(host = "127.0.0.1", env = process.env) {
|
|
11
|
+
if (isLoopbackHost(host) || isLanAllowed(env)) return;
|
|
12
|
+
throw new Error(`Refusing to bind ADAPTER_HOST=${host} beyond loopback without CCDX_ALLOW_LAN=1. This adapter carries your GitHub Copilot access.`);
|
|
13
|
+
}
|