Skip to content

Commit

Permalink
Code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
babenek committed Jul 23, 2023
1 parent 3ebf0e6 commit 7c74751
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
8 changes: 7 additions & 1 deletion credsweeper/rules/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@
- (^|[^.0-9A-Za-z_/+-])(?P<value>[a-zA-Z0-9]{18}([a-zA-Z0-9]{14})?)([^0-9A-Za-z.$_/+-]|$)
filter_type: WeirdBase64Token
min_line_len: 18
required_regex: ([a-zA-Z0-9_/+-]{10})

- name: Bitbucket Client Secret
severity: info
Expand All @@ -594,6 +595,7 @@
- (^|[^.0-9A-Za-z_/+-])(?P<value>([a-zA-Z0-9_-]{32}){1,2})([^0-9A-Za-z.$_/+-]|$)
filter_type: WeirdBase64Token
min_line_len: 32
required_regex: ([a-zA-Z0-9_/+-]{10})

- name: Jira / Confluence PAT token
severity: high
Expand All @@ -614,6 +616,7 @@
- (^|[^.0-9A-Za-z_/+-])(?P<value>[a-zA-Z0-9]{24})([^=0-9A-Za-z.$_/+-]|$)
filter_type: WeirdBase64Token
min_line_len: 24
required_regex: ([a-zA-Z0-9_/+-]{10})

- name: Atlassian PAT token
severity: high
Expand Down Expand Up @@ -744,6 +747,7 @@
- (^|[^.0-9A-Za-z_/+-])(?P<value>[a-z0-9]{15})([^=0-9A-Za-z_/+-]|$)
filter_type: WeirdBase36Token
min_line_len: 15
required_regex: ([a-zA-Z0-9_/+-]{10})

- name: Gitlab Incoming Email Token
severity: info
Expand All @@ -752,6 +756,7 @@
- (^|[^.0-9A-Za-z_/+-])(?P<value>[a-z0-9]{24,25})([^=0-9A-Za-z_/+-]|$)
filter_type: WeirdBase36Token
min_line_len: 24
required_regex: ([a-zA-Z0-9_/+-]{10})

- name: Gitlab Feed Token
severity: info
Expand All @@ -760,6 +765,7 @@
- (^|[^.0-9A-Za-z_/+-])(?P<value>[a-zA-Z0-9_-]{20})([^=0-9A-Za-z_/+-]|$)
filter_type: WeirdBase64Token
min_line_len: 20
required_regex: ([a-zA-Z0-9_/+-]{10})

- name: Jira 2FA
severity: info
Expand All @@ -773,4 +779,4 @@
- ValueBase32DataCheck
- ValueTokenBase32Check
min_line_len: 16
doc_available: true
required_regex: ([a-zA-Z0-9_/+-]{10})
15 changes: 0 additions & 15 deletions credsweeper/scanner/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,6 @@ def yield_rule_scanner(
or RuleType.PEM_KEY == rule.rule_type and matched_pem_key):
yield rule, scanner

@staticmethod
def _required_substrings_not_present(required_substrings: List[str], line: str) -> bool:
""" returns True if required substring absent in line """
for substring in required_substrings:
if substring in line:
return False
return True

@staticmethod
def _required_regex_not_matched(required_regex: re.Pattern, line: str) -> bool:
""" returns True if line does not matched required_regex """
if required_regex.match(line):
return False
return True

def scan(self, provider: ContentProvider) -> List[Candidate]:
"""Run scanning of list of target lines from 'targets' with set of rule from 'self.rules'.
Expand Down

0 comments on commit 7c74751

Please sign in to comment.