Skip to content

Add Betterleaks secret scanning to CI - #1564

Closed
shubham-s-pandey wants to merge 2 commits into
OWASP:masterfrom
shubham-s-pandey:ci/evaluate-betterleaks
Closed

shubham-s-pandey wants to merge 2 commits into
OWASP:masterfrom
shubham-s-pandey:ci/evaluate-betterleaks

Conversation

@shubham-s-pandey

Copy link
Copy Markdown

Summary

Adds Betterleaks-based secret scanning to detect credentials that may be accidentally committed to pull requests or repository history. This is an additive security control.

Security impact

A leaked GitHub, Cloudflare, or OAuth credential could allow unauthorized
access to repositories, certificate-generation workflows, or deployment
resources. Detecting these values before merge reduces the time a credential
can remain exposed and gives maintainers an actionable CI failure.

What this PR adds

  • config/betterleaks.toml

    • Uses Betterleaks' built-in detectors.
    • Filters documented placeholders to reduce false positives.
  • .github/workflows/betterleaks.yml

    • Runs on pull requests and pushes to main.
    • Scans complete Git history.
    • Uses the public Betterleaks container.
    • Requires no API key or repository secret.
    • Mounts the checkout read-only.
    • Grants only contents: read.
    • Documents operation, local reproduction, findings handling, and upgrades.

Validation

  • The custom Betterleaks configuration parses successfully.
  • The workflow explicitly loads config/betterleaks.toml.
  • Full repository history is available to the scanner.
  • No real credentials or secret-like test values are committed.

@kingthorin

Copy link
Copy Markdown
Collaborator

Why?

@shubham-s-pandey

Copy link
Copy Markdown
Author

@kingthorin The goal was to add Betterleaks as a secret-scanning check for CI. It is intended to detect accidental commits of credentials or tokens and fail the workflow before those changes are merged.

WSTG is a large, actively contributed repository, so an automated check provides a consistent safeguard across pull requests from different contributors. The workflow uses read-only permissions, requires no API keys, and scans the repository history with a pinned scanner version. This improves the repository’s overall security posture and helps maintain good security hygiene for both the project and its contributors.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The security check can be modified by the PR itself, and its scanner image is not pinned immutably.

3 open findings
What changed in this PR

Adds Betterleaks secret scanning to CI using the repository configuration and full Git history.

Changes:

  • Runs scans for pull requests, master pushes, and manual dispatches.
  • Uses a read-only checkout and restricted permissions.
  • Executes Betterleaks through its container image.
File Description
.github/​workflows/​betterleaks.yml Defines the Betterleaks CI workflow.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/betterleaks.yml
Comment thread .github/workflows/betterleaks.yml
Comment thread .github/workflows/betterleaks.yml
@kingthorin

Copy link
Copy Markdown
Collaborator

Thanks for the idea but this has never been a problem for us. There are issues with the implementation and this came out of the blue.

@kingthorin kingthorin closed this Oct 14, 2026
@shubham-s-pandey

Copy link
Copy Markdown
Author

@kingthorin I'll fix this issues. This is proactive security approach for CI.

@kingthorin

Copy link
Copy Markdown
Collaborator

It's okay, I'll consider some other/similar controls to implement by the team.

Thanks

@kingthorin kingthorin added the repo A task specifically related to the project repository label Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

repo A task specifically related to the project repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants