Skip to content
Discussion options

You must be logged in to vote

This is actually a known limitation. GitHub Secret Scanning primarily targets specific file types and patterns like .env, .properties, .yaml, .json rather than scanning raw Java source code for string literals.

For catching hardcoded secrets inside .java files, here are your options:

1. Use detect-secrets as a pre-commit hook

pip install detect-secrets
detect-secrets scan > .secrets.baseline

This catches secrets in any file type including .java before they even hit the repo.

2. Add Trufflehog to your GitHub Actions workflow

- name: Scan for secrets
  uses: trufflesecurity/trufflehog@main
  with:
    path: ./
    base: main

3. Use SpotBugs with Find Security Bugs in your Maven build

<plugin>…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ersuayrus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug GitHub or a GitHub feature is not working as intended Code Security Build security into your GitHub workflow with features to keep your codebase secure Welcome 🎉 Used to greet and highlight first-time discussion participants. Welcome to the community! source:ui Discussions created via Community GitHub templates
2 participants