Merge ~litios/ubuntu-cve-tracker:tags-patches-publishing-cve into ubuntu-cve-tracker:master

Proposed by David Fernandez Gonzalez
Status: Merged
Merged at revision: e777c1a948c8170a65eb366fccd4c06ad03d2a31
Proposed branch: ~litios/ubuntu-cve-tracker:tags-patches-publishing-cve
Merge into: ubuntu-cve-tracker:master
Diff against target: 38 lines (+7/-9)
1 file modified
scripts/publish-cves-to-website-api.py (+7/-9)
Reviewer Review Type Date Requested Status
Camila Camargo de Matos (community) Approve
Paulo Flabiano Smorigo Approve
Eduardo Barretto Approve
Review via email: mp+438388@code.launchpad.net

Description of the change

Right now, when publishing a CVE, we are generating entries for patches and tags for packages in subprojects.

That doesn't show on the web page but it does in the USNs: https://ubuntu.com/security/notices/USN-5686-2.json

We should only generate entries for the patches and tags present in the original CVE.

Thanks Cami for both finding the issue on the webpage and in the code!

Testing: https://pastebin.canonical.com/p/7Vhz9Sq72Z/

To post a comment you must log in.
Revision history for this message
Camila Camargo de Matos (ccdm94) wrote (last edit ):

I am by no means a cve_lib expert, but after some explanation from @litios, and some testing using the sample code provided, this LGTM.

The tags change might seem like the correct way to go about this, since with the change, if there are no tags, the field will be empty, as expected if there are no tags (when I say "expected", I mean, in theory). I am just not sure if this would break anything that uses the tags information and expects to receive a non-empty dictionary, even if the non-empty dictionary only contains keys with empty lists, so that might be worth checking out.

After initial analysis, it seems like from our side nothing would break, as we have the following:
  - for the 'tags' key being accessed in `html_export.py`: we have the `if pkg in data['tags']:` instruction, so there is a check here before accessing the tag information. The loop just won't execute in this case (at all), and what is executed inside the loop does not look like something that will affect the rest of the code negatively.
  - for the 'tags' key being accessed in `cve_lib`: the access seems to occur on top of data recovered directly from a CVE file through `load_cves`, so I guess the webpage data being different wouldn't cause any issues in the execution of functions from `cve_lib`, since the webpage that is not what is being used as a reference.

Revision history for this message
Eduardo Barretto (ebarretto) wrote :

lgtm, thanks both for finding the issue and fixing it quickly

review: Approve
Revision history for this message
Paulo Flabiano Smorigo (pfsmorigo) wrote :

LGTM Thanks!

review: Approve
Revision history for this message
Camila Camargo de Matos (ccdm94) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/scripts/publish-cves-to-website-api.py b/scripts/publish-cves-to-website-api.py
2index f27db84..1342eac 100755
3--- a/scripts/publish-cves-to-website-api.py
4+++ b/scripts/publish-cves-to-website-api.py
5@@ -41,11 +41,11 @@ def get_codename(raw_codename, cve_releases):
6
7 return get_devel_codename(cve_releases)
8
9-def get_tags(cve_data, pkg):
10- return list(cve_data['tags'].get(pkg, list()))
11-
12-def get_patches(cve_data, pkg):
13- return [ patch_type + ": " + entry for patch_type, entry in cve_data['patches'].get(pkg, list())]
14+def get_patches(cve_data):
15+ patches = {}
16+ for pkg in cve_data['patches']:
17+ patches[pkg] = [patch_type + ": " + entry for patch_type, entry in cve_data['patches'].get(pkg)]
18+ return patches
19
20 def get_devel_codename(cve_releases):
21 for skip_release in ['upstream', 'devel', 'product', 'snap']:
22@@ -97,14 +97,12 @@ def post_single_cve(cve_filename):
23 impact = None
24
25 packages = []
26- tags = {}
27- patches = {}
28+ tags = cve_data['tags']
29+ patches = get_patches(cve_data)
30 for pkg in cve_data["pkgs"]:
31 statuses = []
32 cve_releases = cve_data["pkgs"][pkg].keys()
33 cve_releases = [rel for rel in cve_releases if rel in cve_lib.releases]
34- tags[pkg] = get_tags(cve_data, pkg)
35- patches[pkg] = get_patches(cve_data, pkg)
36
37 for codename in cve_lib.releases + ["upstream"]:
38 status = None

Subscribers

People subscribed via source and target branches