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

Removing depricated flags --include-paths and --exclude-paths #276

Merged
merged 2 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Features:
* [#244](https://github.com/godaddy/tartufo/pull/244) - Drops support for
`--fetch/--no-fetch` option for local scans

Misc:

* [#255](https://github.com/godaddy/tartufo/issues/255) -- Removed deprecated flags
--include-paths and --exclude-paths

v2.9.0 - 19 October 2021
------------------------

Expand Down
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ Options:
--regex / --no-regex Enable high signal regexes checks.
[default: False]

-i, --include-paths FILENAME [DEPRECATED] Use `--include-path-patterns`.
File with regular expressions (one per
line), at least one of which must match a
Git object path in order for it to be
scanned; lines starting with '#' are treated
as comments and are ignored. If empty or not
provided (default), all Git object paths are
included unless otherwise excluded via the
--exclude-paths option.

-ip, --include-path-patterns TEXT
Specify a regular expression which matches
Git object paths to include in the scan.
Expand All @@ -77,16 +67,6 @@ Options:
included unless otherwise excluded via the
--exclude-path-patterns option.

-x, --exclude-paths FILENAME [DEPRECATED] Use `--exclude-path-patterns`.
File with regular expressions (one per
line), none of which may match a Git object
path in order for it to be scanned; lines
starting with '#' are treated as comments
and are ignored. If empty or not provided
(default), no Git object paths are excluded
unless effectively excluded via the
--include-paths option.

-xp, --exclude-path-patterns TEXT
Specify a regular expression which matches
Git object paths to exclude from the scan.
Expand Down
21 changes: 0 additions & 21 deletions tartufo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ def get_command(self, ctx: click.Context, cmd_name: str) -> Optional[click.Comma
show_default=True,
help="Enable high signal regexes checks.",
)
@click.option(
"-i",
"--include-paths",
type=click.File("r"),
help="""[DEPRECATED] Use `--include-path-patterns`. File with regular
expressions (one per line), at least one of which must match a Git object
path in order for it to be scanned; lines starting with '#' are treated as
comments and are ignored. If empty or not provided (default), all Git object
paths are included unless otherwise excluded via the --exclude-paths
option.""",
)
@click.option(
"-ip",
"--include-path-patterns",
Expand All @@ -102,16 +91,6 @@ def get_command(self, ctx: click.Context, cmd_name: str) -> Optional[click.Comma
included unless otherwise excluded via the --exclude-path-patterns
option.""",
)
@click.option(
"-x",
"--exclude-paths",
type=click.File("r"),
help="""[DEPRECATED] Use `--exclude-path-patterns`. File with regular
expressions (one per line), none of which may match a Git object path in
order for it to be scanned; lines starting with '#' are treated as comments
and are ignored. If empty or not provided (default), no Git object paths are
excluded unless effectively excluded via the --include-paths option.""",
)
@click.option(
"-xp",
"--exclude-path-patterns",
Expand Down
15 changes: 0 additions & 15 deletions tartufo/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
Set,
Tuple,
)
import warnings

import click
import git
Expand Down Expand Up @@ -188,13 +187,6 @@ def included_paths(self) -> List[Pattern]:
if self._included_paths is None:
self.logger.info("Initializing included paths")
patterns = list(self.global_options.include_path_patterns or ())
if self.global_options.include_paths:
warnings.warn(
"--include-paths is deprecated and will be removed in v3.0. Use --include-path-patterns instead.",
DeprecationWarning,
)
patterns += self.global_options.include_paths.readlines()
self.global_options.include_paths.close()
self._included_paths = (
config.compile_path_rules(set(patterns)) if patterns else []
)
Expand Down Expand Up @@ -227,13 +219,6 @@ def excluded_paths(self) -> List[Pattern]:
if self._excluded_paths is None:
self.logger.info("Initializing excluded paths")
patterns = list(self.global_options.exclude_path_patterns or ())
if self.global_options.exclude_paths:
warnings.warn(
"--exclude-paths is deprecated and will be removed in v3.0. Use --exclude-path-patterns instead.",
DeprecationWarning,
)
patterns += self.global_options.exclude_paths.readlines()
self.global_options.exclude_paths.close()
self._excluded_paths = (
config.compile_path_rules(set(patterns)) if patterns else []
)
Expand Down
4 changes: 0 additions & 4 deletions tartufo/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class GlobalOptions:
"default_regexes",
"entropy",
"regex",
"include_paths",
"include_path_patterns",
"exclude_paths",
"exclude_path_patterns",
"exclude_entropy_patterns",
"exclude_signatures",
Expand All @@ -34,9 +32,7 @@ class GlobalOptions:
default_regexes: bool
entropy: bool
regex: bool
include_paths: Optional[TextIO]
include_path_patterns: Tuple[str, ...]
exclude_paths: Optional[TextIO]
exclude_path_patterns: Tuple[str, ...]
exclude_entropy_patterns: Tuple[str, ...]
exclude_signatures: Tuple[str, ...]
Expand Down
10 changes: 2 additions & 8 deletions tests/test_base_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,10 @@ def test_included_paths_is_empty_if_not_specified(self):
def test_include_paths_are_calculated_if_specified(
self, mock_compile: mock.MagicMock
):
mock_include = mock.MagicMock()
mock_include.readlines.return_value = ["bar"]
self.options.include_paths = mock_include
self.options.include_path_patterns = ("foo",)
test_scanner = TestScanner(self.options)
test_scanner.included_paths # pylint: disable=pointless-statement
mock_compile.assert_called_once_with({"foo", "bar"})
mock_compile.assert_called_once_with({"foo"})

@mock.patch("tartufo.config.compile_path_rules")
def test_populated_excluded_paths_list_does_not_recompute(
Expand All @@ -208,13 +205,10 @@ def test_excluded_paths_is_empty_if_not_specified(self):
def test_exclude_paths_are_calculated_if_specified(
self, mock_compile: mock.MagicMock
):
mock_exclude = mock.MagicMock()
mock_exclude.readlines.return_value = ["Pipfile.lock\n"]
self.options.exclude_paths = mock_exclude
self.options.exclude_path_patterns = ("foo",)
test_scanner = TestScanner(self.options)
test_scanner.excluded_paths # pylint: disable=pointless-statement
mock_compile.assert_called_once_with({"foo", "Pipfile.lock\n"})
mock_compile.assert_called_once_with({"foo"})

def test_should_scan_treats_included_paths_as_exclusive(self):
test_scanner = TestScanner(self.options)
Expand Down