diff options
author | Raphaël Hertzog <hertzog@debian.org> | 2015-02-18 17:04:21 +0000 |
---|---|---|
committer | Raphaël Hertzog <hertzog@debian.org> | 2015-02-18 17:04:21 +0000 |
commit | 42c7bfb90aa67e3330758331997c6cad18cf8e3c (patch) | |
tree | 9b8717d22cb58581128d7c5b59134616ce3f6bd4 /bin/contact-maintainers | |
parent | 6d16ea7a2b6d1aeed7d9a2f1b1a16737ac3f9a34 (diff) |
Add a new helper script to contact package maintainers
For now I have only provided sample templates for the LTS team, but
everything is ready if the security team wants to use it too.
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@32318 e39458fd-73e7-0310-bf30-c45bca0a0e42
Diffstat (limited to 'bin/contact-maintainers')
-rwxr-xr-x | bin/contact-maintainers | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/bin/contact-maintainers b/bin/contact-maintainers new file mode 100755 index 0000000000..ca010901c9 --- /dev/null +++ b/bin/contact-maintainers @@ -0,0 +1,83 @@ +#!/usr/bin/python + +import argparse +import os +import pwd +import subprocess +import tempfile + +from jinja2 import Template + + +def get_full_name(): + full_name = os.getenv('DEBFULLNAME') + if full_name: + return full_name.decode('utf-8') + return pwd.getpwuid(os.getuid()).pw_gecos.split(',')[0].decode('utf-8') + + +def get_source_field(pkg, name): + # XXX: retrieve data in a more reliable way + cmd = 'apt-cache showsrc {}|grep ^{}:|tail -n 1'.format( + pkg, name.capitalize()) + output = subprocess.check_output(cmd, shell=True).strip() + if output: + return output.decode('utf-8').split(': ')[1] + return '' + + +def get_maintainer(pkg): + return get_source_field(pkg, 'Maintainer') + + +def get_uploaders(pkg): + return get_source_field(pkg, 'Uploaders') + + +# Parse command line +parser = argparse.ArgumentParser( + description='Get in touch with package maintainers') +parser.add_argument('--lts', action='store_true', + help='Act as a member of the LTS team') +parser.add_argument('--no-dsa', dest='no_dsa', action='store_true', + help='Act as a member of the LTS team') +parser.add_argument('--mailer', action='store', default='mutt -H {}', + help='Command executed. Must contain {} to be replaced ' + 'by the filename of the draft contact mail') +parser.add_argument('package') +parser.add_argument('cve', nargs='*') +args = parser.parse_args() + +cc = 'debian-lts@lists.debian.org' if args.lts else 'team@security.debian.org' +team = 'lts' if args.lts else 'sec' +model = 'no-dsa' if args.no_dsa else 'update-planned' +template_file = 'templates/{}-{}.txt'.format(team, model) + +# Generate the context + +# XXX: Once that 761859 is fixed, improve the logic here to: +# - retrieve the current list of CVE dynamically +# - check whether we should use the no-dsa variant of the template +# - check whether we have an open bug report, in which case we should +# include it in the recipients of the mail + +context = { + 'package': args.package, + 'sender': get_full_name(), + 'cve': args.cve, + 'to': get_maintainer(args.package), + 'cc': cc, + 'uploaders': get_uploaders(args.package), +} + +# Generate the mail +with open(template_file) as f: + template = Template(f.read().decode('utf-8')) + +fd, filename = tempfile.mkstemp(prefix='contact-maintainers', suffix='.txt') +draft = os.fdopen(fd, 'w') +draft.write(template.render(context).encode('utf-8')) +draft.close() + +os.system(args.mailer.format(filename)) +os.unlink(filename) |