Constrain user input to hex-string in argparse

We do have an is_hexstr function which we should use anywhere
where we expect the user to input a string of hex digits.  This way
we validate the input before running in some random exception.

Change-Id: I6426ea864bec82be60554dd125961a48d7751904
This commit is contained in:
Harald Welte
2024-01-11 22:03:37 +01:00
parent d1cc8d0c1d
commit 91842b471d
4 changed files with 18 additions and 22 deletions

View File

@@ -1034,7 +1034,7 @@ class DF_GSM(CardDF):
super().__init__()
authenticate_parser = argparse.ArgumentParser()
authenticate_parser.add_argument('rand', help='Random challenge')
authenticate_parser.add_argument('rand', type=is_hexstr, help='Random challenge')
@cmd2.with_argparser(authenticate_parser)
def do_authenticate(self, opts):