Skip to content

fix(lint/noSecrets): calculate entropy with entropyThreshold option#6642

Merged
unvalley merged 5 commits intobiomejs:mainfrom
unvalley:no-secrets-entropy-threshold
Jul 2, 2025
Merged

fix(lint/noSecrets): calculate entropy with entropyThreshold option#6642
unvalley merged 5 commits intobiomejs:mainfrom
unvalley:no-secrets-entropy-threshold

Conversation

@unvalley
Copy link
Copy Markdown
Member

@unvalley unvalley commented Jun 30, 2025

Summary

Our noSecrets lint rule has the entropyThreshold option, but this option is not used correctly in the rule implementation as described in #4494 .

This PR fixes the calculation and simplify scaling.
I have:

  • removed string length based scaling because it doesn't work (but this leads a false-positive regression, we should minimize heuristics.)
  • simplified the entropy comparison by adding ENTROPY_PRECISION_MULTIPLIER (honestly DEFAULT_HIGH_ENTROPY_THRESHOLD should be 4.1 instead of 41, but this change can break user config)
  • refactored shannon entropy and test

Closes #4494

Test Plan

Added snapshot for option

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 30, 2025

🦋 Changeset detected

Latest commit: 3c277ca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Jun 30, 2025
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 30, 2025

CodSpeed Performance Report

Merging #6642 will not alter performance

Comparing unvalley:no-secrets-entropy-threshold (3c277ca) with main (4b501d3)

Summary

✅ 115 untouched benchmarks

Comment on lines -28 to -29
// Postgres json path query
const isNumeric = '@.scoreDisplayMode == "numeric" || @.scoreDisplayMode == "metricSavings"'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I believe this is detected as high entropy, so it appears to be a regression but it's working correctly. The entropyThreshold option exists for these kinds of cases, so I don't think it's a big problem.

@unvalley unvalley marked this pull request as ready for review June 30, 2025 14:30
@unvalley unvalley requested review from Conaclos and dyc3 July 1, 2025 08:36
Copy link
Copy Markdown
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Great fix!

@unvalley unvalley merged commit a991229 into biomejs:main Jul 2, 2025
29 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 2, 2025
marko-hologram pushed a commit to marko-hologram/biome that referenced this pull request Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 entropyThreshold option for noSecrets rules does not have an effect

3 participants