Skip to content

Commit

Permalink
↪️ Merge pull request #317 from KevinHock/fix_316_custom_plugins_bug
Browse files Browse the repository at this point in the history
🐛 Fix missing tuple() conversion
  • Loading branch information
OiCMudkips authored Jul 13, 2020
2 parents f988877 + 0c80b79 commit 55f0074
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $ detect-secrets scan > .secrets.baseline
```
$ cat .pre-commit-config.yaml
- repo: [email protected]:Yelp/detect-secrets
rev: v0.13.1
rev: v0.14.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
Expand Down
30 changes: 13 additions & 17 deletions detect_secrets/core/secrets_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,19 @@ 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', ())

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)
# In v0.14.0 the `--custom-plugins` option got added
result.custom_plugin_paths = tuple(data.get('custom_plugin_paths', ()))

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] = {}
Expand Down
8 changes: 4 additions & 4 deletions tests/core/secrets_collection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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'] == ()

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 55f0074

Please sign in to comment.