Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ jobs:
- name: Verify full Git checkout
run: |
test -d .git
test "$(git rev-list --count HEAD)" -gt 0
test "$(git rev-parse --is-shallow-repository)" = "false"
git rev-parse --verify "HEAD^{commit}" >/dev/null
- name: Scan Git history
# Mirror the v8.30.0 Git log defaults except --all -> HEAD; re-derive
# these options when bumping the image. This excludes unrelated refs.
run: >-
docker run --rm
--volume "$PWD:/repo:ro"
ghcr.io/gitleaks/gitleaks:v8.30.0@sha256:691af3c7c5a48b16f187ce3446d5f194838f91238f27270ed36eef6359a574d9
git --no-banner --redact --verbose /repo
git --no-banner --redact --verbose
--log-opts="--full-history --diff-filter=tuxdb HEAD --" /repo
Comment thread
chrisknvidia marked this conversation as resolved.
Resolved

dependency-review:
name: Dependency review
Expand Down
21 changes: 21 additions & 0 deletions tests/test_ci_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,27 @@ def test_security_keeps_gitleaks_always_on_and_skips_only_nonessential_jobs() ->
assert "vars.ENABLE_GITHUB_ADVANCED_SECURITY == 'true'" in codeql_if


def test_gitleaks_scans_full_history_reachable_from_checked_out_head() -> None:
job = _load("security.yml")["jobs"]["gitleaks"]
checkout = next(
step for step in job["steps"] if step.get("uses", "").startswith("actions/checkout@")
)
verify = next(step for step in job["steps"] if step.get("name") == "Verify full Git checkout")
scan = next(step for step in job["steps"] if step.get("name") == "Scan Git history")

assert str(checkout["with"]["fetch-depth"]) == "0"
assert 'test "$(git rev-parse --is-shallow-repository)" = "false"' in verify["run"]
assert 'git rev-parse --verify "HEAD^{commit}"' in verify["run"]
assert (
"gitleaks:v8.30.0@sha256:691af3c7c5a48b16f187ce3446d5f194838f91238f27270ed36eef6359a574d9"
in scan["run"]
)
log_opts = re.search(r'--log-opts="([^"]+)"', scan["run"])
assert log_opts is not None
assert log_opts.group(1) == "--full-history --diff-filter=tuxdb HEAD --"
assert "--all" not in log_opts.group(1).split()


def test_dco_stays_unconditional_and_has_no_path_filter() -> None:
dco = _load("dco.yml")

Expand Down