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

Remove deprecated code #433

Merged
merged 5 commits into from
Jan 13, 2023
Merged

Remove deprecated code #433

merged 5 commits into from
Jan 13, 2023

Conversation

emayuri-godaddy
Copy link
Contributor

@emayuri-godaddy emayuri-godaddy commented Jan 13, 2023

To help us get this pull request reviewed and merged quickly, please be sure to include the following items:

  • Tests (if applicable)
  • Documentation (if applicable)
  • Changelog entry
  • A full explanation here in the PR description of the work done

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other - Removing deprecated code

Backward Compatibility

Is this change backward compatible with the most recently released version? Does it introduce changes which might change the user experience in any way? Does it alter the API in any way?

  • Yes (backward compatible)
  • No (breaking changes)

Issue Linking

What's new?

  • Removed deprecated flags rules, b64 and hex, and corresponding code around deprecated options.

Copy link
Contributor

@rbailey-godaddy rbailey-godaddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits.

Mostly, beef up the changelog entry for people who have forgotten what things we dropped... The rest is complaints about the way you specified tuples in various test methods. Just specify the tuples like before, but with dict members instead of str members:

my_tuple = ({"my": "dict"},)

CHANGELOG.md Outdated
@@ -2,6 +2,8 @@ vX.X.X - DD MMM YYYY
--------------------

Features:
* [#433](https://github.com/godaddy/tartufo/pull/433) - Dropped support for deprecated flags from v3.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this context, and in the interest of visibility, I would explicitly list the removed flags here again... for people who only read the CHANGELOG and not the error messages. ;-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Comment on lines 198 to 200
self.options.include_path_patterns = tuple(
[{"path-pattern": "foo", "reason": "Testing exclude path pattern"}]
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works but I had to read it 3 times and then try it myself to convince myself it did what was needed. How about:

Suggested change
self.options.include_path_patterns = tuple(
[{"path-pattern": "foo", "reason": "Testing exclude path pattern"}]
)
self.options.include_path_patterns = (
{"path-pattern": "foo", "reason": "Testing exclude path pattern"},
)

Comment on lines 222 to 224
self.options.exclude_path_patterns = tuple(
[{"path-pattern": "foo", "reason": "Testing exclude path pattern"}]
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto above. The only reason I comment is that it isn't obvious to the casual reader that you're getting a tuple consisting of a single dict vs a tuple consisting of a single list

Comment on lines 292 to 294
self.options.exclude_signatures = tuple(
[{"signature": "foo", "reason": "Testing exclude signature"}]
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and again

Comment on lines 303 to 305
self.options.exclude_signatures = tuple(
[{"signature": "foo", "reason": "Testing exclude signature"}]
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again

Comment on lines 79 to 80
self.global_options.include_path_patterns = tuple(
[{"path-pattern": "foo/", "reason": "Inclusion reason"}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.global_options.include_path_patterns = tuple(
[{"path-pattern": "foo/", "reason": "Inclusion reason"}]
self.global_options.include_path_patterns = (
{"path-pattern": "foo/", "reason": "Inclusion reason"},

tests/test_git_repo_scanner.py Outdated Show resolved Hide resolved
Comment on lines 104 to 105
self.global_options.exclude_path_patterns = tuple(
[{"path-pattern": "bar/", "reason": "Exclusion reason"}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.global_options.exclude_path_patterns = tuple(
[{"path-pattern": "bar/", "reason": "Exclusion reason"}]
self.global_options.exclude_path_patterns = (
{"path-pattern": "bar/", "reason": "Exclusion reason"},

tests/test_git_repo_scanner.py Show resolved Hide resolved
Comment on lines 132 to 133
self.global_options.exclude_signatures = tuple(
[{"signature": "bar", "reason": "Reason to exclude signature"}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.global_options.exclude_signatures = tuple(
[{"signature": "bar", "reason": "Reason to exclude signature"}]
self.global_options.exclude_signatures = (
{"signature": "bar", "reason": "Reason to exclude signature"},

Copy link
Contributor

@sushantmimani sushantmimani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed these:

tartufo/tartufo/config.py

Lines 190 to 194 in 7f3f026

warnings.warn(
"Storing rules in a separate file is deprecated and will be removed "
"in tartufo 4.x. Please use the 'rule-patterns' config "
" option instead.",
DeprecationWarning,

tartufo/tartufo/scanner.py

Lines 606 to 610 in 7f3f026

warnings.warn(
f"Signature {old_signature} was generated by an old version of tartufo and is deprecated. "
"tartufo 4.x will not recognize this signature. "
f"Please update your configuration to use signature {new_signature} instead.",
DeprecationWarning,

@emayuri-godaddy
Copy link
Contributor Author

You missed these:

tartufo/tartufo/config.py

Lines 190 to 194 in 7f3f026

warnings.warn(
"Storing rules in a separate file is deprecated and will be removed "
"in tartufo 4.x. Please use the 'rule-patterns' config "
" option instead.",
DeprecationWarning,

tartufo/tartufo/scanner.py

Lines 606 to 610 in 7f3f026

warnings.warn(
f"Signature {old_signature} was generated by an old version of tartufo and is deprecated. "
"tartufo 4.x will not recognize this signature. "
f"Please update your configuration to use signature {new_signature} instead.",
DeprecationWarning,

Working on addressing second comment here

test_scanner = scanner.GitRepoScanner(
self.global_options, self.git_options, "."
)
self.assertEqual(test_scanner.excluded_signatures, ("bar/",))

def test_error_is_not_raised_when_two_styles_signatures_are_configured(self):
def test_error_is_raised_when_two_styles_signatures_are_configured(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_error_is_raised_when_two_styles_signatures_are_configured(self):
def test_error_is_raised_when_string_signature_is_used(self):

test_scanner = scanner.GitRepoScanner(
self.global_options, self.git_options, "."
)
self.assertEqual(test_scanner.included_paths, [re.compile("bar/")])

def test_error_is_not_raised_when_two_styles_included_paths_are_configured(self):
def test_error_is_raised_when_two_styles_included_paths_are_configured(self):
Copy link
Contributor

@dclayton-godaddy dclayton-godaddy Jan 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_error_is_raised_when_two_styles_included_paths_are_configured(self):
def test_error_is_raised_when_string_included_path_is_used(self):

test_scanner = scanner.GitRepoScanner(
self.global_options, self.git_options, "."
)
self.assertEqual(test_scanner.excluded_paths, [re.compile("bar/")])

@mock.patch("tartufo.scanner.GitScanner.filter_submodules", mock.MagicMock())
def test_error_is_not_raised_when_two_styles_excluded_paths_are_configured(self):
def test_error_is_raised_when_two_styles_excluded_paths_are_configured(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_error_is_raised_when_two_styles_excluded_paths_are_configured(self):
def test_error_is_raised_when_string_exclude_path_is_used(self):

self.global_options.exclude_signatures = [
"foo/",
{"signature": "bar/", "reason": "path pattern"},
]
test_scanner = scanner.GitRepoScanner(
self.global_options, self.git_options, "."
)
self.assertCountEqual(test_scanner.excluded_signatures, ("foo/", "bar/"))
with self.assertRaisesRegex(
ConfigException, "signature is illegal in exclude-signatures"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ConfigException, "signature is illegal in exclude-signatures"
ConfigException, "str signature is illegal in exclude-signatures"


def evaluate_entropy_string(
self,
chunk: types.Chunk,
line: str,
string: str,
min_entropy_score: float,
backwards_compatibility_prefix: Optional[str],
Copy link
Contributor

@sushantmimani sushantmimani Jan 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring and documentation should be updated

Copy link
Contributor

@dclayton-godaddy dclayton-godaddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few suggestions. Otherwise looks good.

@emayuri-godaddy emayuri-godaddy merged commit 24976f1 into main Jan 13, 2023
@emayuri-godaddy emayuri-godaddy deleted the tartufo_v4_prep branch January 13, 2023 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants