credsweeper.scanner package

Subpackages

Submodules

credsweeper.scanner.scanner module

class credsweeper.scanner.scanner.Scanner(config: Config, rule_path: None | str | Path)[source]

Bases: object

Advanced Credential Scanner base class.

Parameters:
  • rules – list of rule objects to check

  • min_pattern_len – minimal length specified in all pattern rules

  • min_keyword_len – minimal possible length for a string to be matched by any keyword rule

  • min_len – Smallest between min_pattern_len and min_keyword_len

  • TargetGroup – Type for List[Tuple[AnalysisTarget, str, int]]

TargetGroup

alias of List[Tuple[AnalysisTarget, str, int]]

static get_scanner(rule: Rule) Type[ScanType][source]

Choose type of scanner base on rule affiliation.

Parameters:

rule – rule object used to scanning

Returns:

depending on the rule type, returns the corresponding scanner class

keywords_required_substrings_check(text: str) bool[source]

check whether text has any required substring for all keyword type rules

scan(provider: ContentProvider) List[Candidate][source]

Run scanning of list of target lines from ‘targets’ with set of rule from ‘self.rules’.

Parameters:

provider – objects with data to analyze: line, line number, filepath and all lines in file

Returns:

list of all detected credential candidates in analyzed targets

yield_rule_scanner(line_len: int, matched_pattern: bool, matched_keyword: bool, matched_pem_key: bool, matched_multi: bool) Generator[Tuple[Rule, Type[ScanType]], None, None][source]

returns generator for rules and according scanner

Module contents