public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "John Helmert III" <ajak@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/security:ajak-cvetool commit in: bin/
Date: Mon,  5 Jul 2021 17:42:26 +0000 (UTC)	[thread overview]
Message-ID: <1625449978.f38466de27e3785cadbfaa45d435dc03445197e9.ajak@gentoo> (raw)

commit:     f38466de27e3785cadbfaa45d435dc03445197e9
Author:     John Helmert III <ajak <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  5 01:51:29 2021 +0000
Commit:     John Helmert III <ajak <AT> gentoo <DOT> 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 <ajak <AT> 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 <CVE>')
@@ -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 <bug>')
                 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)


             reply	other threads:[~2021-07-05 17:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05 17:42 John Helmert III [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-07-24  3:19 [gentoo-commits] proj/security:ajak-cvetool commit in: bin/ John Helmert III
2021-07-24  3:19 John Helmert III
2021-07-19  2:55 John Helmert III
2021-07-19  2:55 John Helmert III
2021-07-07  1:06 John Helmert III
2021-07-06  2:26 John Helmert III
2021-07-06  2:03 John Helmert III
2021-07-06  2:03 John Helmert III
2021-07-05 20:24 John Helmert III
2021-07-05 20:24 John Helmert III
2021-07-05 17:42 John Helmert III
2021-07-05 17:42 John Helmert III
2021-07-04  4:43 John Helmert III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1625449978.f38466de27e3785cadbfaa45d435dc03445197e9.ajak@gentoo \
    --to=ajak@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox