Skip to content

Commit

Permalink
Usage_list refactored, password for doc (#379)
Browse files Browse the repository at this point in the history
* [auxiliary] 2023-07-13T10:46:39+03:00

* SourceType applied to unify usage 'doc' and 'src'

* tmp

* fix

* import fix

* codestyle

* [skip actions] [auxiliary] 2023-07-13T15:20:57+03:00

* min_line_len=10

* fix flake8
  • Loading branch information
babenek authored Jul 17, 2023
1 parent 2b3e47d commit 767546a
Show file tree
Hide file tree
Showing 26 changed files with 369 additions and 255 deletions.
9 changes: 2 additions & 7 deletions credsweeper/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CredSweeper:
"""

def __init__(self,
rule_path: Optional[str] = None,
rule_path: Union[None, str, Path] = None,
config_path: Optional[str] = None,
api_validation: bool = False,
json_filename: Union[None, str, Path] = None,
Expand Down Expand Up @@ -97,9 +97,7 @@ def __init__(self,
exclude_values=exclude_values)
self.config = Config(config_dict)
self.scanner = Scanner(self.config, rule_path)
self.doc_scanner = Scanner(self.config, rule_path, ["doc"])
self.deep_scanner = DeepScanner(self.config, self.scanner)
self.deep_doc_scanner = DeepScanner(self.config, self.doc_scanner)
self.credential_manager = CredentialManager()
self.json_filename: Union[None, str, Path] = json_filename
self.xlsx_filename: Union[None, str, Path] = xlsx_filename
Expand Down Expand Up @@ -305,12 +303,9 @@ def file_scan(self, content_provider: Union[DiffContentProvider, TextContentProv
candidates.append(dummy_candidate)

else:
if self.config.depth:
if self.config.depth or self.config.doc:
# deep scan with possible data representation
candidates = self.deep_scanner.scan(content_provider, self.config.depth, self.config.size_limit)
elif self.config.doc:
# document-specific scanning
candidates = self.deep_doc_scanner.scan(content_provider, 0, self.config.size_limit)
else:
if content_provider.file_type not in self.config.exclude_containers:
# Regular file scanning
Expand Down
7 changes: 4 additions & 3 deletions credsweeper/filters/group/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def filters(self, filters: List[Filter]) -> None:
@staticmethod
def get_keyword_base_filters(config: Config) -> List[Filter]:
"""returns base filters"""
return [ #
filters = [ #
SeparatorUnusualCheck(),
ValueAllowlistCheck(),
ValueArrayDictionaryCheck(),
Expand All @@ -46,13 +46,14 @@ def get_keyword_base_filters(config: Config) -> List[Filter]:
ValueLastWordCheck(),
ValueLengthCheck(config),
ValueMethodCheck(),
ValueNotAllowedPatternCheck(),
ValueSimilarityCheck(),
ValueStringTypeCheck(config),
ValueTokenCheck(),
VariableNotAllowedPatternCheck(),
ValuePatternCheck(config)
]
if not config.doc:
filters.extend([ValuePatternCheck(config), ValueNotAllowedPatternCheck()])
return filters

@staticmethod
def get_pattern_base_filters(config: Config) -> List[Filter]:
Expand Down
3 changes: 1 addition & 2 deletions credsweeper/filters/value_not_part_encoded_check.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Optional

import re
from typing import Optional

from credsweeper.config import Config
from credsweeper.credentials import LineData
Expand Down
Loading

0 comments on commit 767546a

Please sign in to comment.