From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id EA76D13933E for ; Mon, 5 Jul 2021 17:42:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 18FE5E099F; Mon, 5 Jul 2021 17:42:29 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C8F3EE099F for ; Mon, 5 Jul 2021 17:42:28 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D9789335D58 for ; Mon, 5 Jul 2021 17:42:27 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7173C7C2 for ; Mon, 5 Jul 2021 17:42:26 +0000 (UTC) From: "John Helmert III" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "John Helmert III" Message-ID: <1625449978.f38466de27e3785cadbfaa45d435dc03445197e9.ajak@gentoo> Subject: [gentoo-commits] proj/security:ajak-cvetool commit in: bin/ X-VCS-Repository: proj/security X-VCS-Files: bin/cvetool.py X-VCS-Directories: bin/ X-VCS-Committer: ajak X-VCS-Committer-Name: John Helmert III X-VCS-Revision: f38466de27e3785cadbfaa45d435dc03445197e9 X-VCS-Branch: ajak-cvetool Date: Mon, 5 Jul 2021 17:42:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5bfa8fb9-e909-484e-a68e-37a8bb8f3816 X-Archives-Hash: d75235801fabc5b6acf7ca7a5af0d660 commit: f38466de27e3785cadbfaa45d435dc03445197e9 Author: John Helmert III gentoo org> AuthorDate: Mon Jul 5 01:51:29 2021 +0000 Commit: John Helmert III gentoo org> CommitDate: Mon Jul 5 01:52:58 2021 +0000 URL: https://gitweb.gentoo.org/proj/security.git/commit/?id=f38466de cvetool: avoid referencing sys.argv in CVETool constructor This is wrong because we pass in sys.argv in the constructor arguments anyway, and referring to sys.argv directly breaks consumers that aren't the cvetool script. The last use of sys.argv in the constructor is when command is invalid and self.usage(sys.argv[0]) is called, if you hit this it means you were calling CVETool programmatically, so surely you can debug it :) Signed-off-by: John Helmert III gentoo.org> bin/cvetool.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/cvetool.py b/bin/cvetool.py old mode 100644 new mode 100755 index 744e2a5..557c030 --- a/bin/cvetool.py +++ b/bin/cvetool.py @@ -36,9 +36,9 @@ class CVETool: sys.exit(1) try: - self.info(self.cleanup_cve(sys.argv[2])) + self.info(self.cleanup_cve(args[0])) except ValueError: - print('"{}" is not a valid CVE identifier!'.format(sys.argv[2])) + print('"{}" is not a valid CVE identifier!'.format(args[0])) sys.exit(1) elif command == 'assign': if len(args) < 2: @@ -53,7 +53,7 @@ class CVETool: print('Returns a list of the real CVE IDs') sys.exit(1) - self.getcveidlist([self.cleanup_cve(cve) for cve in args[0:]]) + self.getcveidlist([self.cleanup_cve(cve) for cve in args]) elif command == 'new': if len(args) != 1: print('Usage: new ') @@ -61,9 +61,9 @@ class CVETool: sys.exit(1) try: - self.new(self.cleanup_cve(sys.argv[2])) + self.new(self.cleanup_cve(args[0])) except ValueError: - print('"{}" is not a valid CVE identifier!'.format(sys.argv[2])) + print('"{}" is not a valid CVE identifier!'.format(args[0])) sys.exit(1) elif command == 'nfu': if len(args) != 1: @@ -78,14 +78,14 @@ class CVETool: print('Generates a base64-encoded credential for storing') sys.exit(1) - self.pw(sys.argv[2], sys.argv[3]) + self.pw(args[0], args[1]) elif command == 'dobug': if len(args) != 1: print('Usage: dobug ') print('Adds and assigns a bug\'s CVEs') sys.exit(1) - self.dobug(sys.argv[2]) + self.dobug(args[0]) else: self.usage(sys.argv[0]) sys.exit(1)