Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 18 additions & 0 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,24 @@ jobs:
paths = ['''^backend/tests/test_tracing_guard\.py$''']
TOML
fi
# The same reviewed sign-in webhook in platform history, bound to the exact
# commits that added or carried it, so any new commit on the path still fails.
if [[ "${REPOSITORY:-}" == '60xAI/ai-brain-platform' ]]; then
cat >> "$config" <<'TOML'
[[allowlists]]
description = "Reviewed sign-in webhook kept by its owner (ai-brain-platform#1601)"
condition = "AND"
targetRules = ["slack-webhook-url"]
commits = [
"3757fbb3bfabef696925b9ee9400e1244fbb202f",
"43c569cf72e695d023c58593d3e7003a1e9bb5a9",
"9799135ec5da6b000ebbadb135052b255fd768fa",
"b83bddef41260358273cad325809e11801d2977c",
"dd8da03b435323738d8b2d93f77d108b3613af6b",
]
paths = ['''^backend/app/api/routes/auth\.py$''']
TOML
fi
log_opts='--all --diff-merges=first-parent'
if [[ "$FULL_HISTORY" != true ]]; then
[[ "$BASE_SHA" =~ ^[a-f0-9]{40}$ && "$HEAD_SHA" =~ ^[a-f0-9]{40}$ ]] || { echo 'Missing valid scan range'; exit 2; }
Expand Down
26 changes: 26 additions & 0 deletions tests/test_secret_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,32 @@ def test_pipelines_history_exceptions_only_cover_their_own_commits(self):
report = json.loads((scratch/'gitleaks-findings.json').read_text())
self.assertIn({'path': filename, 'rule_id': rule}, report)

def test_platform_webhook_exception_only_covers_its_own_commits(self):
# The platform webhook exception is bound to exact historical commits, so a
# new commit on the same path must still be blocked. Synthetic, unissued value.
webhook = 'https://hooks.slack.com/services/' + 'T0SYNTHETIC/B0SYNTHETIC/' + 'abcdefghijklmnopqrstuvwx'
filename = 'backend/app/api/routes/auth.py'
with tempfile.TemporaryDirectory() as tmp:
repo = Path(tmp, 'repo'); repo.mkdir()
scratch = Path(tmp, 'runner'); scratch.mkdir()
for args in [('init', '-q'), ('config', 'user.name', 'Security Test'),
('config', 'user.email', 'test@example.invalid')]:
self.assertEqual(run('git', *args, cwd=repo).returncode, 0)
target = repo / filename
target.parent.mkdir(parents=True)
target.write_text(f'URL = "{webhook}"\n')
self.commit(repo, 'Synthetic webhook on the excepted path')
env = os.environ | {'RUNNER_TEMP': str(scratch),
'GITHUB_STEP_SUMMARY': str(scratch/'summary'),
'GITHUB_OUTPUT': str(scratch/'output'),
'FULL_HISTORY': 'true', 'BASE_SHA': '', 'HEAD_SHA': '',
'REPOSITORY': '60xAI/ai-brain-platform'}
result = run('bash', '-c', scan_script(), cwd=repo, env=env)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn('result=10', (scratch/'output').read_text())
report = json.loads((scratch/'gitleaks-findings.json').read_text())
self.assertIn({'path': filename, 'rule_id': 'slack-webhook-url'}, report)

def commit(self, repo, message):
self.assertEqual(run('git', 'add', '.', cwd=repo).returncode, 0)
self.assertEqual(run('git', 'commit', '-qm', message, cwd=repo).returncode, 0)
Expand Down
Loading