Merge ubuntu-cve-tracker:making_this_only_opt into ubuntu-cve-tracker:master

Proposed by Leonidas S. Barbosa
Status: Merged
Merged at revision: 273728d6c3708d88c7a460fcbd0849155d880d8d
Proposed branch: ubuntu-cve-tracker:making_this_only_opt
Merge into: ubuntu-cve-tracker:master
Diff against target: 141 lines (+40/-21)
2 files modified
scripts/pull-usn-desc.py (+13/-7)
scripts/sis-generate-usn (+27/-14)
Reviewer Review Type Date Requested Status
Ubuntu Security Team Pending
Review via email: mp+419989@code.launchpad.net

Commit message

Making this_only_affected feature opt and fixing minor issues

Description of the change

kernel updates are one example of usn generating that does not require this kind of feature. So, making it opt is the better approach. This patch also fixes some small issues.

To post a comment you must log in.
Revision history for this message
Steve Beattie (sbeattie) wrote :
Download full text (9.2 KiB)

On Thu, Apr 21, 2022 at 02:25:44AM -0000, Leonidas S. Barbosa wrote:
> Leonidas S. Barbosa has proposed merging ubuntu-cve-tracker:making_this_only_opt into ubuntu-cve-tracker:master.
>
> Commit message:
> Making this_only_affected feature opt and fixing minor issues
>
> For more details, see:
> https://code.launchpad.net/~ubuntu-security/ubuntu-cve-tracker/+git/ubuntu-cve-tracker/+merge/419989
>
> kernel updates are one example of usn generating that does not require this kind of feature. So, making it opt is the better approach. This patch also fixes some small issues.

Thanks, I'm likely going to merge this as-is because I need it to finish
publishing kernels, but some comments and things that need fixing:

  - I am okay with making the "only affected" check being the default,
    have a --skip-only-affects-check or some such flag for opting-out;
    I can add that flag to the scripts/prepare-kernel-usn.py script
    that wraps sis-generate-usn (amongst other things).

  - When I generate a USN for one kernel in focal and another in bionic
    (different sources, same set of CVEs fixed), the resulting calls to
    to pull-usn-desc.py ed up getting passed the following releases to
    check: ['bionic', 'bionic', 'bionic', 'focal', 'focal', 'focal']
    This is because there are three source packages associated with each
    (signed) kernel that need to have binary packages they generate
    incorporated into the USN, but no de-duplication of the releases
    occurs.

  - For similar reasons, when I enable the "affected check" on the
    same set of two kernel source packages, the pull-usn-desc.py
    throws a traceback, because it can't find source packages like
    'linux-meta' and 'linux-signed' in the CVE file. This probably
    should be handled a little more gracefully, though for non-kernel
    situations where someone is trying to publish an emergency update
    where the cve entry doesn't exist or doesn't include the source
    package being updated, the disabling option can be given.

As a general rule, if someone is publishing updates that the touch
multiple source packages and have distinct sets of CVEs for the
same release, then for simplicity of data handling, they should be
separate USNs.

There's some work that could be done to make this work when applied
against kernel updates.

Thanks.

> --
> Your team Ubuntu Security Team is requested to review the proposed merge of ubuntu-cve-tracker:making_this_only_opt into ubuntu-cve-tracker:master.

> diff --git a/scripts/pull-usn-desc.py b/scripts/pull-usn-desc.py
> index c38824b..6bb6ce1 100755
> --- a/scripts/pull-usn-desc.py
> +++ b/scripts/pull-usn-desc.py
> @@ -39,6 +39,8 @@ opter = optparse.OptionParser()
> opter.add_option("--prioritize", help="Display 'critical' and 'high' first, negligible last", action='store_true')
> opter.add_option("--cve", metavar="CVE-YYYY-NNNN", help="Request a given CVE's description or template", action='append', default=[])
> opter.add_option("--releases", help="List of releases CVEs affect to be filter used in description", action='append', default=[])
> +opter.add_option("--this-only-affected", help="Makes this only affected feature option...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/scripts/pull-usn-desc.py b/scripts/pull-usn-desc.py
2index c38824b..6bb6ce1 100755
3--- a/scripts/pull-usn-desc.py
4+++ b/scripts/pull-usn-desc.py
5@@ -39,6 +39,8 @@ opter = optparse.OptionParser()
6 opter.add_option("--prioritize", help="Display 'critical' and 'high' first, negligible last", action='store_true')
7 opter.add_option("--cve", metavar="CVE-YYYY-NNNN", help="Request a given CVE's description or template", action='append', default=[])
8 opter.add_option("--releases", help="List of releases CVEs affect to be filter used in description", action='append', default=[])
9+opter.add_option("--this-only-affected", help="Makes this only affected feature optional", action='store_true')
10+opter.add_option("--src", help="The package source to be check through if --this-only-affected is used", action='append', default=[])
11 opter.add_option("--embargoed", help="Use the embargoed tree to look for desctiptions in addition", action='store_true')
12 (opt, args) = opter.parse_args()
13
14@@ -49,7 +51,7 @@ found = []
15 # This function cross the provided releases info with CVE files info
16 # in order to find 'This only affected <releases>' info and returns it
17 # to creates the CVE description.
18-def only_affected(cve_data, cve_number, releases):
19+def only_affected(cve_data, cve_number, releases, srcs):
20 pkgs = cve_data[cve_number]['pkgs']
21 affects = {}
22
23@@ -58,7 +60,7 @@ def only_affected(cve_data, cve_number, releases):
24 releases.remove('esm-infra/trusty')
25 releases.append('trusty/esm')
26
27- for pkg in pkgs:
28+ for pkg in srcs:
29 has_releases = pkgs[pkg].keys() & set(releases)
30 for release in has_releases:
31 pkg_release = pkgs[pkg][release][0]
32@@ -76,15 +78,16 @@ def only_affected(cve_data, cve_number, releases):
33 affects_values.sort()
34 txt = ", ".join(affects_values[:-1])
35 txt += ', and {}'.format(affects_values[-1:][0])
36- return ". This issue only affected {}.".format(txt)
37+ return " This issue only affected {}.".format(txt)
38 else:
39- return ". This issue only affected {}.".format(list(affects.values())[0])
40+ return " This issue only affected {}.".format(list(affects.values())[0])
41
42 return ""
43
44
45 rc = 0
46 empty = set()
47+affected_txt = ""
48 for cve in opt.cve + args:
49 if cve.endswith(','):
50 cve = cve[:-1]
51@@ -98,9 +101,8 @@ for cve in opt.cve + args:
52 filename = get_filename(cve, use_embargoed=(opt.embargoed == True))
53 if os.path.exists(filename):
54 cves[cve] = cve_lib.load_cve(filename)
55- affected_txt = ""
56- if opt.releases:
57- affected_txt = only_affected(cves, cve, opt.releases)
58+ if opt.this_only_affected and opt.releases and opt.src:
59+ affected_txt = only_affected(cves, cve, opt.releases, opt.src)
60 chunks = cves[cve]
61
62 desc = chunks['Ubuntu-Description'].strip()
63@@ -118,6 +120,10 @@ for cve in opt.cve + args:
64 rc = 1
65 desc = "XXX-FIXME-%s-NOT-KNOWN-TO-TRACKER-XXX" % (cve)
66
67+ # some descriptions has a period others don't, so, check for it.
68+ if not desc.endswith('.') and affected_txt:
69+ affected_txt = '.' + affected_txt
70+
71 descriptions[cve] = desc + affected_txt
72 found.append(cve)
73
74diff --git a/scripts/sis-generate-usn b/scripts/sis-generate-usn
75index 864f25f..dd3c1b4 100755
76--- a/scripts/sis-generate-usn
77+++ b/scripts/sis-generate-usn
78@@ -36,6 +36,7 @@ opter.add_option("--ignore-cves", metavar="CVES", help="Comma separated list of
79 opter.add_option("--embargoed", help="Include embargoed directory when looking for CVE descriptions", action='store_true')
80 opter.add_option("--include-eol", help="Include EoL releases", action='store_true')
81 opter.add_option("--binaries-json", help="Path to JSON mapping of binary packages to versions (can repeat, default: binaries.json)", action='append', default=[])
82+opter.add_option("--this-only-affected", help="Makes this only affected feature optional", action='store_true')
83 (opt, args) = opter.parse_args()
84
85 if len(args) < 2:
86@@ -669,18 +670,22 @@ releases.sort()
87 # Building a release filter list with the current info regarding if it is
88 # esm or not so we can properly filter in it in pull-usn-desc.py --releases
89 releases_filter = []
90-for pkg in binaries.keys():
91- for release in binaries[pkg].keys():
92- for _pkg in binaries[pkg][release].keys():
93- pocket = binaries[pkg][release][_pkg]['pocket']
94- if 'esm' in pocket:
95- releases_filter.append(pocket + '/' + release)
96- else:
97- releases_filter.append(release)
98- # We just need one info as it reflects the release so skip all
99- # pkgs into binaries
100- break
101+srcs_list =[]
102+if opt.this_only_affected:
103+ for pkg in binaries.keys():
104+ for release in binaries[pkg].keys():
105+ for _pkg in binaries[pkg][release].keys():
106+ pocket = binaries[pkg][release][_pkg]['pocket']
107+ if 'esm' in pocket:
108+ releases_filter.append(pocket + '/' + release)
109+ else:
110+ releases_filter.append(release)
111+ # We just need one info as it reflects the release so skip all
112+ # pkgs into binaries
113+ break
114
115+ for src in srcs:
116+ srcs_list.append(src)
117
118 print('# title: used for Email Subject, Web title. XXX-EXPAND-TO-UPSTREAM-NAME-XXX')
119 print('# summary: used inside USN, should be package names')
120@@ -702,10 +707,18 @@ if addition and opt.kernel_mode and not ([x for x in srcs if is_lts_kernel(x)] =
121 if len(CVEs):
122 pull_usn_cmd = ['%s/scripts/pull-usn-desc.py' % os.environ['UCT'], '--prioritize']
123
124- # We need to pass all releases we are publishing in order to filter it
125- # properly in the __this_only_affected__ feature.
126- for release in releases_filter:
127+ if opt.this_only_affected:
128+ # We need to pass all releases we are publishing in order to filter it
129+ # properly in the __this_only_affected__ feature.
130+ for release in releases_filter:
131+ pull_usn_cmd.append('--releases=%s' % release)
132+ for src in srcs_list:
133+ pull_usn_cmd.append('--src=%s' % src)
134+
135+ pull_usn_cmd.append('--this-only-affected')
136+ else:
137 pull_usn_cmd.append('--releases=%s' % release)
138+
139 if opt.embargoed:
140 pull_usn_cmd.append('--embargoed')
141 print(subprocess.Popen(pull_usn_cmd + sorted(CVEs), stdout=subprocess.PIPE).communicate()[0].decode("utf-8"))

Subscribers

People subscribed via source and target branches