[ISS-1258][DC] resolving formatting and line length issues

This commit is contained in:
DanielConnelly 2026-06-02 15:20:12 +01:00
parent 10ce480836
commit 6f0f112e53
No known key found for this signature in database
2 changed files with 22 additions and 10 deletions

View file

@ -49,7 +49,14 @@ def get_aws_secrets_from_json_file(json_credentials_file: str) -> set[str]:
return set() return set()
keys = set() keys = set()
for var in ('AccessKeyId', 'SecretAccessKey', 'SessionToken', 'aws_secret_access_key', 'aws_security_token', 'aws_session_token'): for var in (
'AccessKeyId',
'SecretAccessKey',
'SessionToken',
'aws_secret_access_key',
'aws_security_token',
'aws_session_token'
):
if var in data.get('Credentials', {}): if var in data.get('Credentials', {}):
keys.add(data['Credentials'][var]) keys.add(data['Credentials'][var])
return keys return keys
@ -125,8 +132,8 @@ def main(argv: Sequence[str] | None = None) -> int:
), ),
) )
parser.add_argument( parser.add_argument(
'--json-credentials-file', '--json-credentials-dir',
dest='json_credential_file_locations', dest='json_credential_dir',
action='append', action='append',
default=['~/.aws/cli/cache/', '~/.aws/login/cache/'], default=['~/.aws/cli/cache/', '~/.aws/login/cache/'],
help=( help=(
@ -143,13 +150,14 @@ def main(argv: Sequence[str] | None = None) -> int:
args = parser.parse_args(argv) args = parser.parse_args(argv)
credential_files = set(args.credentials_file) credential_files = set(args.credentials_file)
json_credential_file_locations = set(args.json_credential_file_locations) json_credential_dirs = set(args.json_credential_dir)
json_credential_files = set() json_credential_files = set()
for json_credential_file_location in json_credential_file_locations: for json_credential_dir in json_credential_dirs:
if os.path.isdir(os.path.expanduser(json_credential_file_location)): if os.path.isdir(os.path.expanduser(json_credential_dir)):
for filename in os.listdir(os.path.expanduser(json_credential_file_location)): for file in os.listdir(os.path.expanduser(json_credential_dir)):
if filename.endswith('.json'): if file.endswith('.json'):
json_credential_files.add(os.path.join(json_credential_file_location, filename)) (json_credential_files
.add(os.path.join(json_credential_dir, file)))
# Add the credentials files configured via environment variables to the set # Add the credentials files configured via environment variables to the set
# of files to to gather AWS secrets from. # of files to to gather AWS secrets from.

View file

@ -73,7 +73,11 @@ def test_get_aws_secrets_from_env(env_vars, values):
( (
( (
'aws_temp_secrets_file.json', 'aws_temp_secrets_file.json',
{"tempAccessKeyId", "tempSecretAccessKey", "tempSessionToken"}, {
"tempAccessKeyId",
"tempSecretAccessKey",
"tempSessionToken"
},
), ),
('nonsense.txt', set()), ('nonsense.txt', set()),
('ok_json.json', set()), ('ok_json.json', set()),