Skip to content

Commit

Permalink
rollback debug
Browse files Browse the repository at this point in the history
  • Loading branch information
babenek committed Dec 11, 2024
1 parent fd08d47 commit 1caab0b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 4 additions & 4 deletions credsweeper/filters/value_base64_part_check.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import contextlib
import re
import statistics

Expand Down Expand Up @@ -33,7 +34,7 @@ def run(self, line_data: LineData, target: AnalysisTarget) -> bool:
"""

try:
with contextlib.suppress(Exception):
line = line_data.line
len_line = len(line)
value = line_data.value
Expand Down Expand Up @@ -64,7 +65,7 @@ def run(self, line_data: LineData, target: AnalysisTarget) -> bool:
# simple analysis for data too large to yield sensible insights
part_set = set(line[left_start:right_end])
if not part_set.difference(self.base64_set):
# obviously case: all characters are base64 standard
# obvious case: all characters are base64 standard
return True

left_part = line[left_start:line_data.value_start]
Expand Down Expand Up @@ -96,6 +97,5 @@ def run(self, line_data: LineData, target: AnalysisTarget) -> bool:
if avg_min <= left_entropy and avg_min <= right_entropy:
# high entropy of bound parts looks like a part of base64 long line
return True
except Exception as exc:
print(exc)

return False
4 changes: 0 additions & 4 deletions credsweeper/rules/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ def _init_patterns(self, _values: List[str]) -> List[re.Pattern]:
elif RuleType.MULTI == self.rule_type and 2 == len(_values) \
or self.rule_type in (RuleType.PATTERN, RuleType.PEM_KEY) and 0 < len(_values):
for value in _values:
try:
re.compile(value)
except Exception as exc:
print(exc)
_patterns.append(re.compile(value))
if RuleType.PEM_KEY == self.rule_type and 1 < len(_values):
logger.warning(f"Rule {self.rule_name} has extra patterns. Only single pattern supported.")
Expand Down

0 comments on commit 1caab0b

Please sign in to comment.