fix: tighten the crates lock check, drop the key from child environments
CI / shellcheck + selftests (pull_request) Successful in 1m44s
CI / move v1 to main (pull_request) Skipped

crates-lock-check.sh anchors on `[/:]daniel/gitdan-crates(.git)?/?` and
matches case-insensitively, so a trailing-slash or differently-cased second
commit is counted and a look-alike owner (notdaniel/) is not.
crates-access.sh unsets DEPLOY_KEY once the key file is written, so git, ssh
and timeout no longer inherit it. README says three actions, not two.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MfBCVNDv3y5gm2djeZSAk4
This commit is contained in:
2026-11-22 11:27:46 -06:00
co-authored by Claude Fable 5.2
parent 5b6d8ff7b4
commit ad8cf5756e
4 changed files with 23 additions and 5 deletions
+13 -1
View File
@@ -61,6 +61,16 @@ ok "two commits fail, naming both"
check "$scratch/two2.lock" >/dev/null 2>&1 && fail "two commits under different spellings passed"
ok "two commits fail across URL spellings too"
{ entry core "$SRC?branch=main#$sha_a"; entry shared "git+https://gitdan.com/daniel/gitdan-crates/?branch=main#$sha_b"; } > "$scratch/slash.lock"
check "$scratch/slash.lock" >/dev/null 2>&1 && fail "a second commit spelled with a trailing slash passed"
{ entry core "$SRC?branch=main#$sha_a"; entry shared "git+https://gitdan.com/Daniel/GitDan-Crates.git#$sha_b"; } > "$scratch/case.lock"
check "$scratch/case.lock" >/dev/null 2>&1 && fail "a second commit spelled in another case passed"
ok "a trailing slash or a different case still counts as the repo"
{ entry core "$SRC?branch=main#$sha_a"; entry shared "git+https://gitdan.com/notdaniel/gitdan-crates.git#$sha_b"; } > "$scratch/owner.lock"
check "$scratch/owner.lock" >/dev/null 2>&1 || fail "a look-alike owner counted as a second commit"
ok "a look-alike owner is not this source"
{ entry other "git+ssh://git@gitdan.com:22022/daniel/gitdan-crates-extra.git#$sha_a"
entry a "git+https://example.com/x/y#$sha_a"; entry b "git+https://example.com/x/y#$sha_b"
entry serde "registry+https://github.com/rust-lang/crates.io-index"; } > "$scratch/none.lock"
@@ -79,6 +89,7 @@ cat > "$stub/git" <<'STUB'
#!/usr/bin/env bash
printf '%s\n' "$@" > "$STUB_DIR/git.argv"
printf '%s\n' "${GIT_SSH_COMMAND:-}" > "$STUB_DIR/git.ssh"
printf '%s' "${DEPLOY_KEY:-}" > "$STUB_DIR/git.key"
[ -z "${STUB_GIT_ERR:-}" ] || echo "$STUB_GIT_ERR" >&2
exit "${STUB_GIT_RC:-0}"
STUB
@@ -122,7 +133,8 @@ grep -rqF "$secret_line" "$scratch/workspace" && fail "key material found in the
for f in good.out good.env good.argv good.ssh; do
grep -qF "$secret_line" "$scratch/$f" && fail "key material leaked into $f"
done
ok "key is 0600 in a 0700 directory outside the workspace and in no output, env file or argv"
[ ! -s "$scratch/git.key" ] || fail "DEPLOY_KEY is still in the environment of git"
ok "key is 0600 in a 0700 directory outside the workspace and in no output, env file, argv or child environment"
[ "$(tail -c1 "$keyfile" | od -An -c | tr -d ' ')" = '\n' ] || fail "key file does not end in a newline"
if [ "$have_keygen" = 1 ]; then