Vary exit status based on whether leaked password was found

This commit is contained in:
Michal Nazarewicz 2019-03-13 01:32:18 +00:00
parent 068f0832f7
commit 6955575a64

View File

@ -18,6 +18,7 @@ def lookup_pwned_api(pwd):
def main(args): def main(args):
ec = 0
for pwd in args or sys.stdin: for pwd in args or sys.stdin:
pwd = pwd.strip() pwd = pwd.strip()
api_return = lookup_pwned_api(pwd) api_return = lookup_pwned_api(pwd)
@ -25,9 +26,11 @@ def main(args):
print(pwd, "was found") print(pwd, "was found")
print("Hash {0}, {1} occurences".format( print("Hash {0}, {1} occurences".format(
api_return[0], api_return[1])) api_return[0], api_return[1]))
ec = 1
else: else:
print(pwd, "was not found") print(pwd, "was not found")
return ec
if __name__ == '__main__': if __name__ == '__main__':
main(sys.argv[1:]) sys.exit(main(sys.argv[1:]))