ci: password check: fix: don't break on ScannerError (#1017)

This commit is contained in:
Anish Lakhwara 2023-07-28 00:19:27 +10:00 committed by GitHub
parent 5807507f29
commit a347f61973
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
"A small dirty script to check that none of the password config options have been set to real passwords"
from collections.abc import Generator
import yaml
from yaml.scanner import ScannerError
import sys
@ -33,15 +34,19 @@ WE_DUN_GOOFED: bool = False
changed_files = sys.argv[1:] # Ignore filename of this script
for file in changed_files:
with open(file, 'r') as f:
yml = yaml.safe_load(f)
gen = key_finder(yml)
for password_keys in gen:
if password_keys[-1] not in ALLOWED_PASSWORDS:
if len(password_keys) == 2:
print(f"top level key '{password_keys[0]}' in {file} contains a real password!")
else:
print(f"top level key '{password_keys[0]}' with subkey '{password_keys[1]}' in {file} contains a real password!")
WE_DUN_GOOFED = True
try:
yml = yaml.safe_load(f)
gen = key_finder(yml)
for password_keys in gen:
if password_keys[-1] not in ALLOWED_PASSWORDS:
if len(password_keys) == 2:
print(f"top level key '{password_keys[0]}' in {file} contains a real password!")
else:
print(f"top level key '{password_keys[0]}' with subkey '{password_keys[1]}' in {file} contains a real password!")
WE_DUN_GOOFED = True
except ScannerError:
print(f"Couldn't parse yaml file for: {file}")
pass
if WE_DUN_GOOFED:
exit(1)