Skip to content

Conversation

@jporzucek
Copy link

@jporzucek jporzucek commented Sep 2, 2025

Description:

Implements whitelisting #1019

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@jporzucek jporzucek requested review from a team as code owners September 2, 2025 20:14
@jporzucek jporzucek changed the title Add whitelist feature to suppress acceptable secrets Add whitelist feature to suppress test secrets Sep 2, 2025
Copy link
Contributor

@nabeelalam nabeelalam left a comment

Choose a reason for hiding this comment

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

Hey @jpozucek, thanks for contributing. I'm going through your PR but I've left a couple comments

Copy link
Contributor

@rosecodym rosecodym left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this - the change looks pretty clean and surgical. I'd like to ask how much of a lift it would be to rename "whitelist" to "allowlist," simply because we're already using the latter term in the codebase, and we've historically found a minor but extant cognitive penalty when getting people up to speed on multiple concepts that are the same but have different names. (I'm not requesting changes for this in case it's more of a burden than I'm anticipating.)

@jporzucek jporzucek changed the title Add whitelist feature to suppress test secrets Add allowlist feature to suppress test secrets Sep 11, 2025
@jporzucek
Copy link
Author

@rosecodym Changed to allowlist, np!

@jporzucek jporzucek requested a review from rosecodym September 11, 2025 10:28
@nabeelalam
Copy link
Contributor

@jporzucek I tried to test allowlist-secrets with a yaml with a few known verified and unverified secrets, but even though the yaml file is loaded, the result still includes all of the allow listed secrets

@jporzucek
Copy link
Author

@nabeelalam ahhh, rookie mistake! Please try again now

@jporzucek
Copy link
Author

jporzucek commented Sep 12, 2025

Also added support for correct parsing with YAML files that don't end with a newline character. The function now automatically appends \n if missing, improving parser compatibility and following POSIX standards.

@nabeelalam
Copy link
Contributor

Thanks for the update @jporzucek I'll test it again in a little bit

@nabeelalam
Copy link
Contributor

The flag is working for me now, thanks @jporzucek. This looks good! If it's not a big change, is it possible to make the flag itself a bit more accurately descriptive? --allowlist-secrets doesn't inherently indicate that it accepts a path to a yaml file. Just off the top of my head --secret-allowlist-path seems a touch more accurate. Perhaps you can think of a better one?

@jporzucek
Copy link
Author

@nabeelalam Renamed to --allowlist-secrets-file - hope it's more accurate 🤞

Copy link
Contributor

@camgunz camgunz left a comment

Choose a reason for hiding this comment

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

Thanks for this! The changes I want are using RedactGlobally instead of maskSecret and compiling the regexes up top. It's possible using slices.DeleteFunc doesn't make sense, so if it doesn't, definitely don't rework things to make it make sense.

@jporzucek
Copy link
Author

@camgunz All requested changes applied! 🙌

@jporzucek jporzucek requested a review from camgunz September 18, 2025 10:47
@zricethezav
Copy link
Contributor

I don't want to throw a wrench in this review, but what about introducing this feature in the --config file? https://github.com/trufflesecurity/trufflehog?tab=readme-ov-file#configuration

@jporzucek
Copy link
Author

I don't want to throw a wrench in this review, but what about introducing this feature in the --config file? https://github.com/trufflesecurity/trufflehog?tab=readme-ov-file#configuration

You mean as a new field in sources?

@zricethezav
Copy link
Contributor

zricethezav commented Sep 18, 2025

You mean as a new field in sources?

I was thinking a new top-level key allowlist in the config that could be globally defined like "ignore these secrets if found in any detector" and detector specific allowlists like "ignore these secrets if found in this detector".

This behavior is similar to what is offered in the gitleaks configuration https://github.com/gitleaks/gitleaks?tab=readme-ov-file#configuration.

FWIW, I may be muddying the waters here but I figured since --config supports custom detectors and sources it could also include detector behaviors like allowlists filters.

@jporzucek
Copy link
Author

@zricethezav I've added a top-level allowlists so it matches gitleaks naming convention. The behavior now is it merges allowlisted secrets from --config and --allowlist-secrets-file files. I'm not sure what's the expected behavior so let me know if one should have precedence over the other.

@jporzucek
Copy link
Author

jporzucek commented Sep 30, 2025

@zricethezav @nabeelalam @camgunz Can you take a look when you got a chance? 🙏

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.

5 participants