From cf0bfebb360489392089cf2001a355248e8fc9e6 Mon Sep 17 00:00:00 2001 From: Kevin Hock Date: Sat, 11 Jul 2020 16:21:34 -0700 Subject: [PATCH 1/4] :bug: Add missing tuple() conversion That raised a `TypeError` when using `scan --update` Also correct mentions of v0.13.2, which was the wrongly anticipated version, to v0.14.0 Fixes issue #316 --- detect_secrets/core/secrets_collection.py | 4 ++-- tests/core/secrets_collection_test.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/detect_secrets/core/secrets_collection.py b/detect_secrets/core/secrets_collection.py index fafee55e..1388337c 100644 --- a/detect_secrets/core/secrets_collection.py +++ b/detect_secrets/core/secrets_collection.py @@ -115,8 +115,8 @@ def load_baseline_from_dict(cls, data): # The difference will show whenever the word list changes automaton, result.word_list_hash = build_automaton(result.word_list_file) - # In v0.13.2 the `--custom-plugins` option got added - result.custom_plugin_paths = data.get('custom_plugin_paths', ()) + # In v0.14.0 the `--custom-plugins` option got added + result.custom_plugin_paths = tuple(data.get('custom_plugin_paths', ())) plugins = [] for plugin in data['plugins_used']: diff --git a/tests/core/secrets_collection_test.py b/tests/core/secrets_collection_test.py index cda37dee..a530ad16 100644 --- a/tests/core/secrets_collection_test.py +++ b/tests/core/secrets_collection_test.py @@ -293,7 +293,7 @@ def setup(self): def test_output(self, mock_gmtime): assert ( self.logic.format_for_baseline_output() - == self.get_point_thirteen_point_two_and_later_baseline_dict(mock_gmtime) + == self.get_point_fourteen_point_zero_and_later_baseline_dict(mock_gmtime) ) def test_load_baseline_from_string_with_pre_point_twelve_string(self, mock_gmtime): @@ -348,7 +348,7 @@ def test_load_baseline_from_string_with_point_twelve_point_seven_and_later_strin json.dumps(original), ).format_for_baseline_output() - # v0.13.2+ assertions + # v0.14.0+ assertions assert 'custom_plugin_paths' not in original assert secrets['custom_plugin_paths'] == () @@ -387,8 +387,8 @@ def test_load_baseline_without_exclude(self, mock_log): ) assert mock_log.error_messages == 'Incorrectly formatted baseline!\n' - def get_point_thirteen_point_two_and_later_baseline_dict(self, gmtime): - # In v0.13.2 --custom-plugins got added + def get_point_fourteen_point_zero_and_later_baseline_dict(self, gmtime): + # In v0.14.0 --custom-plugins got added baseline = self.get_point_twelve_point_seven_and_later_baseline_dict(gmtime) baseline['custom_plugin_paths'] = () return baseline From ede144e464e5f4196844623dd525f72f17eef996 Mon Sep 17 00:00:00 2001 From: KevinHock Date: Sat, 11 Jul 2020 16:40:32 -0700 Subject: [PATCH 2/4] :mortar_board: Add post-v0.14.0 unreleased changes --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e23b18c2..7c42dfa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,15 @@ If you love `detect-secrets`, please star our project on GitHub to show your sup ### Unreleased --> +### Unreleased + +#### :bug: Bugfixes + +- Add missing `tuple()` conversion that raised a `TypeError` when using `scan --update` ([#317], thanks [@shaikmanu797]) + +[#317]: https://github.com/Yelp/detect-secrets/pull/317 +[@shaikmanu797]: https://github.com/shaikmanu797 + # v0.14.0 ##### July 9th, 2020 From c44bd5f9a187634b123460b58d79e7dc50b0bf69 Mon Sep 17 00:00:00 2001 From: KevinHock Date: Sat, 11 Jul 2020 17:02:18 -0700 Subject: [PATCH 3/4] :mortar_board: Mention latest version in README We forgot to run `scripts/bumpity.py` I realized bumpity is unfortunately brittle. It looks for the current version in the README and replaces it. So if we make this mistake once, bumpity doesn't find the `rev:` line. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b5647f3..40ce7698 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ $ detect-secrets scan > .secrets.baseline ``` $ cat .pre-commit-config.yaml - repo: git@github.com:Yelp/detect-secrets - rev: v0.13.1 + rev: v0.14.0 hooks: - id: detect-secrets args: ['--baseline', '.secrets.baseline'] From 0c80b798996141785c09ee506c710c7c94285143 Mon Sep 17 00:00:00 2001 From: Kevin Hock Date: Sat, 11 Jul 2020 17:31:22 -0700 Subject: [PATCH 4/4] :snake: Use list comprehension inside of tuple() call --- detect_secrets/core/secrets_collection.py | 24 ++++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/detect_secrets/core/secrets_collection.py b/detect_secrets/core/secrets_collection.py index 1388337c..417c87da 100644 --- a/detect_secrets/core/secrets_collection.py +++ b/detect_secrets/core/secrets_collection.py @@ -118,20 +118,16 @@ def load_baseline_from_dict(cls, data): # In v0.14.0 the `--custom-plugins` option got added result.custom_plugin_paths = tuple(data.get('custom_plugin_paths', ())) - plugins = [] - for plugin in data['plugins_used']: - plugin_classname = plugin.pop('name') - plugins.append( - initialize.from_plugin_classname( - plugin_classname, - custom_plugin_paths=result.custom_plugin_paths, - exclude_lines_regex=result.exclude_lines, - automaton=automaton, - should_verify_secrets=False, - **plugin - ), - ) - result.plugins = tuple(plugins) + result.plugins = tuple( + initialize.from_plugin_classname( + plugin_classname=plugin.pop('name'), + custom_plugin_paths=result.custom_plugin_paths, + exclude_lines_regex=result.exclude_lines, + automaton=automaton, + should_verify_secrets=False, + **plugin + ) for plugin in data['plugins_used'] + ) for filename in data['results']: result.data[filename] = {}