summaryrefslogtreecommitdiffstats
path: root/meta/classes/cve-check.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/cve-check.bbclass')
-rw-r--r--meta/classes/cve-check.bbclass16
1 files changed, 15 insertions, 1 deletions
diff --git a/meta/classes/cve-check.bbclass b/meta/classes/cve-check.bbclass
index f44bbed6ac..bc2f03f7dd 100644
--- a/meta/classes/cve-check.bbclass
+++ b/meta/classes/cve-check.bbclass
@@ -118,10 +118,24 @@ def get_patches_cves(d):
118 118
119 pn = d.getVar("PN") 119 pn = d.getVar("PN")
120 cve_match = re.compile("CVE:( CVE\-\d{4}\-\d+)+") 120 cve_match = re.compile("CVE:( CVE\-\d{4}\-\d+)+")
121
122 # Matches last CVE-1234-211432 in the file name, also if written
123 # with small letters. Not supporting multiple CVE id's in a single
124 # file name.
125 cve_file_name_match = re.compile(".*([Cc][Vv][Ee]\-\d{4}\-\d+)")
126
121 patched_cves = set() 127 patched_cves = set()
122 bb.debug(2, "Looking for patches that solves CVEs for %s" % pn) 128 bb.debug(2, "Looking for patches that solves CVEs for %s" % pn)
123 for url in src_patches(d): 129 for url in src_patches(d):
124 patch_file = bb.fetch.decodeurl(url)[2] 130 patch_file = bb.fetch.decodeurl(url)[2]
131
132 # Check patch file name for CVE ID
133 fname_match = cve_file_name_match.search(patch_file)
134 if fname_match:
135 cve = fname_match.group(1).upper()
136 patched_cves.add(cve)
137 bb.debug(2, "Found CVE %s from patch file name %s" % (cve, patch_file))
138
125 with open(patch_file, "r", encoding="utf-8") as f: 139 with open(patch_file, "r", encoding="utf-8") as f:
126 try: 140 try:
127 patch_text = f.read() 141 patch_text = f.read()
@@ -140,7 +154,7 @@ def get_patches_cves(d):
140 for cve in cves.split(): 154 for cve in cves.split():
141 bb.debug(2, "Patch %s solves %s" % (patch_file, cve)) 155 bb.debug(2, "Patch %s solves %s" % (patch_file, cve))
142 patched_cves.add(cve) 156 patched_cves.add(cve)
143 else: 157 elif not fname_match:
144 bb.debug(2, "Patch %s doesn't solve CVEs" % patch_file) 158 bb.debug(2, "Patch %s doesn't solve CVEs" % patch_file)
145 159
146 return patched_cves 160 return patched_cves