From d0732d16e8d0ca61ef98416b1d26a6b3b1939f07 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Wed, 14 Mar 2018 12:13:44 +0200 Subject: [PATCH] ui: don't log passphrases (since the log may be persisted) --- libagent/device/ui.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libagent/device/ui.py b/libagent/device/ui.py index b3c502c..f74fdea 100644 --- a/libagent/device/ui.py +++ b/libagent/device/ui.py @@ -79,10 +79,10 @@ class UnexpectedError(Exception): """Unexpected response.""" -def expect(p, prefixes): +def expect(p, prefixes, confidential=False): """Read a line and return it without required prefix.""" resp = p.stdout.readline() - log.debug('%s -> %r', p.args, resp) + log.debug('%s -> %r', p.args, resp if not confidential else '********') for prefix in prefixes: if resp.startswith(prefix): return resp[len(prefix):] @@ -117,7 +117,7 @@ def interact(title, description, prompt, binary, options): expect(p, [b'OK', b'ERR']) write(p, b'GETPIN\n') - pin = expect(p, [b'OK', b'D ']) + pin = expect(p, [b'OK', b'D '], confidential=True) p.communicate() # close stdin and wait for the process to exit exit_code = p.wait()