diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0edc85b08..9c25eaae3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,15 +2,17 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.1.0 hooks: - - id: trailing-whitespace - - id: end-of-file-fixer + - id: check-builtin-literals + args: ['--no-allow-dict-kwargs'] - id: check-docstring-first - id: debug-statements + - id: double-quote-string-fixer + - id: end-of-file-fixer - id: name-tests-test - exclude: tests/util - id: flake8 args: ['--max-line-length', '100'] exclude: ^test_data/ + - id: trailing-whitespace - repo: https://github.com/asottile/reorder_python_imports rev: v1.3.4 hooks: diff --git a/detect_secrets/core/audit.py b/detect_secrets/core/audit.py index 7d3498736..81e09754d 100644 --- a/detect_secrets/core/audit.py +++ b/detect_secrets/core/audit.py @@ -23,8 +23,8 @@ class SecretNotFoundOnSpecifiedLineError(Exception): def __init__(self, line): super(SecretNotFoundOnSpecifiedLineError, self).__init__( - "ERROR: Secret not found on line {}!\n".format(line) + - "Try recreating your baseline to fix this issue.", + 'ERROR: Secret not found on line {}!\n'.format(line) + + 'Try recreating your baseline to fix this issue.', ) diff --git a/detect_secrets/core/baseline.py b/detect_secrets/core/baseline.py index 9afc4e671..16f3b29a2 100644 --- a/detect_secrets/core/baseline.py +++ b/detect_secrets/core/baseline.py @@ -51,7 +51,7 @@ def initialize( elif os.path.isfile(element): files_to_scan.append(element) else: - log.error("detect-secrets: " + element + ": No such file or directory") + log.error('detect-secrets: ' + element + ': No such file or directory') if not files_to_scan: return output @@ -215,7 +215,7 @@ def merge_results(old_results, new_results): if filename not in new_results: continue - old_secrets_mapping = dict() + old_secrets_mapping = {} for old_secret in old_secrets: old_secrets_mapping[old_secret['hashed_secret']] = old_secret diff --git a/detect_secrets/core/potential_secret.py b/detect_secrets/core/potential_secret.py index a48d33ea6..97c7a4176 100644 --- a/detect_secrets/core/potential_secret.py +++ b/detect_secrets/core/potential_secret.py @@ -95,8 +95,8 @@ def __hash__(self): def __str__(self): # pragma: no cover return ( - "Secret Type: %s\n" - "Location: %s:%d\n" + 'Secret Type: %s\n' + 'Location: %s:%d\n' ) % ( self.type, self.filename, self.lineno, diff --git a/detect_secrets/core/secrets_collection.py b/detect_secrets/core/secrets_collection.py index 99972aed6..b661ea4b7 100644 --- a/detect_secrets/core/secrets_collection.py +++ b/detect_secrets/core/secrets_collection.py @@ -209,7 +209,7 @@ def scan_file(self, filename, filename_key=None): return True except IOError: - log.warning("Unable to open file: %s", filename) + log.warning('Unable to open file: %s', filename) return False def get_secret(self, filename, secret, type_=None): @@ -263,7 +263,7 @@ def format_for_baseline_output(self): plugins_used = sorted(plugins_used, key=lambda x: x['name']) return { - 'generated_at': strftime("%Y-%m-%dT%H:%M:%SZ", gmtime()), + 'generated_at': strftime('%Y-%m-%dT%H:%M:%SZ', gmtime()), 'exclude': { 'files': self.exclude_files, 'lines': self.exclude_lines, @@ -302,14 +302,14 @@ def _extract_secrets_from_file(self, f, filename): :type filename: string """ try: - log.info("Checking file: %s", filename) + log.info('Checking file: %s', filename) for results, plugin in self._results_accumulator(filename): results.update(plugin.analyze(f, filename)) f.seek(0) except UnicodeDecodeError: - log.warning("%s failed to load.", filename) + log.warning('%s failed to load.', filename) def _extract_secrets_from_patch(self, f, plugin, filename): """Extract secrets from a given patch file object. diff --git a/detect_secrets/main.py b/detect_secrets/main.py index e608c2261..022636a6c 100644 --- a/detect_secrets/main.py +++ b/detect_secrets/main.py @@ -83,7 +83,7 @@ def main(argv=None): def _get_plugin_from_baseline(old_baseline): plugins = [] - if old_baseline and "plugins_used" in old_baseline: + if old_baseline and 'plugins_used' in old_baseline: secrets_collection = SecretsCollection.load_baseline_from_dict(old_baseline) plugins = secrets_collection.plugins return plugins diff --git a/detect_secrets/plugins/common/initialize.py b/detect_secrets/plugins/common/initialize.py index 85af4972b..0035c653b 100644 --- a/detect_secrets/plugins/common/initialize.py +++ b/detect_secrets/plugins/common/initialize.py @@ -76,7 +76,7 @@ def _remove_key(d, key): return r baseline_plugins_dict = { - vars(plugin)["name"]: _remove_key(vars(plugin), "name") + vars(plugin)['name']: _remove_key(vars(plugin), 'name') for plugin in baseline_plugins } @@ -124,7 +124,7 @@ def _remove_key(d, key): except KeyError: log.warning( '%s specified, but %s not configured! Ignoring...' - % ("".join(["--", param_name.replace("_", "-")]), plugin_name), + % (''.join(['--', param_name.replace('_', '-')]), plugin_name), ) return from_parser_builder( diff --git a/setup.py b/setup.py index 2693f592e..991fd4d93 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ long_description=( 'Check out detect-secrets on `GitHub `_!' ), - license="Copyright Yelp, Inc. 2018", + license='Copyright Yelp, Inc. 2018', author='Aaron Loo', author_email='aaronloo@yelp.com', url='https://github.com/Yelp/detect-secrets', @@ -36,14 +36,14 @@ ], }, classifiers=[ - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 3", - "License :: OSI Approved :: Apache Software License", - "Intended Audience :: Developers", - "Topic :: Software Development", - "Topic :: Utilities", - "Environment :: Console", - "Operating System :: OS Independent", - "Development Status :: 5 - Production/Stable", + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', + 'License :: OSI Approved :: Apache Software License', + 'Intended Audience :: Developers', + 'Topic :: Software Development', + 'Topic :: Utilities', + 'Environment :: Console', + 'Operating System :: OS Independent', + 'Development Status :: 5 - Production/Stable', ], ) diff --git a/test_data/files/file_with_no_secrets.py b/test_data/files/file_with_no_secrets.py index 9f7372a8c..cd52a0d73 100644 --- a/test_data/files/file_with_no_secrets.py +++ b/test_data/files/file_with_no_secrets.py @@ -1,5 +1,5 @@ #!/usr/bin/python -REGULAR_VALUE = "this is just a long string, like a user facing error message" +REGULAR_VALUE = 'this is just a long string, like a user facing error message' def main(): diff --git a/test_data/files/tmp/file_with_no_secrets.py b/test_data/files/tmp/file_with_no_secrets.py index ea832f442..5c62f326a 100644 --- a/test_data/files/tmp/file_with_no_secrets.py +++ b/test_data/files/tmp/file_with_no_secrets.py @@ -1,6 +1,6 @@ #!/usr/bin/python # Will change this later. -SUPER_SECRET_VALUE = "this is just a long string, like a user facing error message" +SUPER_SECRET_VALUE = 'this is just a long string, like a user facing error message' def main(): diff --git a/tests/core/audit_test.py b/tests/core/audit_test.py index c0b3b0430..bf9f8d392 100644 --- a/tests/core/audit_test.py +++ b/tests/core/audit_test.py @@ -692,14 +692,14 @@ def test_unicode_in_output(self, mock_printer): self.run_logic( secret=potential_secret_factory( type_='Base64 High Entropy String', - filename="test_data/config.md", + filename='test_data/config.md', secret='ToCynx5Se4e2PtoZxEhW7lUJcOX15c54', lineno=10, ).json(), settings=[ { - "base64_limit": 4.5, - "name": "Base64HighEntropyString", + 'base64_limit': 4.5, + 'name': 'Base64HighEntropyString', }, ], ) diff --git a/tests/core/baseline_test.py b/tests/core/baseline_test.py index 276306d6f..1793b80db 100644 --- a/tests/core/baseline_test.py +++ b/tests/core/baseline_test.py @@ -453,7 +453,7 @@ def test_new_results_has_nothing(self): def test_old_results_have_diff_type_will_carry_over(self): secretA = self.get_secret() - secretA["type"] = "different type" + secretA['type'] = 'different type' secretB = self.get_secret() assert merge_results( diff --git a/tests/main_test.py b/tests/main_test.py index 00beb56dd..8b80f0a71 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -210,217 +210,217 @@ def test_old_baseline_ignored_with_update_flag( ( # remove some plugins from baseline [ { - "base64_limit": 4.5, - "name": "Base64HighEntropyString", + 'base64_limit': 4.5, + 'name': 'Base64HighEntropyString', }, { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, ], '--no-base64-string-scan --no-keyword-scan', [ { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, ], ), ( # all plugins [ { - "base64_limit": 1.5, - "name": "Base64HighEntropyString", + 'base64_limit': 1.5, + 'name': 'Base64HighEntropyString', }, ], '--use-all-plugins', [ { - "name": "AWSKeyDetector", + 'name': 'AWSKeyDetector', }, { - "name": "ArtifactoryDetector", + 'name': 'ArtifactoryDetector', }, { - "base64_limit": 1.5, - "name": "Base64HighEntropyString", + 'base64_limit': 1.5, + 'name': 'Base64HighEntropyString', }, { - "name": "BasicAuthDetector", + 'name': 'BasicAuthDetector', }, { - "hex_limit": 3, - "name": "HexHighEntropyString", + 'hex_limit': 3, + 'name': 'HexHighEntropyString', }, { - "name": "KeywordDetector", + 'name': 'KeywordDetector', }, { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, { - "name": "SlackDetector", + 'name': 'SlackDetector', }, { - "name": "StripeDetector", + 'name': 'StripeDetector', }, ], ), ( # remove some plugins from all plugins [ { - "base64_limit": 4.5, - "name": "Base64HighEntropyString", + 'base64_limit': 4.5, + 'name': 'Base64HighEntropyString', }, ], '--use-all-plugins --no-base64-string-scan --no-private-key-scan', [ { - "name": "AWSKeyDetector", + 'name': 'AWSKeyDetector', }, { - "name": "ArtifactoryDetector", + 'name': 'ArtifactoryDetector', }, { - "name": "BasicAuthDetector", + 'name': 'BasicAuthDetector', }, { - "hex_limit": 3, - "name": "HexHighEntropyString", + 'hex_limit': 3, + 'name': 'HexHighEntropyString', }, { - "name": "KeywordDetector", + 'name': 'KeywordDetector', }, { - "name": "SlackDetector", + 'name': 'SlackDetector', }, { - "name": "StripeDetector", + 'name': 'StripeDetector', }, ], ), ( # use same plugin list from baseline [ { - "base64_limit": 3.5, - "name": "Base64HighEntropyString", + 'base64_limit': 3.5, + 'name': 'Base64HighEntropyString', }, { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, ], '', [ { - "base64_limit": 3.5, - "name": "Base64HighEntropyString", + 'base64_limit': 3.5, + 'name': 'Base64HighEntropyString', }, { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, ], ), ( # overwrite base limit from CLI [ { - "base64_limit": 3.5, - "name": "Base64HighEntropyString", + 'base64_limit': 3.5, + 'name': 'Base64HighEntropyString', }, { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, ], '--base64-limit=5.5', [ { - "base64_limit": 5.5, - "name": "Base64HighEntropyString", + 'base64_limit': 5.5, + 'name': 'Base64HighEntropyString', }, { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, ], ), ( # does not overwrite base limit from CLI if baseline not using the plugin [ { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, ], '--base64-limit=4.5', [ { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, ], ), ( # use overwriten option from CLI only when using --use-all-plugins [ { - "base64_limit": 3.5, - "name": "Base64HighEntropyString", + 'base64_limit': 3.5, + 'name': 'Base64HighEntropyString', }, { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, ], '--use-all-plugins --base64-limit=5.5 --no-hex-string-scan --no-keyword-scan', [ { - "name": "AWSKeyDetector", + 'name': 'AWSKeyDetector', }, { - "name": "ArtifactoryDetector", + 'name': 'ArtifactoryDetector', }, { - "base64_limit": 5.5, - "name": "Base64HighEntropyString", + 'base64_limit': 5.5, + 'name': 'Base64HighEntropyString', }, { - "name": "BasicAuthDetector", + 'name': 'BasicAuthDetector', }, { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, { - "name": "SlackDetector", + 'name': 'SlackDetector', }, { - "name": "StripeDetector", + 'name': 'StripeDetector', }, ], ), ( # use plugin limit from baseline when using --use-all-plugins and no input limit [ { - "base64_limit": 2.5, - "name": "Base64HighEntropyString", + 'base64_limit': 2.5, + 'name': 'Base64HighEntropyString', }, { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, ], '--use-all-plugins --no-hex-string-scan --no-keyword-scan', [ { - "name": "AWSKeyDetector", + 'name': 'AWSKeyDetector', }, { - "name": "ArtifactoryDetector", + 'name': 'ArtifactoryDetector', }, { - "base64_limit": 2.5, - "name": "Base64HighEntropyString", + 'base64_limit': 2.5, + 'name': 'Base64HighEntropyString', }, { - "name": "BasicAuthDetector", + 'name': 'BasicAuthDetector', }, { - "name": "PrivateKeyDetector", + 'name': 'PrivateKeyDetector', }, { - "name": "SlackDetector", + 'name': 'SlackDetector', }, { - "name": "StripeDetector", + 'name': 'StripeDetector', }, ], ), @@ -434,10 +434,10 @@ def test_plugin_from_old_baseline_respected_with_update_flag( with mock_stdin(), mock.patch( 'detect_secrets.main._read_from_file', return_value={ - "plugins_used": plugins_used, - "results": {}, - "version": VERSION, - "exclude": { + 'plugins_used': plugins_used, + 'results': {}, + 'version': VERSION, + 'exclude': { 'files': '', 'lines': '', }, diff --git a/tests/plugins/high_entropy_strings_test.py b/tests/plugins/high_entropy_strings_test.py index 6861f13e6..6ec8f1fc1 100644 --- a/tests/plugins/high_entropy_strings_test.py +++ b/tests/plugins/high_entropy_strings_test.py @@ -53,7 +53,7 @@ def setup(self, logic, non_secret_string, secret_string): ), # Matches exclude_lines_regex ( - "CanonicalUser: {secret}", + 'CanonicalUser: {secret}', False, ), ], @@ -121,7 +121,7 @@ def test_analyze_multiple_strings_same_line(self, content_to_format, expected_re # Test high entropy exclude regex '"CanonicalUser": "{secret}"', # Not a string - "{secret}", + '{secret}', ], ) def test_ignored_lines(self, content_to_format): diff --git a/tests/plugins/keyword_test.py b/tests/plugins/keyword_test.py index ac2062074..a7f2759cf 100644 --- a/tests/plugins/keyword_test.py +++ b/tests/plugins/keyword_test.py @@ -14,24 +14,24 @@ '.py', ) FOLLOWED_BY_COLON_RE = { - "negatives": { - "quotes_required": [ + 'negatives': { + 'quotes_required': [ 'theapikey: ""', # Nothing in the quotes 'theapikey: "somefakekey"', # 'fake' in the secret ], - "quotes_not_required": [ + 'quotes_not_required': [ 'theapikeyforfoo:hopenobodyfindsthisone', # Characters between apikey and : 'password: ${link}', # Has a ${ followed by a } ], }, - "positives": { - "quotes_required": [ + 'positives': { + 'quotes_required': [ "'theapikey': '{{h}o)p${e]nob(ody[finds>-_$#thisone}}'", '"theapikey": "{{h}o)p${e]nob(ody[finds>-_$#thisone}}"', 'apikey: "{{h}o)p${e]nob(ody[finds>-_$#thisone}}"', "apikey: '{{h}o)p${e]nob(ody[finds>-_$#thisone}}'", ], - "quotes_not_required": [ + 'quotes_not_required': [ 'apikey: {{h}o)p${e]nob(ody[finds>-_$#thisone}}', 'apikey:{{h}o)p${e]nob(ody[finds>-_$#thisone}}', 'theapikey:{{h}o)p${e]nob(ody[finds>-_$#thisone}}', @@ -39,8 +39,8 @@ }, } FOLLOWED_BY_EQUAL_SIGNS_RE = { - "negatives": { - "quotes_required": [ + 'negatives': { + 'quotes_required': [ 'some_key = "real_secret"', # We cannot make 'key' a Keyword, too noisy 'my_password = ""', # Nothing in the quotes "my_password = ''", # Nothing in the quotes @@ -48,20 +48,20 @@ 'open(self, password = ""):', # secrets is ""): 'open(self, password = ""):', # secrets is ""): ], - "quotes_not_required": [ + 'quotes_not_required': [ 'my_password = foo(hey)you', # Has a ( followed by a ) "my_password = request.json_body['hey']", # Has a [ followed by a ] 'my_password = True', # 'True' is a known false-positive 'login(username=username, password=password)', # secret is password) ], }, - "positives": { - "quotes_required": [ + 'positives': { + 'quotes_required': [ 'some_dict["secret"] = "{{h}o)p${e]nob(ody[finds>-_$#thisone}}"', 'the_password= "{{h}o)p${e]nob(ody[finds>-_$#thisone}}"\n', 'the_password=\'{{h}o)p${e]nob(ody[finds>-_$#thisone}}\'\n', ], - "quotes_not_required": [ + 'quotes_not_required': [ "some_dict['secret'] = {{h}o)p${e]nob(ody[finds>-_$#thisone}}", 'my_password={{h}o)p${e]nob(ody[finds>-_$#thisone}}', 'my_password= {{h}o)p${e]nob(ody[finds>-_$#thisone}}', @@ -73,8 +73,8 @@ }, } FOLLOWED_BY_QUOTES_AND_SEMICOLON_RE = { - "negatives": { - "quotes_required": [ + 'negatives': { + 'quotes_required': [ 'private_key "";', # Nothing in the quotes 'private_key \'"no spaces\';', # Has whitespace in the secret 'private_key "fake";', # 'fake' in the secret @@ -82,8 +82,8 @@ 'private_key \'hopenobodyfindsthisone";', # Single-quote does not match double-quote ], }, - "positives": { - "quotes_required": [ + 'positives': { + 'quotes_required': [ 'apikey "{{h}o)p${e]nob(ody[finds>-_$#thisone}}";', # Double-quotes 'fooapikeyfoo "{{h}o)p${e]nob(ody[finds>-_$#thisone}}";', # Double-quotes 'fooapikeyfoo"{{h}o)p${e]nob(ody[finds>-_$#thisone}}";', # Double-quotes @@ -94,17 +94,17 @@ }, } FOLLOWED_BY_COLON_EQUAL_SIGNS_RE = { - "negatives": { - "quotes_required": [ + 'negatives': { + 'quotes_required': [ 'theapikey := ""', # Nothing in the quotes 'theapikey := "somefakekey"', # 'fake' in the secret ], - "quotes_not_required": [ + 'quotes_not_required': [ 'theapikeyforfoo := hopenobodyfindsthisone', # Characters between apikey and := ], }, - "positives": { - "quotes_required": [ + 'positives': { + 'quotes_required': [ 'apikey := "{{h}o)p${e]nob(ody[finds>-_$#thisone}}"', 'apikey :="{{h}o)p${e]nob(ody[finds>-_$#thisone}}"', 'apikey := "{{h}o)p${e]nob(ody[finds>-_$#thisone}}"', @@ -116,11 +116,11 @@ "apikey:='{{h}o)p${e]nob(ody[finds>-_$#thisone}}'", "apikey:= '{{h}o)p${e]nob(ody[finds>-_$#thisone}}'", ], - "quotes_not_required": [ - "apikey := {{h}o)p${e]nob(ody[finds>-_$#thisone}}", - "apikey :={{h}o)p${e]nob(ody[finds>-_$#thisone}}", - "apikey:= {{h}o)p${e]nob(ody[finds>-_$#thisone}}", - "apikey:={{h}o)p${e]nob(ody[finds>-_$#thisone}}", + 'quotes_not_required': [ + 'apikey := {{h}o)p${e]nob(ody[finds>-_$#thisone}}', + 'apikey :={{h}o)p${e]nob(ody[finds>-_$#thisone}}', + 'apikey:= {{h}o)p${e]nob(ody[finds>-_$#thisone}}', + 'apikey:={{h}o)p${e]nob(ody[finds>-_$#thisone}}', ], }, } @@ -129,20 +129,20 @@ STANDARD_POSITIVES = [] STANDARD_NEGATIVES.extend( - FOLLOWED_BY_COLON_RE.get("negatives").get("quotes_required") - + FOLLOWED_BY_COLON_RE.get("negatives").get("quotes_not_required") - + FOLLOWED_BY_EQUAL_SIGNS_RE.get("negatives").get("quotes_required") - + FOLLOWED_BY_EQUAL_SIGNS_RE.get("negatives").get("quotes_not_required") - + FOLLOWED_BY_QUOTES_AND_SEMICOLON_RE.get("negatives").get("quotes_required") - + FOLLOWED_BY_COLON_EQUAL_SIGNS_RE.get("negatives").get("quotes_required") - + FOLLOWED_BY_COLON_EQUAL_SIGNS_RE.get("negatives").get("quotes_not_required"), + FOLLOWED_BY_COLON_RE.get('negatives').get('quotes_required') + + FOLLOWED_BY_COLON_RE.get('negatives').get('quotes_not_required') + + FOLLOWED_BY_EQUAL_SIGNS_RE.get('negatives').get('quotes_required') + + FOLLOWED_BY_EQUAL_SIGNS_RE.get('negatives').get('quotes_not_required') + + FOLLOWED_BY_QUOTES_AND_SEMICOLON_RE.get('negatives').get('quotes_required') + + FOLLOWED_BY_COLON_EQUAL_SIGNS_RE.get('negatives').get('quotes_required') + + FOLLOWED_BY_COLON_EQUAL_SIGNS_RE.get('negatives').get('quotes_not_required'), ) STANDARD_POSITIVES.extend( - FOLLOWED_BY_COLON_RE.get("positives").get("quotes_required") - + FOLLOWED_BY_COLON_RE.get("positives").get("quotes_not_required") - + FOLLOWED_BY_EQUAL_SIGNS_RE.get("positives").get("quotes_required") - + FOLLOWED_BY_EQUAL_SIGNS_RE.get("positives").get("quotes_not_required") - + FOLLOWED_BY_QUOTES_AND_SEMICOLON_RE.get("positives").get("quotes_required"), + FOLLOWED_BY_COLON_RE.get('positives').get('quotes_required') + + FOLLOWED_BY_COLON_RE.get('positives').get('quotes_not_required') + + FOLLOWED_BY_EQUAL_SIGNS_RE.get('positives').get('quotes_required') + + FOLLOWED_BY_EQUAL_SIGNS_RE.get('positives').get('quotes_not_required') + + FOLLOWED_BY_QUOTES_AND_SEMICOLON_RE.get('positives').get('quotes_required'), ) @@ -181,9 +181,9 @@ def test_analyze_with_line_exclude(self, file_content): ( (positive, file_extension) for positive in ( - FOLLOWED_BY_COLON_RE.get("positives").get("quotes_required") - + FOLLOWED_BY_EQUAL_SIGNS_RE.get("positives").get("quotes_required") - + FOLLOWED_BY_QUOTES_AND_SEMICOLON_RE.get("positives").get("quotes_required") + FOLLOWED_BY_COLON_RE.get('positives').get('quotes_required') + + FOLLOWED_BY_EQUAL_SIGNS_RE.get('positives').get('quotes_required') + + FOLLOWED_BY_QUOTES_AND_SEMICOLON_RE.get('positives').get('quotes_required') ) for file_extension in QUOTES_REQUIRED_FILE_EXTENSIONS ), ) @@ -203,11 +203,11 @@ def test_analyze_quotes_required_positives(self, file_content, file_extension): @pytest.mark.parametrize( 'file_content', - FOLLOWED_BY_EQUAL_SIGNS_RE.get("positives").get("quotes_required") - + FOLLOWED_BY_EQUAL_SIGNS_RE.get("positives").get("quotes_not_required") - + FOLLOWED_BY_QUOTES_AND_SEMICOLON_RE.get("positives").get("quotes_required") - + FOLLOWED_BY_COLON_EQUAL_SIGNS_RE.get("positives").get("quotes_required") - + FOLLOWED_BY_COLON_EQUAL_SIGNS_RE.get("positives").get("quotes_not_required"), + FOLLOWED_BY_EQUAL_SIGNS_RE.get('positives').get('quotes_required') + + FOLLOWED_BY_EQUAL_SIGNS_RE.get('positives').get('quotes_not_required') + + FOLLOWED_BY_QUOTES_AND_SEMICOLON_RE.get('positives').get('quotes_required') + + FOLLOWED_BY_COLON_EQUAL_SIGNS_RE.get('positives').get('quotes_required') + + FOLLOWED_BY_COLON_EQUAL_SIGNS_RE.get('positives').get('quotes_not_required'), ) def test_analyze_go_positives(self, file_content): logic = KeywordDetector() diff --git a/tests/pre_commit_hook_test.py b/tests/pre_commit_hook_test.py index 554e78150..1b86ec03c 100644 --- a/tests/pre_commit_hook_test.py +++ b/tests/pre_commit_hook_test.py @@ -317,9 +317,9 @@ def _create_baseline_template(has_result, use_private_key_scan): } if not use_private_key_scan: - baseline["plugins_used"].pop(-1) + baseline['plugins_used'].pop(-1) if not has_result: - baseline["results"] = {} + baseline['results'] = {} return baseline