Files
devvm/testdata/stubs/security
T
w3cjandClaude Opus 5.5 ab20aab59d feat(secret): devvm secret and devvm auth, tokens kept on this machine
devvm secret set claude|github [--stdin] saves a token in the macOS
Keychain (through security -i on stdin, never in arguments) or in an
owner-only file elsewhere; devvm auth claude does the same for claude.
secret rm deletes one, secret ls (and devvm secret) lists every secret,
whether it's saved and the VMs using it, and secret use|unuse binds one
to the folder's VM. Saving, deleting, binding and unbinding rewrite the
running proxies' bindings at once, keeping their logins' bindings as the
VM's start wrote them. get stays hidden, for the proxies.

- secrets: Token (whitespace dropped; empty, quotes, backslashes,
  control characters and non-setup claude tokens refused), Save, Delete,
  Bind, FromImage, RefreshFiles; platform: KeychainSet, KeychainDelete.
- netpolicy: Proxy.RefreshSecrets. vm: SecretSave, SecretRm, Secrets,
  SecretUse. ui: Secret (no echo at a terminal, the terminal restored on
  interrupt) and Line.
- Messages: claude_token_howto, github_token_howto, token_prompt,
  no_token, token_quotes, not_setup_token, keychain_save_failed,
  secret_saved, secret_saved_keychain, secret_removed, secret_used,
  secret_unused, secret_with_image, secret_unuse_copied, secret_failed;
  no_claude_token, claude_token_invalid and no_github_token name
  devvm auth claude and devvm secret set github.
- Tests: secret.txtar (set/rm/ls, use/unuse, auth, refused tokens, the
  value never in argv), Go tests for Token, Save/Delete, Bind,
  RefreshFiles, RefreshSecrets, the Keychain calls through the security
  stub (now with -i and delete-generic-password), ui.Secret, vm secrets.
- e2e network: secret set/get/use/ls/unuse/rm with a fake GitHub token;
  the VM gets its own GH_TOKEN placeholder, the proxy puts the token in
  for api.github.com.
- Docs: network.md (saving and binding tokens), coding-agents.md (Claude
  Code login), security.md, commands.md, contributing.md; CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 17:43:18 -06:00

32 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Stand-in for macOS security in tests, so they never touch the real
# Keychain: logs the call to $STUB_LOG (stdin isn't logged, as a value
# there is in no process's arguments). An item is the file
# $STUB_DIR/keychain/ACCOUNT. find-generic-password -a NAME … -w prints it,
# delete-generic-password -a NAME deletes it, each failing as security does
# for an item that isn't there (44); security -i reads
# add-generic-password … -a NAME … -w "VALUE" lines from stdin and saves
# them.
set -euo pipefail
echo "security $*" >> "$STUB_LOG"
kc=$STUB_DIR/keychain
account=""
args=("$@")
for ((i = 0; i < ${#args[@]}; i++)); do [[ ${args[i]} != -a ]] || account=${args[i + 1]:-}; done
case ${1:-} in
find-generic-password)
[[ -n $account && -f $kc/$account ]] || exit 44
cat "$kc/$account" ;;
delete-generic-password)
[[ -n $account && -f $kc/$account ]] || exit 44
rm "$kc/$account" ;;
-i)
re='^add-generic-password .*-a "([^"]*)" .*-w "([^"]*)"$'
while IFS= read -r line; do
[[ $line =~ $re ]] || exit 1
mkdir -p "$kc"
printf '%s\n' "${BASH_REMATCH[2]}" > "$kc/${BASH_REMATCH[1]}"
done ;;
*) exit 1 ;;
esac