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

Exclusion reasons #286

Merged
merged 7 commits into from
Nov 29, 2021
Merged

Exclusion reasons #286

merged 7 commits into from
Nov 29, 2021

Conversation

mayuriesha
Copy link
Contributor

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

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

closes #202

What's new?

  • Supports new format of exclusions in config file with the ability to specify the reason along with exclusion

signatures = self.config_data.get("exclude_signatures", None)
if signatures:
warnings.warn(
"--exclude-signatures will be deprecated. Make sure all the exclusions are moved to "
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
"--exclude-signatures will be deprecated. Make sure all the exclusions are moved to "
"--exclude-signatures has been deprecated and will be removed in a future version. Make sure all the exclusions are moved to "

tartufo/scanner.py Outdated Show resolved Hide resolved
tests/test_git_repo_scanner.py Show resolved Hide resolved
@@ -149,6 +150,8 @@ class ScannerBase(abc.ABC): # pylint: disable=too-many-instance-attributes
global_options: types.GlobalOptions
logger: logging.Logger
_scan_lock: threading.Lock = threading.Lock()
_excluded_findings: tuple = ()
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
_excluded_findings: tuple = ()
_excluded_findings: Tuple[str, ...] = ()

Comment on lines 347 to 349
def config_data(self, data) -> MutableMapping[str, Any]:
self._config_data = data
return self._config_data
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 config_data(self, data) -> MutableMapping[str, Any]:
self._config_data = data
return self._config_data
def config_data(self, data: MutableMapping[str, Any]) -> None:
self._config_data = data

Returning data from a setter in Python is generally not a valuable operation, because there's no way to access it. You would need something like...

new_data = scanner.config_data = data

Which is just confusing. And probably won't even work the way you expect.

You can find a bit more of an explanation here, if you're interested: https://stackoverflow.com/a/16615910

Copy link
Contributor

@tarkatronic tarkatronic left a comment

Choose a reason for hiding this comment

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

This is great @mayuriesha, thank you!

As we have continued talking about this feature, and #257, I can't help but wonder if I was wrong in thinking we should allow both old-style and new-style config to exist side-by-side. The more I think about it, the more I think I was wrong. We're already forcing so much config change and churn on our users, why force them to learn new names for the config entries as well, especially names that might not make as much sense?

I hate to suggest a change to this so late. But I wonder if this, and #257, are cases where we should operate similar to what we did with exclude-entropy-patterns in 2.x. Either you use all old-style config, or all new-style config. I am honestly open to going either direction, so I'd love some more thoughts on it! And of course we can always merge this PR as-is, to get it checked off, and update it in the future if we decide to go the other way!

Thank you again for the hard work @mayuriesha!

@mayuriesha mayuriesha merged commit 06a3833 into godaddy:v3.x Nov 29, 2021
@tarkatronic tarkatronic linked an issue Dec 1, 2021 that may be closed by this pull request
@tarkatronic tarkatronic mentioned this pull request Dec 1, 2021
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.

Exclusion Reasons
2 participants