def test_detection_by_value(src, count): args = parse_args([fixture_path(src)]) args.config = core.load_config( CONFIG_PATH.joinpath("detection_by_value.yml")) secrets = core.run(args) for _ in range(count): value = next(secrets).value.lower() if value.isnumeric(): continue assert "hardcoded" in value with pytest.raises(StopIteration): next(secrets)
def test_detection_by_filename(): expected = map( fixture_path, [ ".aws/credentials", ".htpasswd", ".npmrc", ".pypirc", "connection.config", "integration.conf", "pip.conf", "settings.cfg", "settings.conf", "settings.env", "settings.ini", ], ) args = parse_args([fixture_path()]) args.config = core.load_config( CONFIG_PATH.joinpath("detection_by_filename.yml")) secrets = core.run(args) result = [secret.value for secret in secrets] for exp in expected: assert exp in result
def test_is_static(key, value, expectation): args = parse_args([fixture_path()]) args.config = core.load_config(CONFIG_PATH.joinpath("example.yml")) secrets = WhisperSecrets(args) assert secrets.is_static(key, value) == expectation