Skip to content

Dynamic length of filter pattern#732

Merged
babenek merged 20 commits intoSamsung:mainfrom
babenek:kewordgo
Jul 17, 2025
Merged

Dynamic length of filter pattern#732
babenek merged 20 commits intoSamsung:mainfrom
babenek:kewordgo

Conversation

@babenek
Copy link
Copy Markdown
Contributor

@babenek babenek commented Jun 21, 2025

Description

Please include a summary of the change and which is fixed.

  • Use dynamic length of pattern in keyword rules
  • Fix some filters
  • Update typization for Config in a filter class
  • Rename ValueDictionaryValueLengthCheck to ValueLengthCheck
  • Add case of .go language for bytes array
  • Dropbox Token fix

How has this been tested?

Please describe the tests that you ran to verify your changes.

  • UnitTest
  • Benchmark

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 21, 2025

Codecov Report

Attention: Patch coverage is 98.54015% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.36%. Comparing base (200ab5b) to head (b640f75).

Files with missing lines Patch % Lines
credsweeper/filters/value_pattern_check.py 95.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #732      +/-   ##
==========================================
+ Coverage   92.30%   92.36%   +0.05%     
==========================================
  Files         137      137              
  Lines        5485     5524      +39     
  Branches      896      897       +1     
==========================================
+ Hits         5063     5102      +39     
- Misses        269      270       +1     
+ Partials      153      152       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@babenek babenek changed the title Dynamic length of pattern Dynamic length of filter pattern Jul 5, 2025
@babenek babenek marked this pull request as ready for review July 6, 2025 08:04
@babenek babenek requested a review from a team as a code owner July 6, 2025 08:04
@babenek babenek marked this pull request as draft July 7, 2025 09:31
@babenek babenek marked this pull request as ready for review July 7, 2025 09:45
Comment on lines +31 to +32
various_pattern_lengths = list(x if DEFAULT_PATTERN_LEN < x else DEFAULT_PATTERN_LEN
for x in range(MAX_PATTERN_LENGTH + 1))
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.

Suggested change
various_pattern_lengths = list(x if DEFAULT_PATTERN_LEN < x else DEFAULT_PATTERN_LEN
for x in range(MAX_PATTERN_LENGTH + 1))
various_pattern_lengths = [max(x, DEFAULT_PATTERN_LEN)
for x in range(MAX_PATTERN_LENGTH + 1)]

"""

def __init__(self, config: Config = None, pattern_len: int = DEFAULT_PATTERN_LEN):
default_patterns = list(
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.

Use a list comprehension instead of a list + a generator. Please consider introducing a function instead of doing calculations inside the f-string.

various_pattern_lengths = list(x if DEFAULT_PATTERN_LEN < x else DEFAULT_PATTERN_LEN
for x in range(MAX_PATTERN_LENGTH + 1))

def __init__(self, config: Config = None, pattern_len: Optional[int] = None):
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.

Optional[Config]

Comment on lines +51 to +52
self.pattern_lengths = list(pattern_len for _ in range(MAX_PATTERN_LENGTH + 1))
self.patterns = list(pattern for _ in range(MAX_PATTERN_LENGTH + 1))
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.

Suggested change
self.pattern_lengths = list(pattern_len for _ in range(MAX_PATTERN_LENGTH + 1))
self.patterns = list(pattern for _ in range(MAX_PATTERN_LENGTH + 1))
self.pattern_lengths = [pattern_len] * (MAX_PATTERN_LENGTH + 1)
self.patterns = [pattern] * (MAX_PATTERN_LENGTH + 1)

@babenek babenek marked this pull request as draft July 11, 2025 14:07
@babenek babenek marked this pull request as ready for review July 12, 2025 10:38
@babenek babenek requested a review from xDizzix July 12, 2025 11:01
@babenek babenek merged commit 92382c4 into Samsung:main Jul 17, 2025
28 checks passed
@babenek babenek deleted the kewordgo branch July 17, 2025 12:07
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.

4 participants