Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(e2e): keep login passwords out of jq argv
Alfredo Lopez81bc8ea45d11
diff --git a/scripts/e2e/e2e-825-lib.sh b/scripts/e2e/e2e-825-lib.shindex 0fe55ab2f..81598d242 100644--- a/scripts/e2e/e2e-825-lib.sh+++ b/scripts/e2e/e2e-825-lib.sh@@ -9,7 +9,8 @@# ─── HTTP ─────────────────────────────────────────────────────────────# http METHOD URL [BODY] [MAX_SECONDS] → HTTP_CODE, HTTP_BODY. A transport# failure is HTTP_CODE=000 and a non-zero return. The body goes to curl on-# stdin, never in argv, because login bodies carry passwords.+# stdin, never in argv, because login bodies carry passwords; the login+# helpers hand the password to jq through its environment for the same reason.http() {local method=$1 url=$2 body=${3:-} max=${4:-60} resplocal args=(-sS -m "$max" -w '\n%{http_code}' -X "$method" "$url")@@ -37,7 +38,7 @@ admin_login() {local headers="${SCRATCH}/admin-login.headers" line cookieHTTP_HEADERS=(-D "$headers")http POST "${CAPI}/admin/auth/login" \- "$(jq -cn --arg u "$ADMIN_USERNAME" --arg p "$ADMIN_PASSWORD" '{username:$u,password:$p}')" || true+ "$(ADMIN_PASSWORD="$ADMIN_PASSWORD" jq -cn --arg u "$ADMIN_USERNAME" '{username:$u,password:env.ADMIN_PASSWORD}')" || true[[ "$HTTP_CODE" =~ ^2 ]] || { fail "admin login returned ${HTTP_CODE}"; return 1; }while IFS= read -r line; doline="${line%$'\r'}"@@ -55,7 +56,7 @@ admin_login() {user_login() {HTTP_HEADERS=()http POST "${EXT_BASE}/api/v1/auth/password-login" \- "$(jq -cn --arg e "$DEV_EMAIL" --arg p "$DEV_PASSWORD" '{email:$e,password:$p}')" || true+ "$(DEV_PASSWORD="$DEV_PASSWORD" jq -cn --arg e "$DEV_EMAIL" '{email:$e,password:env.DEV_PASSWORD}')" || true[ "$HTTP_CODE" = 200 ] || { fail "password login for ${DEV_EMAIL} returned ${HTTP_CODE} (a 429 means the lockout window; wait, do not retry blindly)"; return 1; }SESSION_TOKEN="$(jq -er '.token' <<<"$HTTP_BODY")" || { fail 'password login returned no token'; return 1; }}diff --git a/scripts/e2e/e2e-hcc-storage-layout-switch.test.mjs b/scripts/e2e/e2e-hcc-storage-layout-switch.test.mjsindex 57ac45c5c..581d60972 100644--- a/scripts/e2e/e2e-hcc-storage-layout-switch.test.mjs+++ b/scripts/e2e/e2e-hcc-storage-layout-switch.test.mjs@@ -118,6 +118,65 @@ admin GET http://127.0.0.1:1/admin && rpc GET http://127.0.0.1:2/rpc && echo "CO}})+test('admin_login and user_login keep passwords out of jq argv', () => {+ const dir = mkdtempSync(path.join(tmpdir(), 'e2e-825-login-'))+ try {+ const realJq = spawnSync('bash', ['-c', 'command -v jq'], { encoding: 'utf8' }).stdout.trim()+ assert.ok(realJq, 'jq not found on PATH')+ const bin = path.join(dir, 'bin')+ const jqArgv = path.join(dir, 'jq-argv')+ const sent = path.join(dir, 'sent-bodies')+ spawnSync('mkdir', [bin])+ // A PATH executable, not a shell function: what ps would show is the argv+ // of this process.+ writeFileSync(+ path.join(bin, 'jq'),+ `#!/bin/sh\nprintf '%s\\n' "$@" >>"$JQ_ARGV"\nexec '${realJq}' "$@"\n`,+ { mode: 0o755 }+ )+ const body = `+fail() { echo "FAIL — $*"; }+curl() {+ local prev= a+ for a in "$@"; do+ [ "$prev" = -D ] && printf 'Set-Cookie: control_ui_admin_session=c1; Path=/\\r\\n' >"$a"+ prev=$a+ done+ cat >>"$SENT"; echo >>"$SENT"+ printf '{"token":"t1"}\\n200'+}+SCRATCH="$DIR" CAPI=http://127.0.0.1:1 EXT_BASE=http://127.0.0.1:2 HTTP_HEADERS=()+ADMIN_USERNAME=admin ADMIN_PASSWORD='admin pw-secret-1' [email protected] DEV_PASSWORD='dev"pw-secret-2'+${helper('http')}+${helper('admin_login')}+${helper('user_login')}+admin_login && user_login && echo "OK $ADMIN_COOKIE $SESSION_TOKEN"+`+ const run = bash(body, {+ DIR: dir,+ SENT: sent,+ JQ_ARGV: jqArgv,+ PATH: `${bin}:${process.env.PATH}`,+ })+ assert.equal(run.status, 0, run.stderr)+ assert.equal(run.stdout.trim(), 'OK c1 t1')+ const args = readFileSync(jqArgv, 'utf8')+ assert.doesNotMatch(args, /pw-secret/)+ // Witness: jq built both login bodies, and they carry the exact passwords.+ assert.match(args, /username/)+ assert.match(args, /email/)+ assert.deepEqual(+ readFileSync(sent, 'utf8').trim().split('\n').map(line => JSON.parse(line)),+ [+ { username: 'admin', password: 'admin pw-secret-1' },+ { email: '[email protected]', password: 'dev"pw-secret-2' },+ ]+ )+ } finally {+ rmSync(dir, { recursive: true, force: true })+ }+})+test('main_evidence_ok accepts only a passing main log of the same HEAD', () => {const dir = mkdtempSync(path.join(tmpdir(), 'e2e-825-upgrade-evidence-'))try {