Source code for src.checks.interfaces_secrets

from collections.abc import Iterable
from pathlib import Path

from src.interfaces import Named


[docs] class SecretInterface: """Represents a single secret that was found by some tool"""
[docs] def __init__(self): pass
[docs] def summarize(self) -> dict: raise NotImplementedError
[docs] class SecretsToolInterface(Named): """Represents a tool that can be applied to a project in order to discover secrets"""
[docs] def __init__(self): pass
[docs] def check_file(self, f: Path) -> None: """Checks the file 'f' for secrets and adds any found secrets to the internal state of the tool.""" raise NotImplementedError
[docs] def check_files(self, files: Iterable[Path]) -> None: """Checks the 'files' for secrets and adds any found secrets to the internal state of the tool.""" raise NotImplementedError
[docs] def create_or_overwrite_baseline(self, project_id: int) -> None: """Creates a new, or overwrites an existing, baseline using the tool's internal state""" raise NotImplementedError
[docs] def update_baseline(self, project_id: int) -> None: """Uses the tool's internal state to update an existing or create a new baseline on disk. Essentially performs an intersection between the internal state and the baseline if there is one, else it just writes the internal state to disk. Important: This method might change the tool's internal state. """ raise NotImplementedError
[docs] def diff_vs_baseline(self, project_id: int) -> Iterable[SecretInterface]: """The list of all secrets the tool found in a project that are not in the baseline.""" raise NotImplementedError
[docs] def delete_baseline(self, project_id: int) -> None: """Removes any persisted baselines this tool has for the given project. No-op if there is no baseline.""" raise NotImplementedError
@property def detected_secrets(self) -> Iterable[SecretInterface]: """The list of all secrets the tool found in a project. Essentially the tools internal state.""" raise NotImplementedError