~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
ci(gitleaks): de-duplicate the pinned install into one shared composite action (#6807)
LearningCircuite68a7811cf25
diff --git a/.github/actions/install-gitleaks/action.yml b/.github/actions/install-gitleaks/action.ymlnew file mode 100644index 0000000000..4569a2eab6--- /dev/null+++ b/.github/actions/install-gitleaks/action.yml@@ -0,0 +1,61 @@+name: Install pinned Gitleaks+description: >-+ Checksum-verified install of the pinned Gitleaks release. Single source+ of truth for the version + SHA256 pair among the CI workflows (#6686):+ workflows must use this action instead of inlining the archive URL and+ checksum, so every CI scanning lane bumps in lockstep. The pre-commit+ gitleaks hook pins its own copy of the version separately+ (.pre-commit-config.yaml); tests/ci/test_gitleaks_install_single_source.py+ fails a bump that moves one without the other.++inputs:+ install-dir:+ description: >-+ Directory to place the gitleaks binary in. Defaults to a runner-temp+ dir added to PATH. Pass a workspace path when the binary must stay+ visible to a docker run that mounts the workspace (e.g.+ docker-tests.yml).+ required: false+ default: ""++outputs:+ bin-dir:+ description: Directory containing the gitleaks binary.+ value: ${{ steps.resolve.outputs.bin-dir }}++runs:+ using: composite+ steps:+ - id: resolve+ shell: bash+ env:+ INSTALL_DIR: ${{ inputs.install-dir }}+ run: |+ if [ -n "${INSTALL_DIR}" ]; then+ BIN_DIR="${INSTALL_DIR}"+ else+ BIN_DIR="${RUNNER_TEMP}/gitleaks-bin"+ fi+ mkdir -p "${BIN_DIR}"+ echo "bin-dir=${BIN_DIR}" >> "${GITHUB_OUTPUT}"++ - name: Download and verify pinned Gitleaks+ shell: bash+ env:+ # Update this from the release checksums file when changing Gitleaks.+ # This is the only copy of the version + checksum pair among the CI+ # workflows; .pre-commit-config.yaml pins its own copy of the version+ # separately and must be bumped in lockstep (enforced by+ # tests/ci/test_gitleaks_install_single_source.py).+ GITLEAKS_SHA256: 79a3ab579b53f71efd634f3aaf7e04a0fa0cf206b7ed434638d1547a2470a66e+ GITLEAKS_BIN_DIR: ${{ steps.resolve.outputs.bin-dir }}+ run: |+ GITLEAKS_ARCHIVE="${RUNNER_TEMP}/gitleaks_8.30.0_linux_x64.tar.gz"+ curl -sSfL --retry 3 --retry-all-errors \+ --connect-timeout 10 --max-time 120 \+ --output "${GITLEAKS_ARCHIVE}" \+ https://github.com/gitleaks/gitleaks/releases/download/v8.30.0/gitleaks_8.30.0_linux_x64.tar.gz+ echo "${GITLEAKS_SHA256} ${GITLEAKS_ARCHIVE}" | sha256sum --check --strict+ tar -xzf "${GITLEAKS_ARCHIVE}" -C "${GITLEAKS_BIN_DIR}" gitleaks+ chmod +x "${GITLEAKS_BIN_DIR}/gitleaks"+ echo "${GITLEAKS_BIN_DIR}" >> "${GITHUB_PATH}"diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.ymlindex fdccc246cf..09f591d086 100644--- a/.github/workflows/docker-tests.yml+++ b/.github/workflows/docker-tests.yml@@ -226,20 +226,12 @@ jobs:# the required "All Pytest Tests + Coverage" check, so installing the# binary here — into the workspace, which is mounted at /app — makes# the regressions load-bearing for merge: with REQUIRE_GITLEAKS=1 a- # missing binary fails the test instead of skipping it.- env:- # Keep this in sync with gitleaks-rule-tests.yml and gitleaks.yml.- GITLEAKS_SHA256: 79a3ab579b53f71efd634f3aaf7e04a0fa0cf206b7ed434638d1547a2470a66e- run: |- GITLEAKS_ARCHIVE="${RUNNER_TEMP}/gitleaks_8.30.0_linux_x64.tar.gz"- curl -sSfL --retry 3 --retry-all-errors \- --connect-timeout 10 --max-time 120 \- --output "${GITLEAKS_ARCHIVE}" \- https://github.com/gitleaks/gitleaks/releases/download/v8.30.0/gitleaks_8.30.0_linux_x64.tar.gz- echo "${GITLEAKS_SHA256} ${GITLEAKS_ARCHIVE}" | sha256sum --check --strict- mkdir -p "${PWD}/.ci-gitleaks-bin"- tar -xzf "${GITLEAKS_ARCHIVE}" -C "${PWD}/.ci-gitleaks-bin" gitleaks- chmod +x "${PWD}/.ci-gitleaks-bin/gitleaks"+ # missing binary fails the test instead of skipping it. The version ++ # checksum pair lives in the shared action (#6686); install-dir keeps+ # the binary inside the mounted workspace.+ uses: $/.github/actions/install-gitleaks+ with:+ install-dir: ${{ github.workspace }}/.ci-gitleaks-bin- name: Run all pytest tests with coverageid: main_pytestdiff --git a/.github/workflows/gitleaks-main.yml b/.github/workflows/gitleaks-main.ymlindex 8bd8f80410..06ea6b7729 100644--- a/.github/workflows/gitleaks-main.yml+++ b/.github/workflows/gitleaks-main.yml@@ -33,20 +33,7 @@ jobs:ref: main # Always checkout main branch- name: Install Gitleaks- env:- # Update this from the release checksums file when changing Gitleaks.- GITLEAKS_SHA256: 79a3ab579b53f71efd634f3aaf7e04a0fa0cf206b7ed434638d1547a2470a66e- run: |- GITLEAKS_ARCHIVE="${RUNNER_TEMP}/gitleaks_8.30.0_linux_x64.tar.gz"- GITLEAKS_BIN_DIR="${RUNNER_TEMP}/gitleaks-bin"- curl -sSfL --retry 3 --retry-all-errors \- --connect-timeout 10 --max-time 120 \- --output "${GITLEAKS_ARCHIVE}" \- https://github.com/gitleaks/gitleaks/releases/download/v8.30.0/gitleaks_8.30.0_linux_x64.tar.gz- echo "${GITLEAKS_SHA256} ${GITLEAKS_ARCHIVE}" | sha256sum --check --strict- mkdir -p "${GITLEAKS_BIN_DIR}"- tar -xzf "${GITLEAKS_ARCHIVE}" -C "${GITLEAKS_BIN_DIR}" gitleaks- echo "${GITLEAKS_BIN_DIR}" >> "${GITHUB_PATH}"+ uses: $/.github/actions/install-gitleaks- name: Run Gitleaks on main branch onlyrun: |diff --git a/.github/workflows/gitleaks-rule-tests.yml b/.github/workflows/gitleaks-rule-tests.ymlindex 601c7ee67f..b61c54dd80 100644--- a/.github/workflows/gitleaks-rule-tests.yml+++ b/.github/workflows/gitleaks-rule-tests.yml@@ -9,6 +9,7 @@ on:- .gitleaks.toml- tests/security/test_gitleaks_*.py- .github/workflows/gitleaks-rule-tests.yml+ - .github/actions/install-gitleaks/**push:branches:- main@@ -17,6 +18,7 @@ on:- .gitleaks.toml- tests/security/test_gitleaks_*.py- .github/workflows/gitleaks-rule-tests.yml+ - .github/actions/install-gitleaks/**workflow_dispatch:permissions:@@ -50,27 +52,14 @@ jobs:- name: Install focused test dependencyrun: python -m pip install pytest==9.1.1- - name: Install Gitleaks 8.30.0- env:- # Keep this in sync with the repository's Gitleaks scan workflows.- GITLEAKS_SHA256: 79a3ab579b53f71efd634f3aaf7e04a0fa0cf206b7ed434638d1547a2470a66e- run: |- GITLEAKS_ARCHIVE="${RUNNER_TEMP}/gitleaks_8.30.0_linux_x64.tar.gz"- GITLEAKS_BIN_DIR="${RUNNER_TEMP}/gitleaks-bin"- curl -sSfL --retry 3 --retry-all-errors \- --connect-timeout 10 --max-time 120 \- --output "${GITLEAKS_ARCHIVE}" \- https://github.com/gitleaks/gitleaks/releases/download/v8.30.0/gitleaks_8.30.0_linux_x64.tar.gz- echo "${GITLEAKS_SHA256} ${GITLEAKS_ARCHIVE}" | sha256sum --check --strict- mkdir -p "${GITLEAKS_BIN_DIR}"- tar -xzf "${GITLEAKS_ARCHIVE}" -C "${GITLEAKS_BIN_DIR}" gitleaks- echo "${GITLEAKS_BIN_DIR}" >> "${GITHUB_PATH}"+ - name: Install Gitleaks+ uses: $/.github/actions/install-gitleaks- name: Run real-engine rule regressionsenv:PYTEST_DISABLE_PLUGIN_AUTOLOAD: "1"REQUIRE_GITLEAKS: "1"run: |- python -m pytest --confcutdir=tests/security -q \+ python -m pytest --noconftest --confcutdir=tests/security -q \tests/security/test_gitleaks_brave_rule.py \tests/security/test_gitleaks_credential_rule.pydiff --git a/.github/workflows/gitleaks.yml b/.github/workflows/gitleaks.ymlindex d30a6864c8..8636f27c6f 100644--- a/.github/workflows/gitleaks.yml+++ b/.github/workflows/gitleaks.yml@@ -38,20 +38,7 @@ jobs:fetch-depth: 0 # Fetch full history for comprehensive secret scanning- name: Install Gitleaks- env:- # Update this from the release checksums file when changing Gitleaks.- GITLEAKS_SHA256: 79a3ab579b53f71efd634f3aaf7e04a0fa0cf206b7ed434638d1547a2470a66e- run: |- GITLEAKS_ARCHIVE="${RUNNER_TEMP}/gitleaks_8.30.0_linux_x64.tar.gz"- GITLEAKS_BIN_DIR="${RUNNER_TEMP}/gitleaks-bin"- curl -sSfL --retry 3 --retry-all-errors \- --connect-timeout 10 --max-time 120 \- --output "${GITLEAKS_ARCHIVE}" \- https://github.com/gitleaks/gitleaks/releases/download/v8.30.0/gitleaks_8.30.0_linux_x64.tar.gz- echo "${GITLEAKS_SHA256} ${GITLEAKS_ARCHIVE}" | sha256sum --check --strict- mkdir -p "${GITLEAKS_BIN_DIR}"- tar -xzf "${GITLEAKS_ARCHIVE}" -C "${GITLEAKS_BIN_DIR}" gitleaks- echo "${GITLEAKS_BIN_DIR}" >> "${GITHUB_PATH}"+ uses: $/.github/actions/install-gitleaks- name: Run Gitleaks Secret Scannerid: gitleaksdiff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex e7c107f9f2..2bf705c9cd 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -85,8 +85,9 @@ repos:name: Lint GitHub Actions workflowsdescription: "Static checker for GitHub Actions workflow files"files: ^\.github/workflows/.*\.ya?ml$- # The pinned actionlint predates `$/`. Normalize workflow-call refs- # in stdin so its input, secret, output and callee checks still run.+ # The pinned actionlint predates `$/`. Normalize workflow-call and+ # step-level local action refs in stdin so its input, secret, output+ # and callee checks still run.# Keep the original filename for local metadata lookup/diagnostics.# Remove the adapter once actionlint supports self-repository refs.entry: python3 .pre-commit-hooks/actionlint-self-repository.pydiff --git a/.pre-commit-hooks/actionlint-self-repository.py b/.pre-commit-hooks/actionlint-self-repository.pyindex c128577645..d77c411ef3 100644--- a/.pre-commit-hooks/actionlint-self-repository.py+++ b/.pre-commit-hooks/actionlint-self-repository.py@@ -1,9 +1,10 @@#!/usr/bin/env python3"""Validate self-repository workflow calls with the pinned actionlint.-Until actionlint understands `$/`, normalize job-level call references to-`./` in stdin only. Keeping the original filename lets actionlint load the-callee's inputs, secrets and outputs from the repository. No diagnostics+Until actionlint understands `$/`, normalize job-level call references and+step-level local action references to `./` in stdin only. Keeping the+original filename lets actionlint load the callee's inputs, secrets and+outputs, and the local action's inputs, from the repository. No diagnosticsare suppressed and no workflow files are rewritten."""@@ -14,7 +15,7 @@ import sysfrom pathlib import Pathimport yaml-from yaml.nodes import MappingNode, ScalarNode+from yaml.nodes import MappingNode, ScalarNode, SequenceNodefrom yaml.tokens import ScalarToken@@ -26,14 +27,19 @@ def mapping_values(node, key):def normalize_workflow_calls(source: str) -> str:- """Rewrite only job-level uses scalars, retaining diagnostic line numbers."""+ """Rewrite only job- and step-level uses scalars, retaining line numbers."""document = yaml.compose(source, Loader=yaml.SafeLoader)ends = set()for jobs in mapping_values(document, "jobs"):if not isinstance(jobs, MappingNode):continuefor _, job in jobs.value:- for uses in mapping_values(job, "uses"):+ uses_nodes = list(mapping_values(job, "uses"))+ for steps in mapping_values(job, "steps"):+ if isinstance(steps, SequenceNode):+ for step in steps.value:+ uses_nodes.extend(mapping_values(step, "uses"))+ for uses in uses_nodes:if isinstance(uses, ScalarNode) and uses.value.startswith("$/"):ends.add(uses.end_mark.index)diff --git a/tests/ci/test_gitleaks_install_single_source.py b/tests/ci/test_gitleaks_install_single_source.pynew file mode 100644index 0000000000..fdbda0e017--- /dev/null+++ b/tests/ci/test_gitleaks_install_single_source.py@@ -0,0 +1,300 @@+"""Drift guard: the pinned Gitleaks install has exactly one source (#6686).++The version + SHA256 pair for the checksum-verified Gitleaks install used+to be copy-pasted into four workflows, so a partial version bump left+lanes scanning with different binaries while every per-file checksum still+passed. The pair now lives only in+``.github/actions/install-gitleaks/action.yml``; every workflow that needs+the binary must use that action, and a literal inline copy must not+reappear -- in a ``.yml`` or ``.yaml`` workflow, or in any other composite+action under ``.github/actions``.++The action also verifies the archive's checksum before extracting it; that+ordering is load-bearing (a corrupted or substituted archive must never be+unpacked) and is pinned here too.++The pinned version is derived from the release download URL, not from the+archive filename: the archive filename also names the *local* download+path, so a partial bump that moves the URL but not the local filename (or+vice versa) is itself checked for and failed here.++A workflow or action file re-adopting a different, unpinned Gitleaks+distribution channel -- a Docker Hub image, the third-party+"gitleaks-action", or the "gitleaks/v8@" marketplace action -- is flagged+too, even though none of those routes literally copies the version or+checksum.++Separately, ``.pre-commit-config.yaml`` pins its own copy of the Gitleaks+*version* for the pre-commit mirror hook (it runs the ``gitleaks``+pre-commit hook, not this action, so it cannot literally share the pin).+That second copy must move in lockstep with the action's version, with its+version comment on the same line as `rev:`; this file pins that too (see+the lockstep test's docstring for what it cannot verify).+"""++import re+from pathlib import Path++REPO_ROOT = Path(__file__).resolve().parents[2]+WORKFLOWS_DIR = REPO_ROOT / ".github" / "workflows"+ACTIONS_DIR = REPO_ROOT / ".github" / "actions"+SHARED_ACTION_DIR = ACTIONS_DIR / "install-gitleaks"+SHARED_ACTION = SHARED_ACTION_DIR / "action.yml"+SHARED_ACTION_REF = "$/.github/actions/install-gitleaks"+PRE_COMMIT_CONFIG = REPO_ROOT / ".pre-commit-config.yaml"++#: Workflows that need the gitleaks binary installed.+INSTALLER_WORKFLOWS = (+ "gitleaks.yml",+ "gitleaks-main.yml",+ "gitleaks-rule-tests.yml",+ "docker-tests.yml",+)++#: Matches the release download URL, e.g.+#: "releases/download/v8.30.0/gitleaks_8.30.0_linux_x64.tar.gz", and+#: captures the version so it never needs to be hard-coded here. The+#: version is derived from the URL, not from the archive filename: the+#: archive filename is also used for the *local* download path+#: (``GITLEAKS_ARCHIVE=...``), which a partial version bump could leave+#: stale while the URL moves on -- and a ``.search()`` against the archive+#: filename alone would silently pick up that stale local copy, since it+#: appears first in the file.+RELEASE_URL_VERSION_RE = re.compile(r"releases/download/v(\d+\.\d+\.\d+)/")++#: Matches every mention of the pinned archive filename, e.g.+#: "gitleaks_8.30.0_linux_x64.tar.gz", wherever it appears -- the local+#: download path as well as the release URL -- so all copies can be+#: checked against the release-URL-derived version.+ARCHIVE_NAME_RE = re.compile(r"gitleaks_(\d+\.\d+\.\d+)_linux")++#: Matches a step `name:` that still copies the version, e.g. "Download+#: and verify pinned Gitleaks 8.30.0". The shared action no longer names+#: one (fewer copies to drift); this guards against one creeping back in+#: with a stale version.+STEP_NAME_VERSION_RE = re.compile(r"name:.*Gitleaks\s+(\d+\.\d+\.\d+)")++#: Marker of the release download URL; inline re-hosting of the archive+#: URL is as much a drift risk as the checksum, even under a fresh var name.+GITLEAKS_URL_MARKER = "gitleaks/releases/download"++#: Alternate, unpinned ways of getting Gitleaks onto a runner: the Docker+#: Hub image (``docker run zricethezav/gitleaks:...``), the third-party+#: "gitleaks-action" marketplace action, and the "gitleaks/v8@..." OSS+#: marketplace action. Any of these bypasses the checksum-verified,+#: single-source install in the shared action just as much as an inline+#: URL would. Confirmed absent from the repo (`git grep` across+#: .github and .pre-commit-config.yaml) before this guard was added.+OTHER_INSTALL_ROUTE_RE = re.compile(+ r"zricethezav/gitleaks|gitleaks/gitleaks-action|gitleaks/v8@"+)++SHA256SUM_CHECK_RE = re.compile(r"sha256sum\s+(?:--check\b|-c\b)")++#: The gitleaks pre-commit hook's rev line, e.g.:+#: - repo: https://github.com/gitleaks/gitleaks+#: rev: 2ca41cc... # v8.30.0 (frozen)+#: The comment must be on the SAME line as `rev:` -- deliberately, so this+#: can't match a `# vX.Y.Z` comment that drifted onto an unrelated line.+PRE_COMMIT_GITLEAKS_REV_RE = re.compile(+ r"repo:[ \t]*https://github\.com/gitleaks/gitleaks[ \t]*\n"+ r"[ \t]*rev:[ \t]*\S+[ \t]*#[ \t]*v(\d+\.\d+\.\d+)"+)+++def _action_source() -> str:+ assert SHARED_ACTION.is_file(), (+ f"missing {SHARED_ACTION} — the pinned Gitleaks install has no "+ "single source of truth"+ )+ return SHARED_ACTION.read_text(encoding="utf-8")+++def _action_version() -> str:+ """The pinned version, derived from the release download URL (never+ hard-coded here, and never derived from the archive filename -- see+ RELEASE_URL_VERSION_RE)."""+ src = _action_source()+ match = RELEASE_URL_VERSION_RE.search(src)+ assert match, (+ "could not derive the pinned Gitleaks version from the release "+ f"download URL in {SHARED_ACTION} — expected "+ "'releases/download/vX.Y.Z/'"+ )+ return match.group(1)+++def _strip_comments(src: str) -> str:+ """Drop the part of every line from the first '#' onward.++ Good enough for these YAML/shell files: none of the lines this module+ inspects for content use '#' inside a quoted value.+ """+ return "\n".join(line.split("#", 1)[0] for line in src.splitlines())+++def _scan_targets():+ """Every workflow and composite-action file that could re-inline the+ pin, excluding the shared install action itself."""+ targets = []+ for pattern in ("*.yml", "*.yaml"):+ targets.extend(sorted(WORKFLOWS_DIR.glob(pattern)))+ for path in sorted(ACTIONS_DIR.rglob("*")):+ if not path.is_file():+ continue+ if path.is_relative_to(SHARED_ACTION_DIR):+ continue+ targets.append(path)+ return targets+++def test_the_shared_action_is_the_single_pinned_source():+ """The version + checksum pair exists exactly once: the shared action."""+ src = _action_source()+ version = _action_version()+ assert version in src, "the shared action no longer names a version"+ assert "GITLEAKS_SHA256" in src, (+ "the shared action no longer verifies a SHA256 checksum"+ )+ assert GITLEAKS_URL_MARKER in src, (+ "the shared action no longer downloads from a gitleaks release"+ )+++def test_every_archive_name_mention_matches_the_release_url_version():+ """Every "gitleaks_X.Y.Z_linux..." mention in the shared action --+ the local download path as well as the release URL -- must agree with+ the release-URL-derived version. Catches a partial bump that moves+ the URL but leaves the local archive filename (or vice versa) stale;+ ``test_the_shared_action_is_the_single_pinned_source`` alone would+ miss that, since the stale copy still contains *some* version."""+ src = _action_source()+ version = _action_version()+ mentions = set(ARCHIVE_NAME_RE.findall(src))+ assert mentions, (+ f"no 'gitleaks_X.Y.Z_linux' mention found in {SHARED_ACTION}"+ )+ assert mentions == {version}, (+ f"archive-name mention(s) {sorted(mentions)} disagree with the "+ f"release-URL-derived version {version!r} in {SHARED_ACTION} — "+ "a partial version bump left one copy stale"+ )+++def test_no_stale_gitleaks_version_in_a_step_name():+ """If a step `name:` names a Gitleaks version at all, it must agree+ with the release-URL-derived version -- a third copy of the pin that+ could otherwise drift silently."""+ src = _action_source()+ version = _action_version()+ mentions = set(STEP_NAME_VERSION_RE.findall(src))+ assert mentions <= {version}, (+ f"step-name version mention(s) {sorted(mentions)} disagree with "+ f"the release-URL-derived version {version!r} — drop the version "+ "from the step name, or bump it in lockstep (#6686)"+ )+++def test_the_action_verifies_checksum_before_extracting():+ """A corrupted/substituted archive must never reach `tar -x`."""+ src = _action_source()+ check_match = SHA256SUM_CHECK_RE.search(src)+ assert check_match, (+ "the shared action no longer runs `sha256sum --check` (or `-c`) "+ "against the pinned checksum"+ )+ extract_index = src.find("tar -xzf")+ assert extract_index != -1, (+ "the shared action no longer extracts the downloaded archive"+ )+ assert check_match.start() < extract_index, (+ "the checksum must be verified BEFORE the archive is extracted, "+ "not after"+ )+++def test_every_installer_workflow_uses_the_shared_action():+ for name in INSTALLER_WORKFLOWS:+ path = WORKFLOWS_DIR / name+ assert path.is_file(), f"expected workflow {name} not found"+ src = _strip_comments(path.read_text(encoding="utf-8"))+ assert SHARED_ACTION_REF in src, (+ f"{name} does not use {SHARED_ACTION_REF} in a live (non-comment) "+ "line — it either installs gitleaks inline (detection drift "+ "risk, #6686) or the `uses:` line is commented out"+ )+++def test_no_inline_pinned_gitleaks_install_reappears():+ """The version/SHA/URL must not be pasted back into any other file.++ Scans every workflow (.yml and .yaml) and every file under+ .github/actions, except the shared action itself, for the release URL,+ the checksum env var name, or the pinned archive filename -- even+ under a different variable name than GITLEAKS_SHA256.+ """+ version = _action_version()+ archive_marker = f"gitleaks_{version}_linux"+ markers = ("GITLEAKS_SHA256", archive_marker, GITLEAKS_URL_MARKER)++ offenders = []+ for path in _scan_targets():+ src = path.read_text(encoding="utf-8")+ hit = next((marker for marker in markers if marker in src), None)+ if hit is not None:+ offenders.append((str(path.relative_to(REPO_ROOT)), hit))+ assert offenders == [], (+ f"inline pinned Gitleaks install found: {offenders}: the version + "+ "SHA256/URL belongs only in "+ ".github/actions/install-gitleaks/action.yml (#6686)"+ )+++def test_no_other_gitleaks_install_route_reappears():+ """No workflow or action file adopts a different Gitleaks distribution+ channel -- the Docker Hub image, the third-party "gitleaks-action", or+ the "gitleaks/v8@" marketplace action -- that would install or run+ Gitleaks outside the pinned, checksum-verified path in the shared+ action (a drift risk this guard cannot otherwise see, since none of+ those routes ever names the pinned version or checksum)."""+ offenders = []+ for path in _scan_targets():+ src = path.read_text(encoding="utf-8")+ match = OTHER_INSTALL_ROUTE_RE.search(src)+ if match is not None:+ offenders.append((str(path.relative_to(REPO_ROOT)), match.group(0)))+ assert offenders == [], (+ f"alternate Gitleaks install route found: {offenders} — use "+ f"{SHARED_ACTION_REF} instead of a separate distribution channel "+ "(#6686)"+ )+++def test_precommit_gitleaks_pin_matches_the_shared_action_version():+ """.pre-commit-config.yaml pins gitleaks separately; it must track the+ shared action's version, or the two scanning lanes drift again.++ Limitation: this only checks the human-authored `# vX.Y.Z` comment+ against the action's version, and requires that comment to sit on the+ same source line as `rev:` (so it can't drift onto an unrelated line+ and still pass). It cannot independently verify that the pinned `rev:`+ commit SHA actually corresponds to that tag -- pre-commit pins a+ frozen commit SHA precisely so the hook resolves offline, and+ resolving a tag to a commit requires network access this test does+ not have. A comment edited to a false version without updating the+ SHA would defeat this check.+ """+ assert PRE_COMMIT_CONFIG.is_file(), f"missing {PRE_COMMIT_CONFIG}"+ action_version = _action_version()+ src = PRE_COMMIT_CONFIG.read_text(encoding="utf-8")+ match = PRE_COMMIT_GITLEAKS_REV_RE.search(src)+ assert match, (+ "could not find the gitleaks hook's pinned `rev: <sha> # vX.Y.Z` "+ f"comment (same line) in {PRE_COMMIT_CONFIG}"+ )+ precommit_version = match.group(1)+ assert precommit_version == action_version, (+ f".pre-commit-config.yaml pins gitleaks v{precommit_version} but "+ f".github/actions/install-gitleaks/action.yml pins v{action_version} "+ "— bump both together (#6686)"+ )diff --git a/tests/hooks/test_actionlint_self_repository.py b/tests/hooks/test_actionlint_self_repository.pyindex de1bfd1f1a..e88f9e1823 100644--- a/tests/hooks/test_actionlint_self_repository.py+++ b/tests/hooks/test_actionlint_self_repository.py@@ -61,6 +61,33 @@ jobs:- run: echo "$RESULT""""+LOCAL_ACTION = """\+name: greet+description: Greet someone+inputs:+ name:+ description: Who to greet+ required: true+runs:+ using: composite+ steps:+ - run: echo "hello $NAME"+ shell: bash+ env:+ NAME: ${{ inputs.name }}+"""++STEP_CALLER = """\+on: workflow_dispatch+jobs:+ greet:+ runs-on: ubuntu-latest+ steps:+ - uses: $/.github/actions/greet+ with:+ name: example+"""+@unittest.skipUnless(shutil.which("actionlint"), "actionlint is not installed")class TestActionlintSelfRepository(unittest.TestCase):@@ -105,6 +132,23 @@ class TestActionlintSelfRepository(unittest.TestCase):result = self.lint()self.assertEqual(result.returncode, 0, result.stdout + result.stderr)+ def write_local_action(self):+ action = self.root / ".github" / "actions" / "greet"+ action.mkdir(parents=True)+ (action / "action.yml").write_text(LOCAL_ACTION, encoding="utf-8")++ def test_valid_self_repository_step_action(self):+ self.write_local_action()+ result = self.lint(STEP_CALLER)+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)++ def test_step_action_unknown_input_is_rejected(self):+ self.write_local_action()+ self.assert_rejected(+ STEP_CALLER.replace("name: example", "nickname: example"),+ 'input "nickname" is not defined',+ )+def test_legacy_call_remains_valid(self):result = self.lint(CALLER.replace("uses: $/", "uses: ./"))self.assertEqual(result.returncode, 0, result.stdout + result.stderr)