Merge ~litios/ubuntu-cve-tracker:unify-subprojects-info into ubuntu-cve-tracker:master

Proposed by David Fernandez Gonzalez
Status: Merged
Merge reported by: David Fernandez Gonzalez
Merged at revision: 8ccfc81dfe44290e052303b7a615c35d0c3f4bb2
Proposed branch: ~litios/ubuntu-cve-tracker:unify-subprojects-info
Merge into: ubuntu-cve-tracker:master
Diff against target: 129 lines (+44/-33)
1 file modified
scripts/cve_lib.py (+44/-33)
Reviewer Review Type Date Requested Status
Emilia Torino Approve
Eduardo Barretto Pending
Ubuntu Security Team Pending
Review via email: mp+449839@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Emilia Torino (emitorino) wrote :

Minor comment, otherwise LGTM!

review: Approve
f0e3987... by David Fernandez Gonzalez

cve_lib: updating subproject file names to new ones

Signed-off-by: David Fernandez Gonzalez <email address hidden>

8ccfc81... by David Fernandez Gonzalez

cve_lib: update documentation in load_external_subprojects

Revision history for this message
David Fernandez Gonzalez (litios) wrote :

A new commit was added to fix the issues described!

Another one was added to also update the documentation inside of the loading function,
as we no longer have the 2 directory structure.

Revision history for this message
Emilia Torino (emitorino) wrote :

Thanks!!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/scripts/cve_lib.py b/scripts/cve_lib.py
2index f37ef73..a8f0516 100755
3--- a/scripts/cve_lib.py
4+++ b/scripts/cve_lib.py
5@@ -876,7 +876,7 @@ def get_external_subproject_dir(subproject):
6
7 def read_external_subproject_config(subproject_dir):
8 """Read and return the configuration for the given subproject directory."""
9- config_yaml = os.path.join(subproject_dir, "config.yaml")
10+ config_yaml = os.path.join(subproject_dir, "config.yml")
11 with open(config_yaml) as cfg:
12 return yaml.safe_load(cfg)
13
14@@ -914,11 +914,12 @@ def find_external_subproject_cves(cve):
15 cves.append(path)
16 return cves
17
18-# Keys in config.yaml for a external subproject
19+# Keys in config.yml for a external subproject
20 # should follow the same as any other subproject
21 # except for the extra 'product' and 'release' keys.
22-MANDATORY_EXTERNAL_SUBPROJECT_KEYS = ['ppa', 'oval', 'product', 'release']
23-OPTIONAL_EXTERNAL_SUBPROJECT_KEYS = ['parent', 'name', 'codename', 'description']
24+MANDATORY_EXTERNAL_SUBPROJECT_KEYS = ['cve_triage', 'cve_patching', 'cve_notification', 'security_updates_notification', 'binary_copies_only', 'seg_support', 'owners']
25+MANDATORY_EXTERNAL_SUBPROJECT_PPA_KEYS = ['ppa', 'oval', 'product', 'release', 'supported_packages']
26+OPTIONAL_EXTERNAL_SUBPROJECT_PPA_KEYS = ['parent', 'name', 'codename', 'description', 'aliases', 'archs']
27
28 def load_external_subprojects():
29 """Search for and load subprojects into the global subprojects dict.
30@@ -926,29 +927,39 @@ def load_external_subprojects():
31 Search for and load subprojects into the global subprojects dict.
32
33 A subproject is defined as a directory which resides within
34- subprojects_dir and contains a supported.txt file. It can also contain
35- a project.yml file which specifies configuration directives for the
36- project as well as snippet CVE files. By convention, a subproject is
37- usually defined as the combination of a product and series, ie:
38+ subprojects_dir and references a supported.txt file and a PPA.
39+ This information is stored in config.yml, which contains all the
40+ information in regards the subproject. It can also contain
41+ a project.yml file which specifies metadata for the project as well
42+ as snippet CVE files. By convention, a subproject is usually defined
43+ as the combination of a product and series, ie:
44
45 esm-apps/focal
46
47 as such in this case there would expect to be within subprojects_dir a
48- directory called esm-apps/ and within that a subdirectory called
49- focal/. Inside this focal/ subdirectory a supported.txt file would list
50- the packages which are supported by the esm-apps/focal subproject. By
51- convention, snippet CVE files should reside within the esm-apps/
52- project directory rather than the esm-apps/focal/ subdirectory to avoid
53- unnecessary fragmentation across different subproject series.
54-
55+ directory called esm-apps/ and within that, in the config.yml, an entry
56+ of type 'esm-apps/focal'. Inside this entry, a reference to the designated
57+ supported.txt file, which would list the packages which are supported by
58+ the esm-apps/focal subproject. By convention, snippet CVE files should
59+ reside within the esm-apps/ project directory.
60 """
61- for supported_txt in find_files_recursive(subprojects_dir, "supported.txt"):
62- try:
63- # use config to populate other parts of the
64- # subproject settings
65- subproject_path = supported_txt[:-len("supported.txt")-1]
66- config = read_external_subproject_config(subproject_path)
67-
68+ for config_yaml in find_files_recursive(subprojects_dir, "config.yml"):
69+ subproject_path = config_yaml[:-len("config.yml")-1]
70+ # use config to populate other parts of the
71+ # subproject settings
72+ main_config = read_external_subproject_config(subproject_path)
73+ support_metadata = {}
74+
75+ # Disable this check until we have the information available
76+ # for key in MANDATORY_EXTERNAL_SUBPROJECT_KEYS:
77+ # if key not in main_config:
78+ # print('%s missing "%s" field.' % (subproject_path, key))
79+ # raise ValueError
80+ # else:
81+ # support_metadata[key] = main_config[key]
82+
83+ for ppa in main_config['ppas']:
84+ config = main_config['ppas'][ppa]
85 if 'product' not in config or 'release' not in config:
86 print('%s: missing "product" or "release".' % (subproject_path))
87 raise ValueError
88@@ -956,19 +967,20 @@ def load_external_subprojects():
89 subproject_name = '%s/%s' % (config["product"], config["release"])
90 external_releases.append(subproject_name)
91 subprojects.setdefault(subproject_name, {"packages": [],
92- "eol": False})
93+ "eol": False})
94 # an external subproject can append to an internal one
95- subprojects[subproject_name]["packages"].append(supported_txt)
96+ subprojects[subproject_name]["packages"].append(\
97+ os.path.join(subproject_path, config['supported_packages']))
98
99 # check if aliases for packages exist
100- if os.path.isfile(supported_txt[:-len("supported.txt")] + 'aliases.yaml'):
101- subprojects[subproject_name].setdefault("aliases",
102- supported_txt[:-len("supported.txt")] + 'aliases.yaml')
103+ if 'aliases' in config:
104+ subprojects[subproject_name].setdefault("aliases", \
105+ os.path.join(subproject_path, config['aliases']))
106
107- for key in MANDATORY_EXTERNAL_SUBPROJECT_KEYS + OPTIONAL_EXTERNAL_SUBPROJECT_KEYS:
108+ for key in MANDATORY_EXTERNAL_SUBPROJECT_PPA_KEYS + OPTIONAL_EXTERNAL_SUBPROJECT_PPA_KEYS:
109 if key in config:
110 subprojects[subproject_name].setdefault(key, config[key])
111- elif key in OPTIONAL_EXTERNAL_SUBPROJECT_KEYS:
112+ elif key in OPTIONAL_EXTERNAL_SUBPROJECT_PPA_KEYS:
113 _, _, _, original_release_details = get_subproject_details(subprojects[subproject_name]['release'])
114 if original_release_details and key in original_release_details:
115 subprojects[subproject_name].setdefault(key, original_release_details[key])
116@@ -978,11 +990,10 @@ def load_external_subprojects():
117 external_releases.remove(subproject_name)
118 raise ValueError
119
120+ subprojects[subproject_name].setdefault("support_metadata", support_metadata)
121 project = read_external_subproject_details(subproject_name)
122- if project and "customer" in project:
123- subprojects[subproject_name].setdefault("customer", project["customer"])
124- except:
125- pass
126+ if project:
127+ subprojects[subproject_name].setdefault("customer", project)
128
129 load_external_subprojects()
130

Subscribers

People subscribed via source and target branches