def cvesearch(query="last", option=None): if query == "last": if option is None: limit = 10 else: limit = int(option) if limit > opts.max or limit < 1: return "Request not in range 0-%d" % opts.max return json.dumps(lastentries(limit=limit), sort_keys=True, indent=4, default=json_util.default) elif query == "get": if option is None: return "A cve-id must be specified" return apigetcve(opts.api,cveid=option) elif query == "browse": return apibrowse(opts.api, vendor=option) elif query == "search": return apisearch(opts.api, query=option) elif query == "cvetweet": text = " " if option is None: limit = 10 else: limit = int(option) if limit > opts.max or limit < 1: return "Request not in range 0-%d" % opts.max for t in lastentries(limit=limit): text = text + str(t['id']) + " , " + str(t['summary']) + " " + " , ".join(t['references']) + "\n" return text elif query == "browse": return apibrowse(vendor=option) else: return False
def do_command(self, e, cmd): words = cmd.split(' ') if len(words) >= 2: cmd = words[0] option = words[1] else: option = None if cmd == "die": self.die() elif cmd == "last": if option is None: limit = 10 else: limit = int(option) if limit > args.m or limit < 1: self.reply(e, "Request not in range 0-%d" % args.m) self.reply( e, json.dumps(lastentries(limit=limit), sort_keys=True, indent=4, default=json_util.default)) elif cmd == "get": if option is None: self.reply(e, "A cve-id must be specified") self.reply(e, apigetcve(cveid=option)) elif cmd == "browse": self.reply(e, apibrowse(vendor=option)) elif cmd == "search": self.reply(e, apisearch(query=option)) elif cmd == "cvetweet": text = " " if option is None: limit = 10 else: limit = int(option) if limit > args.m or limit < 1: return "Request not in range 0-%d" % args.m for t in lastentries(limit=limit): text = text + str(t['id']) + " , " + str( t['summary']) + " " + " , ".join(t['references']) + "\n" self.reply(e, text) elif cmd == "browse": self.reply(e, apibrowse(vendor=option)) else: self.reply(e, "Not understood: " + cmd)
def do_command(self, e, cmd): words = cmd.split(' ') if len(words)>=2: cmd=words[0] option=words[1] else: option=None if cmd == "die": self.die() elif cmd == "last": if option is None: limit = 10 else: limit = int(option) if limit > args.m or limit < 1: self.reply(e, "Request not in range 0-%d" % args.m) self.reply(e, json.dumps(lastentries(limit=limit), sort_keys=True, indent=4, default=json_util.default)) elif cmd == "get": if option is None: self.reply(e, "A cve-id must be specified") self.reply(e, apigetcve(cveid=option)) elif cmd == "browse": self.reply(e, apibrowse(vendor=option)) elif cmd == "search": self.reply(e, apisearch(query=option)) elif cmd == "cvetweet": text = " " if option is None: limit = 10 else: limit = int(option) if limit > args.m or limit < 1: return "Request not in range 0-%d" % args.m for t in lastentries(limit=limit): text = text + str(t['id']) + " , " + str(t['summary']) + " " + " , ".join(t['references']) + "\n" self.reply(e, text) elif cmd == "browse": self.reply(e, apibrowse(vendor=option)) else: self.reply(e, "Not understood: " + cmd)