Skip to content

Commit e2cf92b

Browse files
committed
Configure gitleaks to block pushes but allow commits
- Remove --exit-code 0 flag (gitleaks will block on findings) - Change stages from [commit, push] to [push] only - Gitleaks now blocks pushes if secrets are detected - Commits proceed without gitleaks blocking for local development - Prevents secrets from reaching remote repository
1 parent c19078f commit e2cf92b

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

.pre-commit-config-simple.yaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
# Simplified pre-commit config (if full version has issues)
23
# This version uses local hooks and doesn't require external repos
34

@@ -10,37 +11,42 @@ repos:
1011
entry: bash -c 'sed -i "s/[[:space:]]*$//" "$@"' --
1112
language: system
1213
files: \.(py|yaml|yml|sh|md)$
13-
14+
1415
- id: end-of-file-fixer
1516
name: Fix End of Files
1617
entry: bash -c 'for f in "$@"; do [ -s "$f" ] && [ "$(tail -c1 "$f")" != "" ] && echo >> "$f"; done' --
1718
language: system
1819
files: \.(py|yaml|yml|sh|md)$
19-
20+
2021
- id: check-yaml
2122
name: Check YAML
2223
entry: bash -c 'for f in "$@"; do python3 -c "import yaml; yaml.safe_load(open(\"$f\"))" || exit 1; done' --
2324
language: system
2425
files: \.(yaml|yml)$
25-
26+
2627
- id: detect-private-key
2728
name: Detect Private Keys
2829
entry: bash -c 'grep -l "BEGIN.*PRIVATE KEY" "$@" && exit 1 || exit 0' --
2930
language: system
3031
files: .*
31-
32+
3233
- id: airflow-dag-validation
3334
name: Airflow DAG Validation
3435
entry: bash -c 'cd "$(git rev-parse --show-toplevel)" && ./scripts/validate-dags.sh' --
3536
language: system
3637
files: ^dags/.*\.py$
3738
pass_filenames: false
3839
always_run: true
39-
40+
4041
- id: gitleaks-local
41-
name: Gitleaks (if installed)
42-
entry: bash -c 'if command -v gitleaks >/dev/null; then gitleaks detect --no-banner --source . --verbose; else echo "gitleaks not installed, skipping"; fi' --
42+
name: Gitleaks (if installed, push only)
43+
entry: >
44+
bash -c 'if command -v gitleaks >/dev/null; then
45+
gitleaks detect --no-banner --source . --verbose
46+
else
47+
echo "gitleaks not installed, skipping"
48+
fi' --
4349
language: system
4450
pass_filenames: false
45-
always_run: true
46-
51+
stages: [push]
52+
# Only runs on push to block secrets from reaching remote

.pre-commit-config.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
# Pre-commit hooks for qubinode-pipelines
23
# Install with: pip install pre-commit && pre-commit install
34
# Run manually: pre-commit run --all-files
@@ -48,13 +49,15 @@ repos:
4849
stages: [commit]
4950
fail_fast: false
5051

51-
# Secret detection with gitleaks
52+
# Secret detection with gitleaks (blocks pushes, allows commits)
5253
- repo: https://github.com/gitleaks/gitleaks
5354
rev: v8.18.0
5455
hooks:
5556
- id: gitleaks
5657
args: ['--no-banner', '--verbose']
57-
stages: [commit, push]
58+
stages: [push]
59+
# Only runs on push to block secrets from reaching remote
60+
# Commits are allowed to proceed for local development
5861

5962
# YAML validation (for Airflow configs, etc.)
6063
- repo: https://github.com/adrienverge/yamllint

0 commit comments

Comments
 (0)