cockpit: the test Connect a client copies reads the key through a descriptor, not curl's arguments

The local CI's scan for secrets on a command line (tests/test_no_secret_in_argv.py) found the copied
test sending -H "Authorization: Bearer $(cat <key file>)": the shell spells the key into curl's
arguments, where any local user reads it in /proc. The header now goes through a descriptor,
-H @<(printf 'Authorization: Bearer %s\n' ...), as the repo's own scripts do. Run on the reference
box against the proxy, the copied command is answered by the lane that serves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hasan BasbunarandClaude Opus 5.5 committed 2026-11-09 11:16:02 +01:00
1 parent 930966ff44
commit d534bb58bc
2 files changed
+6 -3

No files matched your search

+4 -2
View File
@@ -249,7 +249,9 @@ function renderApi(){
// with client keys, the proxy refuses every other key, the cockpit's login included (keepalive-proxy.py, its wall)
const keySaid = d.client_keys ? "a client key of yours, from the proxy's keys file: it refuses any other, the cockpit's login included"
: `the cockpit's login, in ${d.key_file} on the box`;
const keyArg = d.client_keys ? '$YOUR_CLIENT_KEY' : `$(cat ${d.key_file})`;
// the header through a descriptor, never an argument of curl's, where any local user reads it in /proc (the rule of
// tests/test_no_secret_in_argv.py, which caught this command at first)
const keyHeader = `@<(printf 'Authorization: Bearer %s\\n' "${d.client_keys ? '$YOUR_CLIENT_KEY' : `$(cat ${d.key_file})`}")`;
const rows = [['OpenAI API', `${base}/v1`, 'wrap'], ['Anthropic API', base, 'wrap'], ['Model', modelSaid], ['Key', keySaid, 'wrap'],
boxOnly ? ['Other machines', `the proxy listens on this box only (PROXY_BIND=${d.bind}): PROXY_BIND=0.0.0.0 ./install.sh opens it, the key still the gate`, 'wrap']
: others.length ? ['From another machine', others.join('\n'), 'wrap lines'] : [null, null],
@@ -259,7 +261,7 @@ function renderApi(){
// claude-local sets Claude Code up for the lane that serves (proxy, key, model, budgets: docs/clients.md); the test
// reads the key from its file, on the box, and never shows it
const items = [['Copy the address', `${base}/v1`], ['Copy for Claude Code, on the box', 'claude-local'],
['Copy a test', `curl -s ${base}/v1/chat/completions -H "Authorization: Bearer ${keyArg}" -H 'Content-Type: application/json' -d '{"model":"${m}","messages":[{"role":"user","content":"Say ok."}],"max_tokens":8}'`]];
['Copy a test', `curl -s ${base}/v1/chat/completions -H ${keyHeader} -H 'Content-Type: application/json' -d '{"model":"${m}","messages":[{"role":"user","content":"Say ok."}],"max_tokens":8}'`]];
// the unit not read: the proxy's usual port, said as a guess (review of v1.45.1)
const aside = !d.known ? 'its port not read: 30001 assumed' : boxOnly ? 'from this box only' : 'OpenAI and Anthropic APIs';
// built again only when what it says changed: rebuilt at every tick of the lanes (2 s), a selection or a focus on
+2 -1
View File
@@ -1050,8 +1050,9 @@ class AClientIsToldWhereToSendItsRequests(unittest.TestCase):
self.assertIn("OpenAI APIhttp://[fd7a:115c::1]:30001/v1", r["v6"])
self.assertIn("a client key of yours", r["v6"])
self.assertIn("the cockpit's login included", r["v6"])
self.assertIn("Bearer $YOUR_CLIENT_KEY", r["test"])
self.assertIn("-H @<(printf 'Authorization: Bearer %s\\n' \"$YOUR_CLIENT_KEY\")", r["test"])
self.assertNotIn("api-key", r["test"])
self.assertNotIn('-H "Authorization', r["test"], "the key in curl's arguments, read by any local user")
self.assertTrue(r["same"], "rebuilt though nothing it says changed")
self.assertIn("Modelreading the lane that serves", r["switched"])
self.assertEqual(r["aside"], "its port not read: 30001 assumed")