blob: 0889e7544aaf94878c95abb28ff5d234019b35a2 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001# This class is used to check recipes against public CVEs.
2#
3# In order to use this class just inherit the class in the
4# local.conf file and it will add the cve_check task for
5# every recipe. The task can be used per recipe, per image,
6# or using the special cases "world" and "universe". The
7# cve_check task will print a warning for every unpatched
8# CVE found and generate a file in the recipe WORKDIR/cve
9# directory. If an image is build it will generate a report
10# in DEPLOY_DIR_IMAGE for all the packages used.
11#
12# Example:
13# bitbake -c cve_check openssl
14# bitbake core-image-sato
15# bitbake -k -c cve_check universe
16#
17# DISCLAIMER
18#
19# This class/tool is meant to be used as support and not
20# the only method to check against CVEs. Running this tool
21# doesn't guarantee your packages are free of CVEs.
22
Brad Bishop37a0e4d2017-12-04 01:01:44 -050023# The product name that the CVE database uses. Defaults to BPN, but may need to
24# be overriden per recipe (for example tiff.bb sets CVE_PRODUCT=libtiff).
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025CVE_PRODUCT ??= "${BPN}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040026CVE_VERSION ??= "${PV}"
Brad Bishop37a0e4d2017-12-04 01:01:44 -050027
Patrick Williamsc0f7c042017-02-23 20:41:17 -060028CVE_CHECK_DB_DIR ?= "${DL_DIR}/CVE_CHECK"
Andrew Geissler82c905d2020-04-13 13:39:40 -050029CVE_CHECK_DB_FILE ?= "${CVE_CHECK_DB_DIR}/nvdcve_1.1.db"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060030
Brad Bishop316dfdd2018-06-25 12:45:53 -040031CVE_CHECK_LOG ?= "${T}/cve.log"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060032CVE_CHECK_TMP_FILE ?= "${TMPDIR}/cve_check"
Andrew Geisslerb7d28612020-07-24 16:15:54 -050033CVE_CHECK_SUMMARY_DIR ?= "${LOG_DIR}/cve"
34CVE_CHECK_SUMMARY_FILE_NAME ?= "cve-summary"
35CVE_CHECK_SUMMARY_FILE ?= "${CVE_CHECK_SUMMARY_DIR}/${CVE_CHECK_SUMMARY_FILE_NAME}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060036
37CVE_CHECK_DIR ??= "${DEPLOY_DIR}/cve"
38CVE_CHECK_MANIFEST ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.cve"
39CVE_CHECK_COPY_FILES ??= "1"
40CVE_CHECK_CREATE_MANIFEST ??= "1"
41
42# Whitelist for packages (PN)
Brad Bishop96ff1982019-08-19 13:50:42 -040043CVE_CHECK_PN_WHITELIST ?= ""
Patrick Williamsc0f7c042017-02-23 20:41:17 -060044
Brad Bishop96ff1982019-08-19 13:50:42 -040045# Whitelist for CVE. If a CVE is found, then it is considered patched.
46# The value is a string containing space separated CVE values:
47#
48# CVE_CHECK_WHITELIST = 'CVE-2014-2524 CVE-2018-1234'
49#
50CVE_CHECK_WHITELIST ?= ""
Patrick Williamsc0f7c042017-02-23 20:41:17 -060051
Andrew Geisslerb7d28612020-07-24 16:15:54 -050052python cve_save_summary_handler () {
53 import shutil
54 import datetime
55
56 cve_tmp_file = d.getVar("CVE_CHECK_TMP_FILE")
57
58 cve_summary_name = d.getVar("CVE_CHECK_SUMMARY_FILE_NAME")
59 cvelogpath = d.getVar("CVE_CHECK_SUMMARY_DIR")
60 bb.utils.mkdirhier(cvelogpath)
61
62 timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
63 cve_summary_file = os.path.join(cvelogpath, "%s-%s.txt" % (cve_summary_name, timestamp))
64
65 shutil.copyfile(cve_tmp_file, cve_summary_file)
66
67 if cve_summary_file and os.path.exists(cve_summary_file):
68 cvefile_link = os.path.join(cvelogpath, cve_summary_name)
69
70 if os.path.exists(os.path.realpath(cvefile_link)):
71 os.remove(cvefile_link)
72 os.symlink(os.path.basename(cve_summary_file), cvefile_link)
73}
74
75addhandler cve_save_summary_handler
76cve_save_summary_handler[eventmask] = "bb.event.BuildCompleted"
77
Patrick Williamsc0f7c042017-02-23 20:41:17 -060078python do_cve_check () {
79 """
80 Check recipe for patched and unpatched CVEs
81 """
82
Brad Bishop96ff1982019-08-19 13:50:42 -040083 if os.path.exists(d.getVar("CVE_CHECK_DB_FILE")):
Andrew Geissler82c905d2020-04-13 13:39:40 -050084 try:
85 patched_cves = get_patches_cves(d)
86 except FileNotFoundError:
87 bb.fatal("Failure in searching patches")
88 whitelisted, patched, unpatched = check_cves(d, patched_cves)
Patrick Williamsc0f7c042017-02-23 20:41:17 -060089 if patched or unpatched:
90 cve_data = get_cve_info(d, patched + unpatched)
Andrew Geissler82c905d2020-04-13 13:39:40 -050091 cve_write_data(d, patched, unpatched, whitelisted, cve_data)
Patrick Williamsc0f7c042017-02-23 20:41:17 -060092 else:
Brad Bishop96ff1982019-08-19 13:50:42 -040093 bb.note("No CVE database found, skipping CVE check")
94
Patrick Williamsc0f7c042017-02-23 20:41:17 -060095}
96
Andrew Geissler1e34c2d2020-05-29 16:02:59 -050097addtask cve_check before do_build after do_fetch
Brad Bishop96ff1982019-08-19 13:50:42 -040098do_cve_check[depends] = "cve-update-db-native:do_populate_cve_db"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060099do_cve_check[nostamp] = "1"
100
101python cve_check_cleanup () {
102 """
103 Delete the file used to gather all the CVE information.
104 """
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500105 bb.utils.remove(e.data.getVar("CVE_CHECK_TMP_FILE"))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600106}
107
108addhandler cve_check_cleanup
109cve_check_cleanup[eventmask] = "bb.cooker.CookerExit"
110
111python cve_check_write_rootfs_manifest () {
112 """
113 Create CVE manifest when building an image
114 """
115
116 import shutil
117
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500118 if d.getVar("CVE_CHECK_COPY_FILES") == "1":
119 deploy_file = os.path.join(d.getVar("CVE_CHECK_DIR"), d.getVar("PN"))
120 if os.path.exists(deploy_file):
121 bb.utils.remove(deploy_file)
122
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500123 if os.path.exists(d.getVar("CVE_CHECK_TMP_FILE")):
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600124 bb.note("Writing rootfs CVE manifest")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500125 deploy_dir = d.getVar("DEPLOY_DIR_IMAGE")
126 link_name = d.getVar("IMAGE_LINK_NAME")
127 manifest_name = d.getVar("CVE_CHECK_MANIFEST")
128 cve_tmp_file = d.getVar("CVE_CHECK_TMP_FILE")
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600129
130 shutil.copyfile(cve_tmp_file, manifest_name)
131
132 if manifest_name and os.path.exists(manifest_name):
133 manifest_link = os.path.join(deploy_dir, "%s.cve" % link_name)
134 # If we already have another manifest, update symlinks
135 if os.path.exists(os.path.realpath(manifest_link)):
136 os.remove(manifest_link)
137 os.symlink(os.path.basename(manifest_name), manifest_link)
138 bb.plain("Image CVE report stored in: %s" % manifest_name)
139}
140
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500141ROOTFS_POSTPROCESS_COMMAND_prepend = "${@'cve_check_write_rootfs_manifest; ' if d.getVar('CVE_CHECK_CREATE_MANIFEST') == '1' else ''}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500142do_rootfs[recrdeptask] += "${@'do_cve_check' if d.getVar('CVE_CHECK_CREATE_MANIFEST') == '1' else ''}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600143
144def get_patches_cves(d):
145 """
146 Get patches that solve CVEs using the "CVE: " tag.
147 """
148
149 import re
150
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500151 pn = d.getVar("PN")
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600152 cve_match = re.compile("CVE:( CVE\-\d{4}\-\d+)+")
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500153
154 # Matches last CVE-1234-211432 in the file name, also if written
155 # with small letters. Not supporting multiple CVE id's in a single
156 # file name.
157 cve_file_name_match = re.compile(".*([Cc][Vv][Ee]\-\d{4}\-\d+)")
158
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600159 patched_cves = set()
160 bb.debug(2, "Looking for patches that solves CVEs for %s" % pn)
161 for url in src_patches(d):
162 patch_file = bb.fetch.decodeurl(url)[2]
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500163
Andrew Geissler82c905d2020-04-13 13:39:40 -0500164 if not os.path.isfile(patch_file):
165 bb.error("File Not found: %s" % patch_file)
166 raise FileNotFoundError
167
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500168 # Check patch file name for CVE ID
169 fname_match = cve_file_name_match.search(patch_file)
170 if fname_match:
171 cve = fname_match.group(1).upper()
172 patched_cves.add(cve)
173 bb.debug(2, "Found CVE %s from patch file name %s" % (cve, patch_file))
174
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600175 with open(patch_file, "r", encoding="utf-8") as f:
176 try:
177 patch_text = f.read()
178 except UnicodeDecodeError:
179 bb.debug(1, "Failed to read patch %s using UTF-8 encoding"
180 " trying with iso8859-1" % patch_file)
181 f.close()
182 with open(patch_file, "r", encoding="iso8859-1") as f:
183 patch_text = f.read()
184
Brad Bishopbba38f32018-08-23 16:11:46 +0800185 # Search for one or more "CVE: " lines
186 text_match = False
187 for match in cve_match.finditer(patch_text):
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600188 # Get only the CVEs without the "CVE: " tag
189 cves = patch_text[match.start()+5:match.end()]
190 for cve in cves.split():
191 bb.debug(2, "Patch %s solves %s" % (patch_file, cve))
192 patched_cves.add(cve)
Brad Bishopbba38f32018-08-23 16:11:46 +0800193 text_match = True
194
195 if not fname_match and not text_match:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600196 bb.debug(2, "Patch %s doesn't solve CVEs" % patch_file)
197
198 return patched_cves
199
200def check_cves(d, patched_cves):
201 """
Brad Bishopf3fd2882019-06-21 08:06:37 -0400202 Connect to the NVD database and find unpatched cves.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600203 """
Brad Bishopf3fd2882019-06-21 08:06:37 -0400204 from distutils.version import LooseVersion
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600205
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600206 cves_unpatched = []
Brad Bishopf3fd2882019-06-21 08:06:37 -0400207 # CVE_PRODUCT can contain more than one product (eg. curl/libcurl)
Brad Bishop96ff1982019-08-19 13:50:42 -0400208 products = d.getVar("CVE_PRODUCT").split()
Brad Bishop316dfdd2018-06-25 12:45:53 -0400209 # If this has been unset then we're not scanning for CVEs here (for example, image recipes)
Brad Bishop96ff1982019-08-19 13:50:42 -0400210 if not products:
Andrew Geissler82c905d2020-04-13 13:39:40 -0500211 return ([], [], [])
Brad Bishop316dfdd2018-06-25 12:45:53 -0400212 pv = d.getVar("CVE_VERSION").split("+git")[0]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600213
214 # If the recipe has been whitlisted we return empty lists
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500215 if d.getVar("PN") in d.getVar("CVE_CHECK_PN_WHITELIST").split():
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600216 bb.note("Recipe has been whitelisted, skipping check")
Andrew Geissler82c905d2020-04-13 13:39:40 -0500217 return ([], [], [])
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600218
Brad Bishop96ff1982019-08-19 13:50:42 -0400219 old_cve_whitelist = d.getVar("CVE_CHECK_CVE_WHITELIST")
220 if old_cve_whitelist:
221 bb.warn("CVE_CHECK_CVE_WHITELIST is deprecated, please use CVE_CHECK_WHITELIST.")
222 cve_whitelist = d.getVar("CVE_CHECK_WHITELIST").split()
223
Brad Bishopf3fd2882019-06-21 08:06:37 -0400224 import sqlite3
Brad Bishop6dbb3162019-11-25 09:41:34 -0500225 db_file = d.expand("file:${CVE_CHECK_DB_FILE}?mode=ro")
226 conn = sqlite3.connect(db_file, uri=True)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600227
Brad Bishop6dbb3162019-11-25 09:41:34 -0500228 # For each of the known product names (e.g. curl has CPEs using curl and libcurl)...
Brad Bishop96ff1982019-08-19 13:50:42 -0400229 for product in products:
Brad Bishop96ff1982019-08-19 13:50:42 -0400230 if ":" in product:
231 vendor, product = product.split(":", 1)
Brad Bishop96ff1982019-08-19 13:50:42 -0400232 else:
Brad Bishop6dbb3162019-11-25 09:41:34 -0500233 vendor = "%"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600234
Brad Bishop6dbb3162019-11-25 09:41:34 -0500235 # Find all relevant CVE IDs.
236 for cverow in conn.execute("SELECT DISTINCT ID FROM PRODUCTS WHERE PRODUCT IS ? AND VENDOR LIKE ?", (product, vendor)):
237 cve = cverow[0]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600238
Brad Bishop96ff1982019-08-19 13:50:42 -0400239 if cve in cve_whitelist:
240 bb.note("%s-%s has been whitelisted for %s" % (product, pv, cve))
Brad Bishop64c979e2019-11-04 13:55:29 -0500241 # TODO: this should be in the report as 'whitelisted'
242 patched_cves.add(cve)
Brad Bishop6dbb3162019-11-25 09:41:34 -0500243 continue
Brad Bishopf3fd2882019-06-21 08:06:37 -0400244 elif cve in patched_cves:
245 bb.note("%s has been patched" % (cve))
Brad Bishop6dbb3162019-11-25 09:41:34 -0500246 continue
247
248 vulnerable = False
249 for row in conn.execute("SELECT * FROM PRODUCTS WHERE ID IS ? AND PRODUCT IS ? AND VENDOR LIKE ?", (cve, product, vendor)):
250 (_, _, _, version_start, operator_start, version_end, operator_end) = row
251 #bb.debug(2, "Evaluating row " + str(row))
252
Andrew Geissler82c905d2020-04-13 13:39:40 -0500253 if (operator_start == '=' and pv == version_start) or version_start == '-':
Brad Bishop6dbb3162019-11-25 09:41:34 -0500254 vulnerable = True
Brad Bishop96ff1982019-08-19 13:50:42 -0400255 else:
256 if operator_start:
257 try:
Brad Bishop6dbb3162019-11-25 09:41:34 -0500258 vulnerable_start = (operator_start == '>=' and LooseVersion(pv) >= LooseVersion(version_start))
259 vulnerable_start |= (operator_start == '>' and LooseVersion(pv) > LooseVersion(version_start))
Brad Bishop96ff1982019-08-19 13:50:42 -0400260 except:
Brad Bishop64c979e2019-11-04 13:55:29 -0500261 bb.warn("%s: Failed to compare %s %s %s for %s" %
Brad Bishop96ff1982019-08-19 13:50:42 -0400262 (product, pv, operator_start, version_start, cve))
Brad Bishop6dbb3162019-11-25 09:41:34 -0500263 vulnerable_start = False
Brad Bishop96ff1982019-08-19 13:50:42 -0400264 else:
Brad Bishop6dbb3162019-11-25 09:41:34 -0500265 vulnerable_start = False
Brad Bishop96ff1982019-08-19 13:50:42 -0400266
267 if operator_end:
268 try:
Brad Bishop6dbb3162019-11-25 09:41:34 -0500269 vulnerable_end = (operator_end == '<=' and LooseVersion(pv) <= LooseVersion(version_end))
270 vulnerable_end |= (operator_end == '<' and LooseVersion(pv) < LooseVersion(version_end))
Brad Bishop96ff1982019-08-19 13:50:42 -0400271 except:
Brad Bishop64c979e2019-11-04 13:55:29 -0500272 bb.warn("%s: Failed to compare %s %s %s for %s" %
Brad Bishop96ff1982019-08-19 13:50:42 -0400273 (product, pv, operator_end, version_end, cve))
Brad Bishop6dbb3162019-11-25 09:41:34 -0500274 vulnerable_end = False
Brad Bishop96ff1982019-08-19 13:50:42 -0400275 else:
Brad Bishop6dbb3162019-11-25 09:41:34 -0500276 vulnerable_end = False
Brad Bishop96ff1982019-08-19 13:50:42 -0400277
278 if operator_start and operator_end:
Brad Bishop6dbb3162019-11-25 09:41:34 -0500279 vulnerable = vulnerable_start and vulnerable_end
Brad Bishop96ff1982019-08-19 13:50:42 -0400280 else:
Brad Bishop6dbb3162019-11-25 09:41:34 -0500281 vulnerable = vulnerable_start or vulnerable_end
Brad Bishop96ff1982019-08-19 13:50:42 -0400282
Brad Bishop6dbb3162019-11-25 09:41:34 -0500283 if vulnerable:
Brad Bishop64c979e2019-11-04 13:55:29 -0500284 bb.note("%s-%s is vulnerable to %s" % (product, pv, cve))
Brad Bishop96ff1982019-08-19 13:50:42 -0400285 cves_unpatched.append(cve)
Brad Bishop6dbb3162019-11-25 09:41:34 -0500286 break
287
288 if not vulnerable:
289 bb.note("%s-%s is not vulnerable to %s" % (product, pv, cve))
290 # TODO: not patched but not vulnerable
291 patched_cves.add(cve)
292
Brad Bishopf3fd2882019-06-21 08:06:37 -0400293 conn.close()
294
Andrew Geissler82c905d2020-04-13 13:39:40 -0500295 return (list(cve_whitelist), list(patched_cves), cves_unpatched)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600296
297def get_cve_info(d, cves):
298 """
Brad Bishop96ff1982019-08-19 13:50:42 -0400299 Get CVE information from the database.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600300 """
301
Brad Bishop6dbb3162019-11-25 09:41:34 -0500302 import sqlite3
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600303
304 cve_data = {}
Brad Bishop6dbb3162019-11-25 09:41:34 -0500305 conn = sqlite3.connect(d.getVar("CVE_CHECK_DB_FILE"))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600306
Brad Bishop6dbb3162019-11-25 09:41:34 -0500307 for cve in cves:
308 for row in conn.execute("SELECT * FROM NVD WHERE ID IS ?", (cve,)):
309 cve_data[row[0]] = {}
310 cve_data[row[0]]["summary"] = row[1]
311 cve_data[row[0]]["scorev2"] = row[2]
312 cve_data[row[0]]["scorev3"] = row[3]
313 cve_data[row[0]]["modified"] = row[4]
314 cve_data[row[0]]["vector"] = row[5]
315
316 conn.close()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600317 return cve_data
318
Andrew Geissler82c905d2020-04-13 13:39:40 -0500319def cve_write_data(d, patched, unpatched, whitelisted, cve_data):
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600320 """
321 Write CVE information in WORKDIR; and to CVE_CHECK_DIR, and
322 CVE manifest if enabled.
323 """
324
Brad Bishop316dfdd2018-06-25 12:45:53 -0400325 cve_file = d.getVar("CVE_CHECK_LOG")
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600326 nvd_link = "https://web.nvd.nist.gov/view/vuln/detail?vulnId="
327 write_string = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500328 unpatched_cves = []
Brad Bishop316dfdd2018-06-25 12:45:53 -0400329 bb.utils.mkdirhier(os.path.dirname(cve_file))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600330
331 for cve in sorted(cve_data):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500332 write_string += "PACKAGE NAME: %s\n" % d.getVar("PN")
Andrew Geissler4ed12e12020-06-05 18:00:41 -0500333 write_string += "PACKAGE VERSION: %s%s\n" % (d.getVar("EXTENDPE"), d.getVar("PV"))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600334 write_string += "CVE: %s\n" % cve
Andrew Geissler82c905d2020-04-13 13:39:40 -0500335 if cve in whitelisted:
336 write_string += "CVE STATUS: Whitelisted\n"
337 elif cve in patched:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600338 write_string += "CVE STATUS: Patched\n"
339 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500340 unpatched_cves.append(cve)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600341 write_string += "CVE STATUS: Unpatched\n"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600342 write_string += "CVE SUMMARY: %s\n" % cve_data[cve]["summary"]
Brad Bishopf3fd2882019-06-21 08:06:37 -0400343 write_string += "CVSS v2 BASE SCORE: %s\n" % cve_data[cve]["scorev2"]
344 write_string += "CVSS v3 BASE SCORE: %s\n" % cve_data[cve]["scorev3"]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600345 write_string += "VECTOR: %s\n" % cve_data[cve]["vector"]
346 write_string += "MORE INFORMATION: %s%s\n\n" % (nvd_link, cve)
347
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500348 if unpatched_cves:
349 bb.warn("Found unpatched CVE (%s), for more information check %s" % (" ".join(unpatched_cves),cve_file))
350
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600351 with open(cve_file, "w") as f:
352 bb.note("Writing file %s with CVE information" % cve_file)
353 f.write(write_string)
354
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500355 if d.getVar("CVE_CHECK_COPY_FILES") == "1":
356 cve_dir = d.getVar("CVE_CHECK_DIR")
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600357 bb.utils.mkdirhier(cve_dir)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500358 deploy_file = os.path.join(cve_dir, d.getVar("PN"))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600359 with open(deploy_file, "w") as f:
360 f.write(write_string)
361
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500362 if d.getVar("CVE_CHECK_CREATE_MANIFEST") == "1":
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500363 cvelogpath = d.getVar("CVE_CHECK_SUMMARY_DIR")
364 bb.utils.mkdirhier(cvelogpath)
365
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500366 with open(d.getVar("CVE_CHECK_TMP_FILE"), "a") as f:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600367 f.write("%s" % write_string)