Gentoo Archives: gentoo-commits

From: John Helmert III <ajak@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/security:ajak-cvetool commit in: bin/
Date: Tue, 06 Jul 2021 02:03:57
Message-Id: 1625516881.be4a8b7e8023688a31e931b46fc3ef8651a290a5.ajak@gentoo
1 commit: be4a8b7e8023688a31e931b46fc3ef8651a290a5
2 Author: John Helmert III <ajak <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jul 5 20:27:13 2021 +0000
4 Commit: John Helmert III <ajak <AT> gentoo <DOT> org>
5 CommitDate: Mon Jul 5 20:28:01 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/security.git/commit/?id=be4a8b7e
7
8 glsatool: drop, accidentally added, not ready yet
9
10 Signed-off-by: John Helmert III <ajak <AT> gentoo.org>
11
12 bin/glsatool | 74 ------------------------------------------------------------
13 1 file changed, 74 deletions(-)
14
15 diff --git a/bin/glsatool b/bin/glsatool
16 deleted file mode 100755
17 index 4582a40..0000000
18 --- a/bin/glsatool
19 +++ /dev/null
20 @@ -1,74 +0,0 @@
21 -#!/usr/bin/env python
22 -
23 -import argparse
24 -import os
25 -import re
26 -import typing
27 -
28 -import bugzilla
29 -import bracex
30 -import pkgcore.config
31 -from pkgcore.ebuild import atom
32 -import requests
33 -
34 -from cvetool import CVETool
35 -
36 -PKG_SEPARATORS = re.compile(r':\s|[\s,;(){}[\]]')
37 -GLSAMAKER_URI = 'https://glsamaker.gentoo.org'
38 -bgo = bugzilla.Bugzilla('https://bugs.gentoo.org')
39 -repo = pkgcore.config.load_config().repo['gentoo']
40 -
41 -
42 -class GLSATool:
43 - """ Utility to ease GLSA handling in GLSAMaker """
44 -
45 - def __init__(self, auth):
46 - self.auth = auth
47 -
48 - # https://github.com/mgorny/kuroneko/blob/master/kuroneko/scraper.py#L80
49 - def find_package_specs(s: str) -> typing.Iterable[atom.atom]:
50 - """Find potentially valid package specifications in given string."""
51 - words = set()
52 - # consider all possible expansions
53 - for exp in bracex.iexpand(s):
54 - words.update(PKG_SEPARATORS.split(exp))
55 - for w in words:
56 - # skip anything that couldn't be cat/pkg early
57 - if '/' not in w:
58 - continue
59 - try:
60 - yield atom.atom(w)
61 - except MalformedAtom:
62 - continue
63 -
64 - def new_glsa(auth, title, bugs):
65 - post = requests.post(GLSAMAKER_URI + '/glsas',
66 - data={'title': title + ' [DRAFT]',
67 - 'bugs': ','.join(bugs),
68 - 'access': 'public',
69 - 'import_references': '1',
70 - 'what': 'request', # ???
71 - 'authenticity_token': 'k75YYdGlcL+dlZS7RKXSVxKaKl2tiiMvwWlReFtKzt3NCKDE2AeskkrZ851xJB7uCBRUTpstV+/aqUTEx3MfIQ=='},
72 - headers={'Authorization': 'Basic ' + auth})
73 - if not post.ok:
74 - import pdb; pdb.set_trace()
75 -
76 -
77 -def get_auth():
78 - authpath = os.path.join(os.path.expanduser('~'), '.config', 'cvetool_auth')
79 - if 'CVETOOL_AUTH' in os.environ:
80 - return os.environ['CVETOOL_AUTH']
81 - elif os.path.isfile(authpath):
82 - with open(authpath, 'r') as authfile:
83 - return authfile.readlines()[0]
84 -
85 -
86 -if __name__ == '__main__':
87 - parser = argparse.ArgumentParser()
88 - parser.add_argument('-b', '--bugs', required=True, nargs='+')
89 - parser.add_argument('-t', '--title', required=True)
90 - args = parser.parse_args()
91 - auth = get_auth()
92 - for bug in args.bugs:
93 - CVETool(auth, 'dobug', [bug])
94 - new_glsa(auth, args.title, args.bugs)