From 22fd8e122ec57a3cb4b2558dd34a17096b70d6af Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Sat, 23 Nov 2024 16:59:36 +0100 Subject: [PATCH] chg: [lookup] add `--unique` option to return the best matching CPE --- bin/lookup.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bin/lookup.py b/bin/lookup.py index ddbef29..62ee813 100644 --- a/bin/lookup.py +++ b/bin/lookup.py @@ -21,7 +21,21 @@ if __name__ == "__main__": nargs="+", help="One or more keyword(s) to lookup", ) + parser.add_argument( + "--unique", + action="store_true", + help="Return the best CPE matching the keywords given", + default=False, + ) args = parser.parse_args() cpeGuesser = CPEGuesser() - print(json.dumps(cpeGuesser.guessCpe(args.word))) + r = cpeGuesser.guessCpe(args.word) + if not args.unique: + print(json.dumps(r)) + else: + try: + r = r[:1][0][1] + except: + r = [] + print(json.dumps(r))