Interview Security & DevSecOps

What is secrets scanning, and how do you stop secrets being committed to Git? [Intermediate]

Answer

Secrets scanning detects credentials accidentally committed to source code, images, logs, or configuration files. To stop secrets from reaching Git, I use pre-commit hooks, server-side scanning, PR checks, developer education, and patterns that avoid static credentials in the first place.

Technical explanation

Tools include gitleaks, trufflehog, GitHub secret scanning, GitLab secret detection, and enterprise DLP controls.

Pre-commit checks give fastest feedback, but server-side scanning is still needed because local hooks can be bypassed.

The best prevention is workload identity/OIDC and secret managers so developers do not handle long-lived keys.

Hands-on example

Hands-on:

gitleaks detect --source . --redact --exit-code 1

Add it to pre-commit and CI. Configure branch protection so the PR cannot merge if a secret is detected. For cloud access, use GitHub OIDC to assume a role instead of storing AWS keys.

Preparing for an interview?

Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.

More Security & DevSecOps interview questions

← All Security & DevSecOps questions