Skip to content

Commit

Permalink
Fix disable flags for pre-commit (Yelp#391)
Browse files Browse the repository at this point in the history
* Fix disable flags for pre-commit

Follow up of Yelp#379

* docstrings
  • Loading branch information
justineyster authored and GitHub Enterprise committed Nov 11, 2020
1 parent c2fd155 commit e6e6dc5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
10 changes: 8 additions & 2 deletions detect_secrets/core/secrets_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,23 @@ def __init__(
self.output_verified_false = output_verified_false

@classmethod
def load_baseline_from_string(cls, string):
def load_baseline_from_string(cls, string, plugin_filenames=None):
"""Initializes a SecretsCollection object from string.
:type string: str
:param string: string to load SecretsCollection from.
:type plugin_filenames: tuple
:param plugin_filenames: list of plugins to import
:rtype: SecretsCollection
:raises: IOError
"""
try:
return cls.load_baseline_from_dict(json.loads(string))
return cls.load_baseline_from_dict(
json.loads(string),
plugin_filenames=plugin_filenames,
)
except (IOError, ValueError):
log.error('Incorrectly formatted baseline!')
raise
Expand Down
14 changes: 12 additions & 2 deletions detect_secrets/pre_commit_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ def main(argv=None):
try:
# If baseline is provided, we first want to make sure
# it's valid, before doing any further computation.
baseline_collection = get_baseline(args.baseline[0])
baseline_collection = get_baseline(
args.baseline[0],
plugin_filenames=args.plugin_filenames,
)
except (IOError, TypeError, ValueError):
# Error logs handled within logic.
return 1
Expand Down Expand Up @@ -123,8 +126,14 @@ def main(argv=None):
return 0


def get_baseline(baseline_filename):
def get_baseline(baseline_filename, plugin_filenames=None):
"""
:type baseline_filename: string
:param baseline_filename: name of the baseline file
:type plugin_filenames: tuple
:param plugin_filenames: list of plugins to import
:raises: IOError
:raises: ValueError
"""
Expand All @@ -137,6 +146,7 @@ def get_baseline(baseline_filename):
_get_baseline_string_from_file(
baseline_filename,
),
plugin_filenames=plugin_filenames,
)


Expand Down

0 comments on commit e6e6dc5

Please sign in to comment.