fix(harnesses): migrate to ESO secrets_required form, mirror agent-runtimes

The CRS-served harnesses still carried `secrets_files: [{encrypted: true}]`
which now hard-fails on H-SECRET-1 ("SOPS-encrypted secrets_files entries
are no longer permitted") in the dispatcher's harness validator. Sync the
8 provider harnesses with the agent-runtimes copies: same `secrets_required`
shape, same `init.sh` (ESO-mounted file paths), same `bin/` wrappers.

Use bare `account_ref: "<provider>"` (not `<provider>.cp:cp` — that
scope-kind isn't valid per SR-DISP-1-FIELD).

Provider key names follow the per-provider schema as emitted by the CP
provisioner: minimax/airouter/z-ai → api_key; gitea-https/gitea-admin →
{token,base_url,username}; gitea-ssh* → {host,private_key}.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul O'Reilly
2026-05-07 07:26:19 +12:00
parent 8bbf6cbb2f
commit 5f85d895c1
20 changed files with 288 additions and 117 deletions

View File

@@ -0,0 +1,45 @@
#!/bin/bash
# gitea-admin-wrapper.sh — reads the ESO-mounted gitea-admin token at exec time
# and prefixes it as a transient env var to the underlying tool.
#
# M22 Phase 9: token mounted at /run/agent/secrets/gitea-admin/token (read-only,
# tmpfs, mode 0400). The token NEVER enters the wrapper's parent shell — only
# the exec'd tool's environment via `exec env VAR=value cmd`. The brief
# presence in /proc/<tool_pid>/environ of the tool process is the accepted
# floor (per spec/secrets-runtime.md SR-DISP-7 / H-SECRET-4).
set -euo pipefail
TOKEN_FILE="/run/agent/secrets/gitea-admin/token"
# git-credential-helper subcommand: read token and emit git credential format.
# Git invokes us as `gitea-admin-wrapper.sh git-credential-helper get` and
# expects key=value lines on stdout terminated by a blank line.
git_credential_helper() {
if [[ ! -r "$TOKEN_FILE" ]]; then
echo "gitea-admin-wrapper: token file not readable at $TOKEN_FILE" >&2
exit 1
fi
local base_url="${GITEA_BASE_URL:-https://gitea.oreillyit.nz}"
local host
host=$(echo "$base_url" | sed 's|https\?://||')
# Trailing blank line per git credential-helper protocol.
printf 'protocol=https\nhost=%s\nusername=git\npassword=%s\n\n' "$host" "$(cat "$TOKEN_FILE")"
exit 0
}
case "${1:-}" in
git-credential-helper)
git_credential_helper
;;
*)
if [[ ! -r "$TOKEN_FILE" ]]; then
echo "gitea-admin-wrapper: token file not readable at $TOKEN_FILE" >&2
exit 1
fi
# `exec env VAR=...` keeps the secret out of the wrapper's parent shell
# — it lands only in the exec'd tool's /proc/<pid>/environ. NEVER use
# `export VAR=` here, which would leak the secret to the wrapper's
# ancestors (H-SECRET-4 violation).
exec env GITEA_ADMIN_TOKEN="$(cat "$TOKEN_FILE")" "$@"
;;
esac

View File

@@ -17,11 +17,18 @@ ssh_hosts:
identity_secret: SSH_KEY_AI_ENABLEMENT
secrets_required:
# ESO-managed gitea-admin token (M22 Phase 9)
- name: gitea-admin
account_ref: "gitea-admin"
mount_path: /run/agent/secrets/gitea-admin
mode: "0400"
# Legacy SSH key (file-based, already delivered as mount)
- name: SSH_KEY_AI_ENABLEMENT
mount: /home/agent/.ssh/id_ed25519
mode: "0600"
secrets_files:
- source: ./provider.sops.env
target: /opt/harness/secrets/gitea-admin/provider.sops.env
encrypted: true
env:
GITEA_BASE_URL: "https://gitea.oreillyit.nz"
scripts:
init: ./init.sh

View File

@@ -0,0 +1,19 @@
#!/bin/bash
# init.sh for gitea-admin harness (M22 Phase 9)
# Sets up non-secret env vars and configures git credential helper.
# Credential token is NOT exported here — only read at exec time by the wrapper.
set -euo pipefail
# Non-secret configuration
export GITEA_BASE_URL="${GITEA_BASE_URL:-https://gitea.oreillyit.nz}"
# Ensure SSH directory exists with correct permissions
mkdir -p /home/agent/.ssh
chmod 700 /home/agent/.ssh
# Configure git to use the gitea-admin credential helper wrapper
# The wrapper reads the ESO-mounted token at exec time
git config --global credential.helper "!/opt/harness/contexts/gitea-admin/v1/bin/gitea-admin-wrapper.sh git-credential-helper"
echo "[gitea-admin] init complete"