Skip to content

fix(ci): migrate from deprecated gitleaks to betterleaks - #117

Merged
sonupreetam merged 2 commits into
complytime:mainfrom
sonupreetam:fix/gitleaks-config-not-loaded
Jul 30, 2026
Merged

fix(ci): migrate from deprecated gitleaks to betterleaks#117
sonupreetam merged 2 commits into
complytime:mainfrom
sonupreetam:fix/gitleaks-config-not-loaded

Conversation

@sonupreetam

@sonupreetam sonupreetam commented Jul 30, 2026

Copy link
Copy Markdown
Member

Summary

Migrates the secrets scanner from the deprecated REPOSITORY_GITLEAKS to
REPOSITORY_BETTERLEAKS and properly configures the .content-lock.json
false positive suppression.

Why the previous fix (PR #114) didn't work

PR #114 added a .gitleaks.toml with a paths allowlist for
.content-lock.json. However, MegaLinter's gitleaks integration invokes:

gitleaks detect --redact -c /action/lib/.automation/.gitleaks.toml --verbose --source .

The -c flag passes MegaLinter's built-in config (inside the container),
which overrides gitleaks' local config discovery. The repo's .gitleaks.toml
was present in the workspace but never loaded. This is confirmed by the
PR #86 CI re-run on Jul 30
which still fails with the same 2 generic-api-key findings.

Why migrate to betterleaks instead of patching gitleaks

MegaLinter v9.6.0 emits this deprecation warning on every run:

REPOSITORY_GITLEAKS is deprecated and will be removed in a future major
release. gitleaks has been superseded by betterleaks, a faster and more
accurate secrets scanner created by the same author.

Rather than patching a linter that will be removed, this PR migrates to the
recommended replacement.

Changes

  • .mega-linter.yml: Replace REPOSITORY_GITLEAKS with
    REPOSITORY_BETTERLEAKS; remove REPOSITORY_GITLEAKS_CONFIG_FILE
  • .betterleaks.toml (new): Expr-based prefilter skips
    .content-lock.json before regex matching — equivalent to the old path
    allowlist but using betterleaks' native syntax
  • .gitleaks.toml (deleted): No longer needed

Related Issues

Review Hints

  • Betterleaks is a drop-in replacement by the original gitleaks author
    (repo)
  • prefilter must appear before [extend] in TOML (keys after a table
    header are parsed as part of that table)
  • MegaLinter auto-detects .betterleaks.toml for REPOSITORY_BETTERLEAKS

@sonupreetam
sonupreetam marked this pull request as ready for review July 30, 2026 11:38
@sonupreetam
sonupreetam requested review from a team as code owners July 30, 2026 11:38
REPOSITORY_GITLEAKS is deprecated in MegaLinter v9.6.0 and will be
removed in a future major release. Gitleaks has been superseded by
betterleaks, a faster and more accurate secrets scanner by the same
author.

PR complytime#114 added a .gitleaks.toml with a path allowlist for
.content-lock.json, but MegaLinter's gitleaks integration passes
its own built-in config via -c /action/lib/.automation/.gitleaks.toml,
which overrides local config discovery. The repo's .gitleaks.toml was
never loaded — the false positive persisted on every PR that includes
the "complyapi" entry (e.g. PR complytime#86 re-run on Jul 30).

This commit:
- Replaces REPOSITORY_GITLEAKS with REPOSITORY_BETTERLEAKS in
  .mega-linter.yml
- Adds .betterleaks.toml with an Expr prefilter that skips
  .content-lock.json (commit SHA map, not secrets)
- Removes the now-unused .gitleaks.toml

Refs complytime#86

Signed-off-by: sonupreetam <spreetam@redhat.com>
@sonupreetam
sonupreetam force-pushed the fix/gitleaks-config-not-loaded branch from 9aae95f to a1c64d4 Compare July 30, 2026 11:44
@sonupreetam sonupreetam changed the title fix(ci): point MegaLinter at repo gitleaks config fix(ci): migrate from deprecated gitleaks to betterleaks Jul 30, 2026
Betterleaks scans the full git tree in project mode, unlike
file-based linters that respect ADDITIONAL_EXCLUDED_DIRECTORIES.
Add node_modules/ to the prefilter to skip vendored dependencies
that produce false positives not previously flagged by gitleaks.

Refs complytime#86

Signed-off-by: sonupreetam <spreetam@redhat.com>
@sonupreetam

Copy link
Copy Markdown
Member Author

Hey @yvonnedevlinrh, thanks for the diagnosis in #114, it was spot on (the "complyapi" key + 40-char hex value triggering generic-api-key).

Unfortunately the fix didn't take effect, MegaLinter's gitleaks runner passes its own built-in config via -c /action/lib/.automation/.gitleaks.toml, which overrides the repo's.gitleaks.tomlentirely. The PR #86 re-run on Jul 30 still fails with the same 2 findings.

This PR which migrates from the deprecated REPOSITORY_GITLEAKS to REPOSITORY_BETTERLEAKS (as MegaLinter recommends) with a proper prefilter config. Happy to have you review it since you're familiar with the context.

@yvonnedevlinrh yvonnedevlinrh 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.

LGTM

@sonupreetam
sonupreetam merged commit 0781fe5 into complytime:main Jul 30, 2026
13 checks passed
@sonupreetam
sonupreetam deleted the fix/gitleaks-config-not-loaded branch July 30, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants