summaryrefslogtreecommitdiffstats
path: root/bin/lts-cve-triage.py
blob: 4ee3b576859e2353ae5e91129a80f8430b43a3b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/python

# Copyright 2015 Raphael Hertzog <hertzog@debian.org>
#
# This file is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this file.  If not, see <https://www.gnu.org/licenses/>.

import argparse
import collections

from tracker_data import TrackerData, RELEASES

tracker = TrackerData(update_cache=True)
next_lts = RELEASES['next_lts']

LIST_NAMES = (
    ('triage_already_in_dsa_needed',
     'Issues to triage that are in dsa-needed'),
    ('triage_likely_nodsa',
     'Issues to triage that are nodsa in {}'.format(next_lts)),
    ('triage_other',
     'Other issues to triage (no special status)'),
    ('triage_other_not_triaged_in_next_lts',
     'Other issues to triage (not yet triaged in {})'.format(next_lts)),
    ('unexpected_nodsa',
     'Issues tagged no-dsa that are open in {}'.format(next_lts)),
    ('possible_easy_fixes',
     'Issues that are already fixed in {}'.format(next_lts)),
)

lists = collections.defaultdict(lambda: collections.defaultdict(lambda: []))

parser = argparse.ArgumentParser(
    description='Find CVEs to triage')
parser.add_argument('--skip-dla-needed', action='store_true',
                    help='Skip packages already in dla-needed.txt')
args = parser.parse_args()


def add_to_list(key, pkg, issue):
    assert key in [l[0] for l in LIST_NAMES]
    lists[key][pkg].append(issue)


for pkg in tracker.iterate_packages():
    if args.skip_dla_needed and pkg in tracker.dla_needed:
        continue

    for issue in tracker.iterate_pkg_issues(pkg):
        status_in_lts = issue.get_status('lts')
        status_in_next_lts = issue.get_status('next_lts')

        if status_in_lts.status in ('not-affected', 'resolved'):
            continue

        if status_in_lts.status == 'open':
            if pkg not in tracker.dla_needed:  # Issues not triaged yet
                if status_in_next_lts.status == 'open':
                    if pkg in tracker.dsa_needed:
                        add_to_list('triage_already_in_dsa_needed', pkg, issue)
                    else:
                        add_to_list('triage_other_not_triaged_in_next_lts',
                                    pkg, issue)
                elif (status_in_next_lts.status == 'ignored' and
                        status_in_next_lts.reason == 'no-dsa'):
                    add_to_list('triage_likely_nodsa', pkg, issue)
                else:
                    add_to_list('triage_other', pkg, issue)
            if status_in_next_lts.status == 'resolved':
                add_to_list('possible_easy_fixes', pkg, issue)

        if (status_in_lts.status == 'ignored' and
                status_in_lts.reason == 'no-dsa' and
                status_in_next_lts.status == 'open'):
            add_to_list('unexpected_nodsa', pkg, issue)

for key, desc in LIST_NAMES:
    if not len(lists[key]):
        continue
    print('{}:'.format(desc))
    for pkg in sorted(lists[key].keys()):
        cve_list = ' '.join(
            [i.name for i in sorted(lists[key][pkg], key=lambda i: i.name)])
        print('* {:20s} -> {}'.format(pkg, cve_list))
    print('')

© 2014-2024 Faster IT GmbH | imprint | privacy policy