Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ggshield.secret to ggshield.verticals.secret #700

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ggshield/cmd/secret/scan/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
from ggshield.core.errors import UnexpectedError
from ggshield.scan import Files, ScanContext, ScanMode
from ggshield.scan.file import get_files_from_paths
from ggshield.secret import RichSecretScannerUI, SecretScanCollection, SecretScanner
from ggshield.verticals.secret import (
RichSecretScannerUI,
SecretScanCollection,
SecretScanner,
)


@click.command()
Expand Down
2 changes: 1 addition & 1 deletion ggshield/cmd/secret/scan/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ggshield.core.git_hooks.ci import collect_commit_range_from_ci_env
from ggshield.core.git_shell import check_git_dir
from ggshield.scan import ScanContext, ScanMode
from ggshield.secret.repo import scan_commit_range
from ggshield.verticals.secret.repo import scan_commit_range


@click.command()
Expand Down
2 changes: 1 addition & 1 deletion ggshield/cmd/secret/scan/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ggshield.core.config import Config
from ggshield.core.errors import handle_exception
from ggshield.scan import ScanContext, ScanMode
from ggshield.secret.docker import docker_save_to_tmp, docker_scan_archive
from ggshield.verticals.secret.docker import docker_save_to_tmp, docker_scan_archive


# bailout if docker command takes longer than 6 minutes
Expand Down
2 changes: 1 addition & 1 deletion ggshield/cmd/secret/scan/dockerarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ggshield.core.config import Config
from ggshield.core.errors import handle_exception
from ggshield.scan import ScanContext, ScanMode
from ggshield.secret.docker import docker_scan_archive
from ggshield.verticals.secret.docker import docker_scan_archive


@click.command(hidden=True)
Expand Down
2 changes: 1 addition & 1 deletion ggshield/cmd/secret/scan/docset.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ggshield.core.errors import handle_exception
from ggshield.core.text_utils import create_progress_bar, display_info
from ggshield.scan import ScanContext, ScanMode, Scannable, StringScannable
from ggshield.secret import SecretScanCollection, SecretScanner
from ggshield.verticals.secret import SecretScanCollection, SecretScanner


def generate_files_from_docsets(
Expand Down
6 changes: 5 additions & 1 deletion ggshield/cmd/secret/scan/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
from ggshield.core.errors import handle_exception
from ggshield.scan import ScanContext, ScanMode
from ggshield.scan.file import get_files_from_paths
from ggshield.secret import RichSecretScannerUI, SecretScanCollection, SecretScanner
from ggshield.verticals.secret import (
RichSecretScannerUI,
SecretScanCollection,
SecretScanner,
)


@click.command()
Expand Down
6 changes: 3 additions & 3 deletions ggshield/cmd/secret/scan/precommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from ggshield.core.errors import handle_exception
from ggshield.core.git_shell import check_git_dir
from ggshield.scan import Commit, ScanContext, ScanMode
from ggshield.secret import SecretScanCollection, SecretScanner
from ggshield.secret.output import SecretTextOutputHandler
from ggshield.secret.output.messages import remediation_message
from ggshield.verticals.secret import SecretScanCollection, SecretScanner
from ggshield.verticals.secret.output import SecretTextOutputHandler
from ggshield.verticals.secret.output.messages import remediation_message


REMEDIATION_STEPS = """ Since the secret was detected before the commit was made:
Expand Down
4 changes: 2 additions & 2 deletions ggshield/cmd/secret/scan/prepush.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from ggshield.core.git_shell import check_git_dir, get_list_commit_SHA
from ggshield.core.utils import EMPTY_SHA, EMPTY_TREE
from ggshield.scan import ScanContext, ScanMode
from ggshield.secret.output.messages import remediation_message
from ggshield.secret.repo import scan_commit_range
from ggshield.verticals.secret.output.messages import remediation_message
from ggshield.verticals.secret.repo import scan_commit_range


logger = logging.getLogger(__name__)
Expand Down
9 changes: 6 additions & 3 deletions ggshield/cmd/secret/scan/prereceive.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
from ggshield.core.git_shell import get_list_commit_SHA
from ggshield.core.text_utils import display_error
from ggshield.scan import ScanContext, ScanMode
from ggshield.secret.output import SecretGitLabWebUIOutputHandler, SecretOutputHandler
from ggshield.secret.output.messages import remediation_message
from ggshield.secret.repo import scan_commit_range
from ggshield.verticals.secret.output import (
SecretGitLabWebUIOutputHandler,
SecretOutputHandler,
)
from ggshield.verticals.secret.output.messages import remediation_message
from ggshield.verticals.secret.repo import scan_commit_range


logger = logging.getLogger(__name__)
Expand Down
6 changes: 5 additions & 1 deletion ggshield/cmd/secret/scan/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
from ggshield.core.errors import UnexpectedError
from ggshield.scan import Files, ScanContext, ScanMode
from ggshield.scan.file import get_files_from_paths
from ggshield.secret import RichSecretScannerUI, SecretScanCollection, SecretScanner
from ggshield.verticals.secret import (
RichSecretScannerUI,
SecretScanCollection,
SecretScanner,
)


PYPI_DOWNLOAD_TIMEOUT = 30
Expand Down
2 changes: 1 addition & 1 deletion ggshield/cmd/secret/scan/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ggshield.core.errors import handle_exception
from ggshield.core.git_shell import get_list_commit_SHA
from ggshield.scan import ScanContext, ScanMode
from ggshield.secret.repo import scan_commit_range
from ggshield.verticals.secret.repo import scan_commit_range


@click.command()
Expand Down
2 changes: 1 addition & 1 deletion ggshield/cmd/secret/scan/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ggshield.core.git_shell import git
from ggshield.core.utils import REGEX_GIT_URL
from ggshield.scan import ScanContext, ScanMode
from ggshield.secret.repo import scan_repo_path
from ggshield.verticals.secret.repo import scan_repo_path


@click.command()
Expand Down
2 changes: 1 addition & 1 deletion ggshield/cmd/secret/scan/secret_scan_common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ggshield.core.config.user_config import SecretConfig
from ggshield.core.filter import init_exclusion_regexes
from ggshield.core.utils import IGNORED_DEFAULT_WILDCARDS
from ggshield.secret.output import (
from ggshield.verticals.secret.output import (
SecretJSONOutputHandler,
SecretOutputHandler,
SecretTextOutputHandler,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import click

from ggshield.core.errors import ExitCode
from ggshield.secret import SecretScanCollection
from ggshield.verticals.secret import SecretScanCollection


class SecretOutputHandler(ABC):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/unit/cmd/iac/test_scan_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ggshield.cmd.main import cli
from ggshield.core.errors import ExitCode
from ggshield.secret.repo import cd
from ggshield.verticals.secret.repo import cd
from tests.conftest import _IAC_SINGLE_VULNERABILITY
from tests.repository import Repository
from tests.unit.conftest import my_vcr
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cmd/iac/test_scan_prepush.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from click.testing import CliRunner

from ggshield.cmd.main import cli
from ggshield.secret.repo import cd
from ggshield.verticals.secret.repo import cd
from tests.conftest import _IAC_NO_VULNERABILITIES, _IAC_SINGLE_VULNERABILITY
from tests.repository import Repository
from tests.unit.conftest import my_vcr
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cmd/sca/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from ggshield.cmd.main import cli
from ggshield.core.errors import ExitCode
from ggshield.secret.repo import cd
from ggshield.verticals.secret.repo import cd
from tests.unit.conftest import my_vcr


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cmd/sca/test_precommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
SCAVulnerability,
SCAVulnerablePackageVersion,
)
from ggshield.secret.repo import cd
from ggshield.verticals.secret.repo import cd
from tests.repository import Repository
from tests.unit.conftest import my_vcr

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cmd/sca/test_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ggshield.core.errors import ExitCode
from ggshield.sca.client import SCAClient
from ggshield.sca.sca_scan_models import SCAScanAllOutput, SCAScanDiffOutput
from ggshield.secret.repo import cd
from ggshield.verticals.secret.repo import cd
from tests.repository import Repository
from tests.unit.conftest import my_vcr, write_text

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cmd/sca/test_scan_prepush.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ggshield.cmd.main import cli
from ggshield.core.errors import ExitCode
from ggshield.secret.repo import cd
from ggshield.verticals.secret.repo import cd
from tests.repository import Repository
from tests.unit.conftest import my_vcr

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cmd/sca/test_scan_prereceive.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ggshield.cmd.main import cli
from ggshield.core.errors import ExitCode
from ggshield.secret.repo import cd
from ggshield.verticals.secret.repo import cd
from tests.repository import create_pre_receive_repo
from tests.unit.conftest import my_vcr

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/cmd/scan/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from ggshield.cmd.main import cli
from ggshield.core.errors import ExitCode
from ggshield.scan import Files, StringScannable
from ggshield.secret import SecretScanCollection
from ggshield.secret.docker import DockerImage, LayerInfo, _validate_filepath
from ggshield.verticals.secret import SecretScanCollection
from ggshield.verticals.secret.docker import DockerImage, LayerInfo, _validate_filepath
from tests.unit.conftest import (
DOCKER__INCOMPLETE_MANIFEST_EXAMPLE_PATH,
DOCKER_EXAMPLE_PATH,
Expand Down Expand Up @@ -95,7 +95,7 @@ def test_docker_scan_failed_to_save(
assert_invoke_exited_with(result, ExitCode.UNEXPECTED_ERROR)
assert 'Image "ggshield-non-existant" not found' in result.output

@patch("ggshield.secret.docker.DockerImage")
@patch("ggshield.verticals.secret.docker.DockerImage")
@pytest.mark.parametrize(
"image_path", [DOCKER_EXAMPLE_PATH, DOCKER__INCOMPLETE_MANIFEST_EXAMPLE_PATH]
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cmd/scan/test_prepush.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ggshield.core.filter import init_exclusion_regexes
from ggshield.core.utils import EMPTY_SHA, EMPTY_TREE, IGNORED_DEFAULT_WILDCARDS
from ggshield.scan import ScanContext, ScanMode
from ggshield.secret.repo import cd
from ggshield.verticals.secret.repo import cd
from tests.repository import Repository
from tests.unit.conftest import assert_invoke_exited_with, assert_invoke_ok

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/cmd/scan/test_prereceive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from ggshield.core.errors import ExitCode
from ggshield.core.utils import EMPTY_SHA, Filemode
from ggshield.scan import StringScannable
from ggshield.secret import Result, Results, SecretScanCollection
from ggshield.secret.repo import cd
from ggshield.verticals.secret import Result, Results, SecretScanCollection
from ggshield.verticals.secret.repo import cd
from tests.repository import Repository, create_pre_receive_repo
from tests.unit.conftest import (
_SIMPLE_SECRET_PATCH,
Expand Down Expand Up @@ -157,8 +157,8 @@ def test_stdin_breakglass_2ndoption(
in result.output
)

@patch("ggshield.secret.repo.check_client_api_key")
@patch("ggshield.secret.repo.scan_commits_content")
@patch("ggshield.verticals.secret.repo.check_client_api_key")
@patch("ggshield.verticals.secret.repo.scan_commits_content")
def test_stdin_supports_gitlab_web_ui(
self,
scan_commits_content_mock: Mock,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cmd/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ggshield.core.config.user_config import UserConfig
from ggshield.core.config.utils import find_global_config_path
from ggshield.core.errors import ExitCode
from ggshield.secret.repo import cd
from ggshield.verticals.secret.repo import cd

from .utils import add_instance_config

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cmd/test_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ggshield.core.config import Config
from ggshield.core.types import IgnoredMatch
from ggshield.scan import Commit, ScanContext, ScanMode
from ggshield.secret import SecretScanner
from ggshield.verticals.secret import SecretScanner
from tests.unit.conftest import _MULTIPLE_SECRETS_PATCH, my_vcr


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/core/test_git_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
is_valid_git_commit_ref,
tar_from_ref_and_filepaths,
)
from ggshield.secret.repo import cd
from ggshield.verticals.secret.repo import cd
from tests.repository import Repository


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/core/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
)
from ggshield.scan import Commit, Files, ScanContext, ScanMode, StringScannable
from ggshield.scan.scan_context import parse_os_release
from ggshield.secret import SecretScanner
from ggshield.secret.repo import cd
from ggshield.verticals.secret import SecretScanner
from ggshield.verticals.secret.repo import cd
from tests.unit.conftest import (
_PATCH_WITH_NONEWLINE_BEFORE_SECRET,
_SECRET_RAW_FILE,
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from pygitguardian.models import Match, PolicyBreak

from ggshield.scan import StringScannable
from ggshield.secret import Result, Results, SecretScanCollection
from ggshield.secret.output.secret_gitlab_webui_output_handler import (
from ggshield.verticals.secret import Result, Results, SecretScanCollection
from ggshield.verticals.secret.output.secret_gitlab_webui_output_handler import (
SecretGitLabWebUIOutputHandler,
format_policy_break,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@
from ggshield.core.filter import leak_dictionary_by_ignore_sha
from ggshield.core.git_shell import Filemode
from ggshield.scan import Commit, ScanContext, ScanMode, StringScannable
from ggshield.secret import Result, Results, SecretScanCollection, SecretScanner
from ggshield.secret.output import SecretJSONOutputHandler, SecretOutputHandler
from ggshield.secret.output.schemas import JSONScanCollectionSchema
from ggshield.verticals.secret import (
Result,
Results,
SecretScanCollection,
SecretScanner,
)
from ggshield.verticals.secret.output import (
SecretJSONOutputHandler,
SecretOutputHandler,
)
from ggshield.verticals.secret.output.schemas import JSONScanCollectionSchema
from tests.unit.conftest import (
_MULTIPLE_SECRETS_PATCH,
_NO_SECRET_PATCH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
from ggshield.core.filter import leak_dictionary_by_ignore_sha
from ggshield.core.git_shell import Filemode
from ggshield.scan import StringScannable
from ggshield.secret import Result, Results, SecretScanCollection
from ggshield.secret.output import SecretTextOutputHandler
from ggshield.secret.output.secret_text_output_handler import format_line_count_break
from ggshield.verticals.secret import Result, Results, SecretScanCollection
from ggshield.verticals.secret.output import SecretTextOutputHandler
from ggshield.verticals.secret.output.secret_text_output_handler import (
format_line_count_break,
)
from tests.unit.conftest import (
_MULTI_SECRET_ONE_LINE_PATCH,
_MULTI_SECRET_ONE_LINE_PATCH_OVERLAY,
Expand Down Expand Up @@ -111,7 +113,7 @@ def test_leak_message(result_input, snapshot, show_secrets, verbose):
# None until we make an API call. Since this test does not make any API call, set
# the version to a fake value.
with mock.patch(
"ggshield.secret.output.secret_text_output_handler.VERSIONS"
"ggshield.verticals.secret.output.secret_text_output_handler.VERSIONS"
) as VERSIONS:
VERSIONS.secrets_engine_version = "3.14.159"

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from ggshield.core.cache import Cache
from ggshield.scan import Commit, ScanContext, ScanMode
from ggshield.scan.scan_context import get_os_info
from ggshield.secret import SecretScanner
from ggshield.secret.repo import cd
from ggshield.verticals.secret import SecretScanner
from ggshield.verticals.secret.repo import cd
from tests.unit.conftest import UNCHECKED_SECRET_PATCH


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest

from ggshield.core.errors import UnexpectedError
from ggshield.secret.docker import (
from ggshield.verticals.secret.docker import (
DockerImage,
InvalidDockerArchiveException,
LayerInfo,
Expand Down
Loading
Loading