chg: [lookup] add --unique option to return the best matching CPE

This commit is contained in:
Alexandre Dulaunoy 2024-11-23 16:59:36 +01:00
parent 30d9321fc9
commit 22fd8e122e
Signed by: adulau
GPG key ID: 09E2CD4944E6CBCD

View file

@ -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))