Skip to content

fix(tests): join _person helper threads in test_second_factor_terminal.py #5621

fix(tests): join _person helper threads in test_second_factor_terminal.py

fix(tests): join _person helper threads in test_second_factor_terminal.py #5621

Workflow file for this run

name: Secret Scan
# SOC 2: secret scanning (OA-C-24). Uses the free, MIT-licensed gitleaks CLI.
# NOTE: the gitleaks *Action* now requires a paid GITLEAKS_LICENSE for
# organization-owned repos (even public ones); the gitleaks CLI does not, so we
# invoke it directly and pin the version. Scans full git history on PRs + main.
on:
pull_request:
# Drafts run nothing (each job checks `draft`); marking one ready runs CI.
types: [opened, synchronize, reopened, ready_for_review]
# The merge queue tests each group before it lands on main.
merge_group:
push:
branches: [main]
permissions:
contents: read
# Cancel a pull request's earlier run when it gets a new commit; runs on
# main always finish.
concurrency:
# A pull request's newer push cancels its older run. Every other event (the
# merge queue, main, schedules, dispatches) gets a group of its own, so it
# is never cancelled or replaced.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
gitleaks:
name: gitleaks
if: github.event.pull_request.draft != true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Install gitleaks
env:
GITLEAKS_VERSION: 8.30.1
GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb
run: |
python3 scripts/ci/install_checked_tool.py \
--url "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
--sha256 "$GITLEAKS_SHA256" --member gitleaks \
--destination "$RUNNER_TEMP/checking-tools/gitleaks"
echo "$RUNNER_TEMP/checking-tools" >> "$GITHUB_PATH"
"$RUNNER_TEMP/checking-tools/gitleaks" version
- name: Scan git history for secrets
# --config pins the baseline (.gitleaks.toml) that scopes one known,
# pre-existing historical finding; all new commits are still fully scanned.
# --log-opts=HEAD scans the full history of the checked-out commit (the
# PR merge commit, or main). Without it gitleaks scans every fetched
# branch, so one branch's finding fails every other pull request.
run: |
set -euo pipefail
report_dir="$(mktemp -d "${RUNNER_TEMP}/gitleaks-report.XXXXXX")"
trap 'rm -rf -- "$report_dir"' EXIT
report_path="${report_dir}/metadata.tsv"
template_path="${report_dir}/metadata.tmpl"
# Gitleaks' JSON Finding includes fields beyond redacted Secret,
# Match, and Line (including optional Fragment). Use its supported
# template reporter to serialize only these four metadata fields.
# Base64 avoids control-character delimiters in repository paths.
cat > "$template_path" <<'EOF'
{{range .}}{{printf "%s\t%s\t%d\t%s\n" (.RuleID | b64enc) (.File | b64enc) .StartLine (.Commit | b64enc)}}{{end -}}
EOF
# Never let scanner output enter Actions logs. The template report
# contains only RuleID, repository-relative file/line, and commit.
set +e
gitleaks git . \
--config .gitleaks.toml \
--redact=100 \
--no-banner \
--log-opts=HEAD \
--report-format=template \
--report-template "$template_path" \
--report-path "$report_path" \
>/dev/null 2>&1
scanner_exit_code=$?
set -e
python3 scripts/ci/gitleaks_metadata.py "$report_path" "$scanner_exit_code"