One of the most common security mistakes is accidentally exposing credentials to unauthorized individuals - whether by sharing files with others or mistakenly committing them to a repository. Because of this, many tools have been created to detect the presence of sensitive data. Below are two popular and proven solutions:
Gitleaks
# Scan the current directory for secrets
gitleaks dir -v
# Scan gir repository for secrets
gitleaks git -v
TruffleHog
# Scan the current filesystem directory
trufflehog filesystem .
# Scan the current Git repository
trufflehog git file://.
Regularly scanning dotfiles with tools like Gitleaks and TruffleHog helps detect and prevent leaking secrets into version control. This practice improves security and reduces the risk of exposing sensitive data. It's good idea to add them to your pre-commit hooks!