Merge pull request 'Closeout: crates-access review findings' (#38) from chore/closeout-townlife into main
This commit was merged in pull request #38.
This commit is contained in:
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
Shared Gitea Actions composite actions for the gitdan forge.
|
Shared Gitea Actions composite actions for the gitdan forge.
|
||||||
|
|
||||||
Two actions. The first, done properly: **`cargo-cache`** — a persistent,
|
Three actions: `cargo-cache`, `cargo-cache-publish` and `gitdan-crates-access`
|
||||||
|
(read access to the private crates repo, [below](#gitdan-crates-access)). The
|
||||||
|
cache, done properly: **`cargo-cache`** — a persistent,
|
||||||
per-branch Cargo build cache for self-hosted Gitea runners, where a pull
|
per-branch Cargo build cache for self-hosted Gitea runners, where a pull
|
||||||
request's cache is a near-free hardlink clone of an immutable snapshot its
|
request's cache is a near-free hardlink clone of an immutable snapshot its
|
||||||
base branch published.
|
base branch published.
|
||||||
|
|||||||
@@ -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"
|
check "$scratch/two2.lock" >/dev/null 2>&1 && fail "two commits under different spellings passed"
|
||||||
ok "two commits fail across URL spellings too"
|
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 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 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"
|
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
|
#!/usr/bin/env bash
|
||||||
printf '%s\n' "$@" > "$STUB_DIR/git.argv"
|
printf '%s\n' "$@" > "$STUB_DIR/git.argv"
|
||||||
printf '%s\n' "${GIT_SSH_COMMAND:-}" > "$STUB_DIR/git.ssh"
|
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
|
[ -z "${STUB_GIT_ERR:-}" ] || echo "$STUB_GIT_ERR" >&2
|
||||||
exit "${STUB_GIT_RC:-0}"
|
exit "${STUB_GIT_RC:-0}"
|
||||||
STUB
|
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
|
for f in good.out good.env good.argv good.ssh; do
|
||||||
grep -qF "$secret_line" "$scratch/$f" && fail "key material leaked into $f"
|
grep -qF "$secret_line" "$scratch/$f" && fail "key material leaked into $f"
|
||||||
done
|
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"
|
[ "$(tail -c1 "$keyfile" | od -An -c | tr -d ' ')" = '\n' ] || fail "key file does not end in a newline"
|
||||||
if [ "$have_keygen" = 1 ]; then
|
if [ "$have_keygen" = 1 ]; then
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ known_hosts="$dir/known_hosts"
|
|||||||
# builtin, so the key is not in any process's argv.
|
# builtin, so the key is not in any process's argv.
|
||||||
( umask 077; printf '%s\n' "${DEPLOY_KEY%$'\n'}" | tr -d '\r' > "$key" )
|
( umask 077; printf '%s\n' "${DEPLOY_KEY%$'\n'}" | tr -d '\r' > "$key" )
|
||||||
chmod 600 "$key"
|
chmod 600 "$key"
|
||||||
|
# The children below (ssh-keygen, git, ssh, timeout) must not inherit the key.
|
||||||
|
unset DEPLOY_KEY
|
||||||
cp "$known_hosts_src" "$known_hosts"
|
cp "$known_hosts_src" "$known_hosts"
|
||||||
chmod 600 "$known_hosts"
|
chmod 600 "$known_hosts"
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,10 @@
|
|||||||
#
|
#
|
||||||
# Several packages from the one source share a commit, so what counts is
|
# Several packages from the one source share a commit, so what counts is
|
||||||
# distinct commits, not entries. The query string (`?branch=main`, `?rev=...`)
|
# distinct commits, not entries. The query string (`?branch=main`, `?rev=...`)
|
||||||
# is ignored, and so is the URL's spelling (scheme, port, `.git`): two copies
|
# is ignored, and so is the URL's spelling (scheme, port, `.git`, a trailing
|
||||||
# of the repo are two copies whichever way they were named. No entry passes.
|
# slash, case): two copies of the repo are two copies whichever way they were
|
||||||
|
# named. A look-alike owner or repo (`notdaniel/`, `gitdan-crates-extra`) is not
|
||||||
|
# this source. No entry passes.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
[ $# -eq 1 ] || { echo "::error::crates-lock-check: expected <path-to-Cargo.lock>" >&2; exit 1; }
|
[ $# -eq 1 ] || { echo "::error::crates-lock-check: expected <path-to-Cargo.lock>" >&2; exit 1; }
|
||||||
@@ -18,7 +20,7 @@ lock="$1"
|
|||||||
}
|
}
|
||||||
|
|
||||||
# source = "git+<url>[?query]#<sha>"
|
# source = "git+<url>[?query]#<sha>"
|
||||||
shas=$(sed -nE 's#^source = "git\+[^"?\#]*daniel/gitdan-crates(\.git)?(\?[^"\#]*)?\#([^"]*)"$#\3#p' "$lock" | sort -u)
|
shas=$(sed -nE 's#^source = "git\+[^"?\#]*[/:]daniel/gitdan-crates(\.git)?/?(\?[^"\#]*)?\#([^"]*)"$#\3#Ip' "$lock" | sort -u)
|
||||||
count=$(grep -c . <<<"$shas" || true)
|
count=$(grep -c . <<<"$shas" || true)
|
||||||
|
|
||||||
if [ "$count" -gt 1 ]; then
|
if [ "$count" -gt 1 ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user