Skip to content

Conversation

9999years
Copy link
Contributor

Description:

PR #1524 broke the ability to specify a [[rules]] with the same ID as a built-in rule in order to extend the default configuration.

This PR restores this ability, but merges the provided configuration with the default rule instead of overwriting the default rule wholesale.

Checklist:

  • Does your PR pass tests?
  • Have you written new tests for your changes?
  • Have you lint your code locally prior to submission?

PR gitleaks#1524 broke the ability to specify a `[[rules]]` with the same ID as
a built-in rule in order to extend the default configuration.

This PR restores this ability, but merges the provided configuration
with the default rule instead of overwriting the default rule wholesale.
@rgmz
Copy link
Contributor

rgmz commented Oct 9, 2024

(Continuing the discussion from #1524.)

@rgmz Just a minimal example. Our actual configuration looks like this:

Ah, I see you want to completely replace the rule. I haven't seen anyone do that before. The impetus for this change was because quite a few people were doing stuff similar to your minimal example.

The [extend] functionality seems to be poorly understood / lack definite clarity on what gets appended versus overwritten. This change makes sense — although it is inconsistent that tags/keywords are overwritten but allowlist is appended.

@zricethezav
Copy link
Collaborator

The [extend] functionality seems to be poorly understood / lack definite clarity on what gets appended versus overwritten. This change makes sense — although it is inconsistent that tags/keywords are overwritten but allowlist is appended.

I think we need to be consistent across the board for the default case. All the things should be appended rather than overwritten. A feature could be included to configure the behavior of extend down the line -- append vs overwrite, or something.

@zricethezav zricethezav merged commit be9d0f8 into gitleaks:master Oct 10, 2024
1 check passed
@9999years 9999years deleted the fix-rule-extension branch October 10, 2024 21:58
alayne222 pushed a commit to alayne222/gitleaks that referenced this pull request May 28, 2025
* Reimplement the ability to override built-in rules

PR gitleaks#1524 broke the ability to specify a `[[rules]]` with the same ID as
a built-in rule in order to extend the default configuration.

This PR restores this ability, but merges the provided configuration
with the default rule instead of overwriting the default rule wholesale.

* Add tests

* Append keywords and tags
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.

3 participants