diff --git a/detect_secrets/core/secrets_collection.py b/detect_secrets/core/secrets_collection.py index 147fca165..0a4773f35 100644 --- a/detect_secrets/core/secrets_collection.py +++ b/detect_secrets/core/secrets_collection.py @@ -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 diff --git a/detect_secrets/pre_commit_hook.py b/detect_secrets/pre_commit_hook.py index 39c85f5df..be703dad6 100644 --- a/detect_secrets/pre_commit_hook.py +++ b/detect_secrets/pre_commit_hook.py @@ -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 @@ -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 """ @@ -137,6 +146,7 @@ def get_baseline(baseline_filename): _get_baseline_string_from_file( baseline_filename, ), + plugin_filenames=plugin_filenames, )