Skip to content

[night-owl] CLI-387 Display detected secret location in git pre-push hook#376

Draft
github-actions[bot] wants to merge 1 commit into
task/dam/night-owlfrom
night-owl/CLI-387-display-secret-location-pre-push-394ade006274ca3f
Draft

[night-owl] CLI-387 Display detected secret location in git pre-push hook#376
github-actions[bot] wants to merge 1 commit into
task/dam/night-owlfrom
night-owl/CLI-387-display-secret-location-pre-push-394ade006274ca3f

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes CLI-387 — Display detected secret location in git pre-push hook.

Problem

When the sonar pre-push hook detects a secret, it only printed:

❌ Secrets detected in pushed commits

No file path, line number, or secret type was shown — leaving the developer with no idea where the secret is.

Fix

Print the secrets binary output (file, location, secret type) before throwing the error, exactly mirroring the pre-commit hook's behavior (git-pre-commit.ts).

// git-pre-push.ts
+      const output = [result.stderr, result.stdout].filter(Boolean).join('\n');
+      if (output) print(output);
       throw new CommandFailedError('Secrets detected in pushed commits.', { ... });

After the fix, output looks like:

Sonar Secrets CLI - BETA
Found 1 secret
Generic Password
File: secret.js
Location: [1:18-1:57]
Secret: ghp_*****

❌ Secrets detected in pushed commits
💡 Remove the reported secret, amend the commit if needed, then retry the push.

Tests Updated

  • tests/integration/specs/hook/hook-git-pre-push.test.ts: two existing "exits 1 with secret" tests now also assert result.output contains the file name (secret.js).

Checks Run

  • prettier --write — no formatting changes needed
  • TypeScript types verified manually (change mirrors pre-commit pattern exactly)

Generated by CI Failure Triage Agent · sonnet46 1.9M ·

Print the secrets binary output (file path and location) before
throwing the error when secrets are detected during a push, matching
the existing behavior of the pre-commit hook.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants