Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Keep credentials out of cached directories, and audit the org against the miri cache disclosure

Daniel Han43e7dd302ee8
diff --git a/.github/workflows/docker-credential-probe.yml b/.github/workflows/docker-credential-probe.yml
index 36b259d066e..69536ed17b2 100644
--- a/.github/workflows/docker-credential-probe.yml
+++ b/.github/workflows/docker-credential-probe.yml
@@ -30,12 +30,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Report what will be attempted
+ # The key arrives as env rather than interpolated into the script below. An
+ # expanded ${{ secrets.* }} is written into the step's temporary shell script
+ # on the runner and, when it lands in a command line, into the process argv
+ # table, both readable by anything else on the machine. Actions masks it in
+ # the log, which is a different problem from where the value comes to rest.
+ env:
+ DOCKER_API_KEY: ${{ secrets.DOCKER_API_KEY }}
run: |
echo "registry: ${REGISTRY}"
echo "image: ${IMAGE_NAME}"
echo "username: ${REGISTRY_USERNAME}"
echo "tag: ${PROBE_TAG}"
- if [ -z "${{ secrets.DOCKER_API_KEY }}" ]; then
+ if [ -z "$DOCKER_API_KEY" ]; then
echo "::error::DOCKER_API_KEY is empty or not visible to this workflow."
exit 1
fi
@@ -81,10 +88,14 @@ jobs:
# success: the tag is verified gone, and the step fails if it is not.
- name: Delete the probe tag
if: always() && steps.push.outcome == 'success'
+ env:
+ DOCKER_API_KEY: ${{ secrets.DOCKER_API_KEY }}
run: |
- TOKEN="$(curl -s -X POST https://hub.docker.com/v2/auth/token \
- -H 'Content-Type: application/json' \
- -d "{\"identifier\": \"${REGISTRY_USERNAME}\", \"secret\": \"${{ secrets.DOCKER_API_KEY }}\"}" \
+ # The body is built from the environment and handed to curl on stdin, so the
+ # key is never a command-line argument.
+ TOKEN="$(python3 -c 'import json,os,sys; sys.stdout.write(json.dumps({"identifier": os.environ["REGISTRY_USERNAME"], "secret": os.environ["DOCKER_API_KEY"]}))' \
+ | curl -s -X POST https://hub.docker.com/v2/auth/token \
+ -H 'Content-Type: application/json' --data-binary @- \
| python3 -c 'import json,sys; print(json.load(sys.stdin).get("access_token",""))')"
if [ -z "$TOKEN" ]; then
echo "::error::Could not exchange DOCKER_API_KEY for a Hub API token at /v2/auth/token."
diff --git a/.github/workflows/docker-publish-rocm.yml b/.github/workflows/docker-publish-rocm.yml
index 5aebc536e31..0c684668b30 100644
--- a/.github/workflows/docker-publish-rocm.yml
+++ b/.github/workflows/docker-publish-rocm.yml
@@ -495,9 +495,11 @@ jobs:
README=docker/DOCKERHUB-ROCM.md
test -s "$README"
HUB="https://hub.docker.com/v2/namespaces/${IMAGE_NAME%%/*}/repositories/${IMAGE_NAME#*/}"
- TOKEN="$(curl -sS -X POST https://hub.docker.com/v2/auth/token \
- -H 'Content-Type: application/json' \
- -d "{\"identifier\": \"${{ env.REGISTRY_USERNAME }}\", \"secret\": \"${{ secrets.DOCKER_API_KEY }}\"}" \
+ # Body built from the environment and handed to curl on stdin, so the key is
+ # never a command-line argument.
+ TOKEN="$(python3 -c 'import json,os,sys; sys.stdout.write(json.dumps({"identifier": os.environ["REGISTRY_USERNAME"], "secret": os.environ["DOCKER_API_KEY"]}))' \
+ | curl -sS -X POST https://hub.docker.com/v2/auth/token \
+ -H 'Content-Type: application/json' --data-binary @- \
| python3 -c 'import json,sys; print(json.load(sys.stdin).get("access_token",""))')"
if [ -z "$TOKEN" ]; then
echo "::error::Could not exchange DOCKER_API_KEY for a Hub API token; the Hub page was not updated."
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
index c732cf9224c..30f7ef41c39 100644
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@ -620,6 +620,12 @@ jobs:
- uses: actions/checkout@v7
- name: Sync docker/DOCKERHUB.md to the Docker Hub page
+ # Key by env, not interpolated into the script: an expanded ${{ secrets.* }}
+ # is written into the step's temporary shell script on the runner and, in a
+ # command line, into the process argv table. Masking covers the log, not the
+ # places the value comes to rest.
+ env:
+ DOCKER_API_KEY: ${{ secrets.DOCKER_API_KEY }}
run: |
README=docker/DOCKERHUB.md
test -s "$README"
@@ -629,9 +635,11 @@ jobs:
# is not allowed", whatever its scopes. The token needs the repository
# edit permission on ${IMAGE_NAME}.
HUB="https://hub.docker.com/v2/namespaces/${IMAGE_NAME%%/*}/repositories/${IMAGE_NAME#*/}"
- TOKEN="$(curl -sS -X POST https://hub.docker.com/v2/auth/token \
- -H 'Content-Type: application/json' \
- -d "{\"identifier\": \"${{ env.REGISTRY_USERNAME }}\", \"secret\": \"${{ secrets.DOCKER_API_KEY }}\"}" \
+ # Body built from the environment and handed to curl on stdin, so the key is
+ # never a command-line argument.
+ TOKEN="$(python3 -c 'import json,os,sys; sys.stdout.write(json.dumps({"identifier": os.environ["REGISTRY_USERNAME"], "secret": os.environ["DOCKER_API_KEY"]}))' \
+ | curl -sS -X POST https://hub.docker.com/v2/auth/token \
+ -H 'Content-Type: application/json' --data-binary @- \
| python3 -c 'import json,sys; print(json.load(sys.stdin).get("access_token",""))')"
if [ -z "$TOKEN" ]; then
echo "::error::Could not exchange DOCKER_API_KEY for a Hub API token; the Hub page was not updated."
@@ -706,9 +714,11 @@ jobs:
NIGHTLY_KEEP_DAYS: "60"
run: |
HUB="https://hub.docker.com/v2/namespaces/${IMAGE_NAME%%/*}/repositories/${IMAGE_NAME#*/}"
- TOKEN="$(curl -sS -X POST https://hub.docker.com/v2/auth/token \
- -H 'Content-Type: application/json' \
- -d "{\"identifier\": \"${{ env.REGISTRY_USERNAME }}\", \"secret\": \"${{ secrets.DOCKER_API_KEY }}\"}" \
+ # Body built from the environment and handed to curl on stdin, so the key is
+ # never a command-line argument.
+ TOKEN="$(python3 -c 'import json,os,sys; sys.stdout.write(json.dumps({"identifier": os.environ["REGISTRY_USERNAME"], "secret": os.environ["DOCKER_API_KEY"]}))' \
+ | curl -sS -X POST https://hub.docker.com/v2/auth/token \
+ -H 'Content-Type: application/json' --data-binary @- \
| python3 -c 'import json,sys; print(json.load(sys.stdin).get("access_token",""))')"
if [ -z "$TOKEN" ]; then
echo "::error::Could not exchange DOCKER_API_KEY for a Hub API token; handle tags of run ${{ github.run_id }} were not removed."
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index 488d3c08ade..507c3893d6a 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -806,9 +806,33 @@ jobs:
with:
workspaces: 'studio/src-tauri -> target'
- # Windows release builds can spend many minutes uploading the target cache
- # after signed artifacts are ready, which blocks the publisher for no release benefit.
- save-if: ${{ matrix.platform != 'windows-latest' }}
+ # Restore only, on every platform. Windows already did not save, because a
+ # release build there can spend many minutes uploading the target cache after
+ # the signed artifacts are ready, blocking the publisher for no release
+ # benefit. The other legs now do not either, for a different reason.
+ #
+ # This job holds TAURI_SIGNING_PRIVATE_KEY, APPLE_ID, APPLE_PASSWORD,
+ # APPLE_CERTIFICATE, KEYCHAIN_PASSWORD and the AZURE_* signing credentials,
+ # and it was the only job in the organisation where a secret-bearing run wrote
+ # a cache that pull requests can read. GitHub makes caches written on the
+ # default branch restorable by every PR, so the blast radius of anything that
+ # serialised one of those values into studio/src-tauri/target would have been
+ # every contributor who can open one. That is the shape of the 2026-09-21
+ # cargo-miri disclosure, where miri wrote the whole environment under target/
+ # and CI cached it.
+ #
+ # Nothing here does that today, and it was checked rather than assumed: all
+ # 673 locked dependencies were audited from source, 20 build scripts declare
+ # cargo:rerun-if-env-changed, and the 27 variables they name include none of
+ # the above. See tests/studio/test_cached_paths_hold_no_credentials.py for the
+ # full result and the two runtime-constructed cases. But cargo writes the
+ # VALUE of any rerun-if-env-changed variable into
+ # target/<profile>/.fingerprint/*.json, which rust-cache preserves for
+ # dependencies, so that clean result is a property of 673 third-party build
+ # scripts rather than of anything in this repository, and it is re-decided by
+ # every `cargo update`. Restoring is free of that risk; saving is not worth it
+ # for a workflow_dispatch-only release that runs a handful of times a month.
+ save-if: false
# ── macOS: fail before the build if notarization cannot run ──
- name: Check Apple notarization credentials
diff --git a/.github/workflows/workflow-trigger-lint.yml b/.github/workflows/workflow-trigger-lint.yml
index 7b61a4f8eed..59d550184c9 100644
--- a/.github/workflows/workflow-trigger-lint.yml
+++ b/.github/workflows/workflow-trigger-lint.yml
@@ -134,6 +134,7 @@ jobs:
tests/studio/test_backend_ci_matrix.py \
tests/studio/test_backend_ci_parallel_isolation.py \
tests/studio/test_cache_budget_discipline.py \
+ tests/studio/test_cached_paths_hold_no_credentials.py \
tests/studio/test_local_actions_are_in_path_filters.py \
tests/studio/test_chat_ui_shards_cover_everything.py \
tests/studio/test_ui_shard_engines.py \
diff --git a/tests/security/test_release_desktop_integrity.py b/tests/security/test_release_desktop_integrity.py
index 287dabb6d3e..1a53eb1c4d3 100644
--- a/tests/security/test_release_desktop_integrity.py
+++ b/tests/security/test_release_desktop_integrity.py
@@ -39,10 +39,29 @@ def _step(workflow, job, name):
return _steps(workflow, job)[_step_index(workflow, job, name)]
-def test_windows_release_build_restores_but_does_not_save_rust_cache():
+def test_the_release_build_restores_but_never_saves_the_rust_cache():
+ """No platform may save, because this job holds the signing credentials.
+
+ Windows was already restore-only, to keep a long target-cache upload from blocking
+ the publisher once the signed artifacts were ready. Every leg is restore-only now
+ for a security reason instead: GitHub lets pull requests restore caches written on
+ the default branch, so this was the only job in the organisation where a run holding
+ TAURI_SIGNING_PRIVATE_KEY, APPLE_* and AZURE_* wrote a cache a contributor could
+ read. That is the 2026-09-21 cargo-miri shape, where miri serialised the whole
+ environment under target/ and CI cached it.
+
+ A `save-if` that names a platform is what this guards against: it reads as a
+ performance knob, and the next platform added inherits saving by default.
+ """
cache = _step(_workflow(), "build", "Rust cache")
assert cache["with"]["workspaces"] == "studio/src-tauri -> target"
- assert cache["with"]["save-if"] == "${{ matrix.platform != 'windows-latest' }}"
+ assert cache["with"]["save-if"] is False, (
+ f"the release build's rust-cache has save-if={cache['with']['save-if']!r}, so some "
+ f"platform writes a cache from the job that holds the signing credentials. Caches "
+ f"written on the default branch are restorable by every pull request. Keep this "
+ f"`save-if: false`; restoring is free of that risk, and a dispatch-only release "
+ f"does not run often enough for the save to be worth it."
+ )
def _write_fake_gh(path: Path):
diff --git a/tests/studio/test_cached_paths_hold_no_credentials.py b/tests/studio/test_cached_paths_hold_no_credentials.py
new file mode 100644
index 00000000000..69050533d0b
--- /dev/null
+++ b/tests/studio/test_cached_paths_hold_no_credentials.py
@@ -0,0 +1,285 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""No job may persist a directory that it has also configured a credential to live in.
+
+On 2026-09-21 the Rust project disclosed that `cargo miri` wrote the ENTIRE process
+environment to a file under `target/` (`cargo-miri/src/util.rs:40-42`), that CI cached
+`target/` with `actions/cache` or `Swatinem/rust-cache`, and that GitHub lets
+`pull_request` runs restore caches written on the default branch. A secret that had only
+ever existed in a privileged run therefore became readable by anyone who could open a
+pull request, and the exposure was invisible in the workflow YAML, because the leak
+happened inside a tool nobody had reason to distrust.
+
+The class needs four things at once: a secret in the job's environment, something that
+serialises it to disk, that path being persisted by a cache save or an artifact upload,
+and the result being readable from a pull request. This repository satisfies one, three
+and four in 24 jobs. What has kept it safe is the second link, and only the second link.
+
+That is worth stating precisely, because it is the part a future commit can undo without
+looking dangerous. There is no `miri` here. Secrets are step-scoped everywhere: a scan
+for a workflow- or job-level `env:` whose value is a `${{ secrets.* }}` expression
+returns nothing across all 57 workflows and 9 composite actions, no secret is ever
+written to `$GITHUB_ENV`, there is no `set -x` anywhere, and the only two `env` /
+`printenv` uses discard values through `cut -d= -f1`. Every upload names a narrow path
+rather than a tree.
+
+The one structural hole left is the shape this module pins. Eight workflows point
+`HF_HOME` at `${{ github.workspace }}/hf-cache` and then cache `hf-cache` itself
+(`studio-api-smoke.yml:114,154`, `studio-ui-smoke.yml:182,239`,
+`studio-mac-ui-smoke.yml:152,199`, `studio-windows-api-smoke.yml:103,129`,
+`studio-windows-ui-smoke.yml:113,152`, `studio-windows-inference-smoke.yml:411,1522`,
+`studio-inference-smoke.yml:269`, `local-agent-guides-ci.yml:783,823`), under a
+cross-OS key that carries no ref and is saved from main. `huggingface_hub` persists
+credentials INSIDE `HF_HOME` -- `$HF_HOME/token`, and `stored_tokens` in newer versions.
+So a single added `hf auth login` in one of those jobs would write a real token into a
+cache every pull request can restore, and nothing would flag it: the token is withheld on
+pull requests, which protects the PR run's own environment and does nothing about a value
+baked into main's cache. Cache scoping means the leak direction is main-writes /
+PR-reads, which is the opposite of the direction the rest of the tooling models.
+
+Nothing in the existing machinery can see this. `scripts/lint_workflow_triggers.py`
+compares cache keys as byte-identical strings and only models PR-poisons-publish; it
+never parses `path:`, and it globs only `.github/workflows`, so the keys that live in
+`.github/actions/*/action.yml` are outside it. `tests/studio/test_cache_budget_discipline.py`
+reasons only about which ref a save lands on. No test related a cached path to the
+secrets a job holds, which is why this file exists.
+
+One measured result recorded here because it is load-bearing elsewhere and expires.
+`release-desktop.yml` was the only job in the organisation where a secret-bearing run
+wrote a cache pull requests can read. Cargo serialises the VALUE of any
+`cargo:rerun-if-env-changed` variable into `target/<profile>/.fingerprint/*.json`, and
+rust-cache preserves dependency artifacts, so the question was whether any crate in the
+Tauri graph names a signing variable. On 2026-09-22 all 673 locked dependencies were
+audited from source: 671 crates.io tarballs, plus `unsloth-studio` itself (a three-line
+`build.rs` calling `tauri_build::build()`) and `fix-path-env`, a git dependency with no
+`build.rs` at all. Twenty build scripts declare `rerun-if-env-changed`, naming 27
+distinct variables, none of them a secret this CI holds. The two runtime-constructed
+cases both resolve safely: `ring`'s wrapper takes a `&'static str` and its only literals
+are `CARGO_MANIFEST_DIR` and `OUT_DIR`, and `aws-lc-rs` emits its interpolated form
+through `eprintln!`, i.e. on stderr, where cargo never reads it as a directive. So the
+finding was a risky configuration rather than a live leak, no rotation was warranted, and
+`release-desktop.yml` is now `save-if: false` anyway -- because that clean result is a
+property of 673 third-party build scripts, not of this repository, and every `cargo
+update` decides it again.
+"""
+
+import re
+from pathlib import Path
+
+import pytest
+import yaml
+
+REPO = Path(__file__).resolve().parents[2]
+WORKFLOWS = REPO / ".github" / "workflows"
+ACTIONS = REPO / ".github" / "actions"
+
+# Environment variables that designate a directory a tool will write credentials into.
+# The value is the credential-bearing file or subdirectory, for the message only; the
+# test cares that the variable's directory is inside something persisted.
+CREDENTIAL_HOMES = {
+ # huggingface_hub writes $HF_HOME/token and, since 0.25, $HF_HOME/stored_tokens.
+ "HF_HOME": "token, stored_tokens",
+ # Both are consulted before HF_HOME by older releases still pinned in some lanes.
+ "HUGGINGFACE_HUB_CACHE": "token",
+ "TRANSFORMERS_CACHE": "token",
+ # npm and cargo both keep registry credentials in their config roots.
+ "NPM_CONFIG_USERCONFIG": ".npmrc auth tokens",
+ "CARGO_HOME": "credentials.toml",
+ "DOCKER_CONFIG": "config.json auth entries",
+ "AWS_SHARED_CREDENTIALS_FILE": "aws credentials",
+ "GOOGLE_APPLICATION_CREDENTIALS": "service account json",
+}
+
+# Anything that makes a tool persist a credential into one of the directories above.
+# Matched against the shell body of every step, so a login added anywhere in a job that
+# caches its own credential home fails the guard.
+LOGIN_PATTERNS = (
+ r"\bhf\s+auth\s+login\b",
+ r"\bhuggingface-cli\s+login\b",
+ r"\bhf\s+login\b",
+ r"huggingface_hub[.\s]*\.?\s*login\s*\(",
+ r"\bfrom\s+huggingface_hub\s+import\s+[^\n]*\blogin\b",
+ r"\bHfFolder\b[^\n]*\bsave_token\b",
+ r"\bsave_token\s*\(",
+ r"add_to_git_credential\s*=\s*True",
+ r"\bnpm\s+login\b",
+ r"\bcargo\s+login\b",
+ r"\bdocker\s+login\b",
+ r"\bgcloud\s+auth\s+(?:application-default\s+)?login\b",
+ r"\baws\s+configure\b",
+)
+
+_CACHE_SAVE = ("actions/cache/save", "actions/cache@")
+_PERSIST = _CACHE_SAVE + ("actions/upload-artifact",)
+
+
+def _on(doc):
+ """The `on:` mapping, which PyYAML parses as the boolean True."""
+ return doc.get(True) if True in doc else doc.get("on")
+
+
+def _docs():
+ """Every workflow and composite action, parsed, with its path."""
+ for path in sorted(WORKFLOWS.glob("*.y*ml")):
+ try:
+ doc = yaml.safe_load(path.read_text(encoding = "utf-8"))
+ except yaml.YAMLError:
+ continue
+ if isinstance(doc, dict):
+ yield path, doc
+ for path in sorted(ACTIONS.rglob("action.y*ml")):
+ try:
+ doc = yaml.safe_load(path.read_text(encoding = "utf-8"))
+ except yaml.YAMLError:
+ continue
+ if isinstance(doc, dict):
+ yield path, doc
+
+
+def _jobs(doc):
+ jobs = doc.get("jobs")
+ if isinstance(jobs, dict):
+ for jid, job in jobs.items():
+ if isinstance(job, dict):
+ yield jid, job
+ # A composite action has one implicit job: its `runs.steps`.
+ runs = doc.get("runs")
+ if isinstance(runs, dict) and isinstance(runs.get("steps"), list):
+ yield "runs", {"steps": runs["steps"]}
+
+
+def _steps(job):
+ steps = job.get("steps")
+ return [s for s in steps if isinstance(s, dict)] if isinstance(steps, list) else []
+
+
+def _env_of(job, doc):
+ """Env visible to the job: workflow-level overlaid with job-level."""
+ env = {}
+ for source in (doc.get("env"), job.get("env")):
+ if isinstance(source, dict):
+ env.update({str(k): str(v) for k, v in source.items()})
+ return env
+
+
+def _persisted_paths(job):
+ """Every path this job writes to a cache or an artifact."""
+ out = []
+ for step in _steps(job):
+ uses = str(step.get("uses") or "").casefold()
+ if not any(marker.casefold() in uses for marker in _PERSIST):
+ continue
+ with_ = step.get("with")
+ if not isinstance(with_, dict):
+ continue
+ raw = with_.get("path")
+ if raw is None:
+ continue
+ for line in str(raw).splitlines():
+ line = line.strip()
+ if line and not line.startswith("!"):
+ out.append((line, step))
+ return out
+
+
+def _normalise(path: str) -> str:
+ """Strip expressions and separators so a path and an env value can be compared."""
+ path = re.sub(r"\$\{\{[^}]*\}\}", "", path)
+ path = path.replace("\\", "/").strip().strip("'\"")
+ while path.startswith("./"):
+ path = path[2:]
+ return path.strip("/")
+
+
+def _inside(inner: str, outer: str) -> bool:
+ """Is `inner` the same directory as `outer`, or below it?"""
+ inner, outer = _normalise(inner), _normalise(outer)
+ if not inner or not outer:
+ return False
+ return inner == outer or inner.startswith(outer + "/")
+
+
+def _offending_jobs():
+ """(label, var, path, home_value) for every job caching its own credential home."""
+ for path, doc in _docs():
+ for jid, job in _jobs(doc):
+ env = _env_of(job, doc)
+ homes = {v: env[v] for v in CREDENTIAL_HOMES if v in env}
+ if not homes:
+ continue
+ for persisted, _step in _persisted_paths(job):
+ for var, home in homes.items():
+ if _inside(home, persisted):
+ yield f"{path.name}:{jid}", var, persisted, home
+
+
+def test_the_scan_finds_the_jobs_it_claims_to():
+ """A scan that matched nothing would pass every check below on an empty set."""
+ found = {label for label, _, _, _ in _offending_jobs()}
+ assert len(found) >= 5, (
+ f"only found {len(found)} jobs that persist their own credential home; the scan is "
+ f"wrong. This is expected to be non-empty: pointing HF_HOME at a cached directory "
+ f"is deliberate here, and the point of this module is that a login must never be "
+ f"added to one of those jobs, not that the arrangement is forbidden."
+ )
+ names = {label.split(":")[0] for label in found}
+ for expected in ("studio-api-smoke.yml", "studio-windows-ui-smoke.yml"):
+ assert expected in names, f"{expected} caches its HF_HOME but the scan missed it"
+
+
+def test_the_inside_predicate_reads_the_path():
+ """The guard is only as good as this predicate, so the predicate is tested too."""
+ cases = [
+ # (home, persisted, inside)
+ ("hf-cache", "hf-cache", True),
+ ("${{ github.workspace }}/hf-cache", "hf-cache", True),
+ ("hf-cache/hub", "hf-cache", True), # credential home below the cached dir
+ ("./hf-cache", "hf-cache", True),
+ ("hf-cache-vision", "hf-cache", False), # prefix, not a child
+ ("other", "hf-cache", False),
+ ("hf-cache", "hf-cache/hub", False), # cached dir below the home, not covered
+ ("", "hf-cache", False),
+ ("hf-cache", "", False),
+ (r"${{ github.workspace }}\hf-cache", "hf-cache", True), # Windows separators
+ ]
+ for home, persisted, expected in cases:
+ assert _inside(home, persisted) is expected, f"_inside({home!r}, {persisted!r})"
+
+
+ "label,var,persisted,home",
+ sorted(_offending_jobs()),
+ ids = lambda v: str(v).replace("/", "_") if isinstance(v, str) else str(v),
+)
+def test_a_job_that_caches_its_credential_home_performs_no_login(label, var, persisted, home):
+ name, jid = label.split(":", 1)
+ path = WORKFLOWS / name
+ if not path.exists():
+ candidates = list(ACTIONS.rglob(name))
+ path = candidates[0] if candidates else path
+ doc = yaml.safe_load(path.read_text(encoding = "utf-8"))
+ job = dict(_jobs(doc)).get(jid) or {}
+
+ offenders = []
+ for step in _steps(job):
+ body = str(step.get("run") or "")
+ if not body:
+ continue
+ for pattern in LOGIN_PATTERNS:
+ if re.search(pattern, body, re.IGNORECASE):
+ offenders.append(f"{step.get('name') or step.get('uses')}: matched /{pattern}/")
+
+ assert not offenders, (
+ f"{label} sets {var}={home}, which is inside the persisted path {persisted!r}, and a "
+ f"step in it logs in:\n " + "\n ".join(offenders) + "\n\n"
+ f"{var} is where the tool keeps its credentials ({CREDENTIAL_HOMES[var]}), so a login "
+ f"writes a real token into that directory, and the directory is then saved to a cache "
+ f"or uploaded as an artifact. GitHub lets every pull request restore caches written on "
+ f"the default branch, so the token would be readable by anyone who can open one. "
+ f"Withholding the secret on pull requests does not help: it protects the PR run's own "
+ f"environment, not a value already baked into main's cache.\n\n"
+ f"Read the token from the environment instead of logging in, which is what this repo "
+ f"does today ({var} is set for the download path and no step authenticates), or point "
+ f"{var} somewhere outside the persisted path."
+ )