1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7# This class is used to check recipes against public CVEs.
8#
9# In order to use this class just inherit the class in the
10# local.conf file and it will add the cve_check task for
11# every recipe. The task can be used per recipe, per image,
12# or using the special cases "world" and "universe". The
13# cve_check task will print a warning for every unpatched
14# CVE found and generate a file in the recipe WORKDIR/cve
15# directory. If an image is build it will generate a report
16# in DEPLOY_DIR_IMAGE for all the packages used.
17#
18# Example:
19#   bitbake -c cve_check openssl
20#   bitbake core-image-sato
21#   bitbake -k -c cve_check universe
22#
23# DISCLAIMER
24#
25# This class/tool is meant to be used as support and not
26# the only method to check against CVEs. Running this tool
27# doesn't guarantee your packages are free of CVEs.
28
29# The product name that the CVE database uses defaults to BPN, but may need to
30# be overriden per recipe (for example tiff.bb sets CVE_PRODUCT=libtiff).
31CVE_PRODUCT ??= "${BPN}"
32CVE_VERSION ??= "${PV}"
33
34CVE_CHECK_DB_DIR ?= "${DL_DIR}/CVE_CHECK"
35CVE_CHECK_DB_FILE ?= "${CVE_CHECK_DB_DIR}/nvdcve_1.1.db"
36CVE_CHECK_DB_FILE_LOCK ?= "${CVE_CHECK_DB_FILE}.lock"
37
38CVE_CHECK_LOG ?= "${T}/cve.log"
39CVE_CHECK_TMP_FILE ?= "${TMPDIR}/cve_check"
40CVE_CHECK_SUMMARY_DIR ?= "${LOG_DIR}/cve"
41CVE_CHECK_SUMMARY_FILE_NAME ?= "cve-summary"
42CVE_CHECK_SUMMARY_FILE ?= "${CVE_CHECK_SUMMARY_DIR}/${CVE_CHECK_SUMMARY_FILE_NAME}"
43CVE_CHECK_SUMMARY_FILE_NAME_JSON = "cve-summary.json"
44CVE_CHECK_SUMMARY_INDEX_PATH = "${CVE_CHECK_SUMMARY_DIR}/cve-summary-index.txt"
45
46CVE_CHECK_LOG_JSON ?= "${T}/cve.json"
47
48CVE_CHECK_DIR ??= "${DEPLOY_DIR}/cve"
49CVE_CHECK_RECIPE_FILE ?= "${CVE_CHECK_DIR}/${PN}"
50CVE_CHECK_RECIPE_FILE_JSON ?= "${CVE_CHECK_DIR}/${PN}_cve.json"
51CVE_CHECK_MANIFEST ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.cve"
52CVE_CHECK_MANIFEST_JSON ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.json"
53CVE_CHECK_COPY_FILES ??= "1"
54CVE_CHECK_CREATE_MANIFEST ??= "1"
55
56# Report Patched or Ignored CVEs
57CVE_CHECK_REPORT_PATCHED ??= "1"
58
59CVE_CHECK_SHOW_WARNINGS ??= "1"
60
61# Provide text output
62CVE_CHECK_FORMAT_TEXT ??= "1"
63
64# Provide JSON output
65CVE_CHECK_FORMAT_JSON ??= "1"
66
67# Check for packages without CVEs (no issues or missing product name)
68CVE_CHECK_COVERAGE ??= "1"
69
70# Skip CVE Check for packages (PN)
71CVE_CHECK_SKIP_RECIPE ?= ""
72
73# Ingore the check for a given list of CVEs. If a CVE is found,
74# then it is considered patched. The value is a string containing
75# space separated CVE values:
76#
77# CVE_CHECK_IGNORE = 'CVE-2014-2524 CVE-2018-1234'
78#
79CVE_CHECK_IGNORE ?= ""
80
81# Layers to be excluded
82CVE_CHECK_LAYER_EXCLUDELIST ??= ""
83
84# Layers to be included
85CVE_CHECK_LAYER_INCLUDELIST ??= ""
86
87
88# set to "alphabetical" for version using single alphabetical character as increment release
89CVE_VERSION_SUFFIX ??= ""
90
91def generate_json_report(d, out_path, link_path):
92    if os.path.exists(d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")):
93        import json
94        from oe.cve_check import cve_check_merge_jsons, update_symlinks
95
96        bb.note("Generating JSON CVE summary")
97        index_file = d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")
98        summary = {"version":"1", "package": []}
99        with open(index_file) as f:
100            filename = f.readline()
101            while filename:
102                with open(filename.rstrip()) as j:
103                    data = json.load(j)
104                    cve_check_merge_jsons(summary, data)
105                filename = f.readline()
106
107        with open(out_path, "w") as f:
108            json.dump(summary, f, indent=2)
109
110        update_symlinks(out_path, link_path)
111
112python cve_save_summary_handler () {
113    import shutil
114    import datetime
115    from oe.cve_check import update_symlinks
116
117    cve_tmp_file = d.getVar("CVE_CHECK_TMP_FILE")
118
119    cve_summary_name = d.getVar("CVE_CHECK_SUMMARY_FILE_NAME")
120    cvelogpath = d.getVar("CVE_CHECK_SUMMARY_DIR")
121    bb.utils.mkdirhier(cvelogpath)
122
123    timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
124    cve_summary_file = os.path.join(cvelogpath, "%s-%s.txt" % (cve_summary_name, timestamp))
125
126    if os.path.exists(cve_tmp_file):
127        shutil.copyfile(cve_tmp_file, cve_summary_file)
128        cvefile_link = os.path.join(cvelogpath, cve_summary_name)
129        update_symlinks(cve_summary_file, cvefile_link)
130        bb.plain("Complete CVE report summary created at: %s" % cvefile_link)
131
132    if d.getVar("CVE_CHECK_FORMAT_JSON") == "1":
133        json_summary_link_name = os.path.join(cvelogpath, d.getVar("CVE_CHECK_SUMMARY_FILE_NAME_JSON"))
134        json_summary_name = os.path.join(cvelogpath, "%s-%s.json" % (cve_summary_name, timestamp))
135        generate_json_report(d, json_summary_name, json_summary_link_name)
136        bb.plain("Complete CVE JSON report summary created at: %s" % json_summary_link_name)
137}
138
139addhandler cve_save_summary_handler
140cve_save_summary_handler[eventmask] = "bb.event.BuildCompleted"
141
142python do_cve_check () {
143    """
144    Check recipe for patched and unpatched CVEs
145    """
146    from oe.cve_check import get_patched_cves
147
148    with bb.utils.fileslocked([d.getVar("CVE_CHECK_DB_FILE_LOCK")], shared=True):
149        if os.path.exists(d.getVar("CVE_CHECK_DB_FILE")):
150            try:
151                patched_cves = get_patched_cves(d)
152            except FileNotFoundError:
153                bb.fatal("Failure in searching patches")
154            ignored, patched, unpatched, status = check_cves(d, patched_cves)
155            if patched or unpatched or (d.getVar("CVE_CHECK_COVERAGE") == "1" and status):
156                cve_data = get_cve_info(d, patched + unpatched + ignored)
157                cve_write_data(d, patched, unpatched, ignored, cve_data, status)
158        else:
159            bb.note("No CVE database found, skipping CVE check")
160
161}
162
163addtask cve_check before do_build
164do_cve_check[depends] = "cve-update-db-native:do_fetch"
165do_cve_check[nostamp] = "1"
166
167python cve_check_cleanup () {
168    """
169    Delete the file used to gather all the CVE information.
170    """
171    bb.utils.remove(e.data.getVar("CVE_CHECK_TMP_FILE"))
172    bb.utils.remove(e.data.getVar("CVE_CHECK_SUMMARY_INDEX_PATH"))
173}
174
175addhandler cve_check_cleanup
176cve_check_cleanup[eventmask] = "bb.event.BuildCompleted"
177
178python cve_check_write_rootfs_manifest () {
179    """
180    Create CVE manifest when building an image
181    """
182
183    import shutil
184    import json
185    from oe.rootfs import image_list_installed_packages
186    from oe.cve_check import cve_check_merge_jsons, update_symlinks
187
188    if d.getVar("CVE_CHECK_COPY_FILES") == "1":
189        deploy_file = d.getVar("CVE_CHECK_RECIPE_FILE")
190        if os.path.exists(deploy_file):
191            bb.utils.remove(deploy_file)
192        deploy_file_json = d.getVar("CVE_CHECK_RECIPE_FILE_JSON")
193        if os.path.exists(deploy_file_json):
194            bb.utils.remove(deploy_file_json)
195
196    # Create a list of relevant recipies
197    recipies = set()
198    for pkg in list(image_list_installed_packages(d)):
199        pkg_info = os.path.join(d.getVar('PKGDATA_DIR'),
200                                'runtime-reverse', pkg)
201        pkg_data = oe.packagedata.read_pkgdatafile(pkg_info)
202        recipies.add(pkg_data["PN"])
203
204    bb.note("Writing rootfs CVE manifest")
205    deploy_dir = d.getVar("DEPLOY_DIR_IMAGE")
206    link_name = d.getVar("IMAGE_LINK_NAME")
207
208    json_data = {"version":"1", "package": []}
209    text_data = ""
210    enable_json = d.getVar("CVE_CHECK_FORMAT_JSON") == "1"
211    enable_text = d.getVar("CVE_CHECK_FORMAT_TEXT") == "1"
212
213    save_pn = d.getVar("PN")
214
215    for pkg in recipies:
216        # To be able to use the CVE_CHECK_RECIPE_FILE variable we have to evaluate
217        # it with the different PN names set each time.
218        d.setVar("PN", pkg)
219        if enable_text:
220            pkgfilepath = d.getVar("CVE_CHECK_RECIPE_FILE")
221            if os.path.exists(pkgfilepath):
222                with open(pkgfilepath) as pfile:
223                    text_data += pfile.read()
224
225        if enable_json:
226            pkgfilepath = d.getVar("CVE_CHECK_RECIPE_FILE_JSON")
227            if os.path.exists(pkgfilepath):
228                with open(pkgfilepath) as j:
229                    data = json.load(j)
230                    cve_check_merge_jsons(json_data, data)
231
232    d.setVar("PN", save_pn)
233
234    if enable_text:
235        link_path = os.path.join(deploy_dir, "%s.cve" % link_name)
236        manifest_name = d.getVar("CVE_CHECK_MANIFEST")
237
238        with open(manifest_name, "w") as f:
239            f.write(text_data)
240
241        update_symlinks(manifest_name, link_path)
242        bb.plain("Image CVE report stored in: %s" % manifest_name)
243
244    if enable_json:
245        link_path = os.path.join(deploy_dir, "%s.json" % link_name)
246        manifest_name = d.getVar("CVE_CHECK_MANIFEST_JSON")
247
248        with open(manifest_name, "w") as f:
249            json.dump(json_data, f, indent=2)
250
251        update_symlinks(manifest_name, link_path)
252        bb.plain("Image CVE JSON report stored in: %s" % manifest_name)
253}
254
255ROOTFS_POSTPROCESS_COMMAND:prepend = "${@'cve_check_write_rootfs_manifest; ' if d.getVar('CVE_CHECK_CREATE_MANIFEST') == '1' else ''}"
256do_rootfs[recrdeptask] += "${@'do_cve_check' if d.getVar('CVE_CHECK_CREATE_MANIFEST') == '1' else ''}"
257do_populate_sdk[recrdeptask] += "${@'do_cve_check' if d.getVar('CVE_CHECK_CREATE_MANIFEST') == '1' else ''}"
258
259def check_cves(d, patched_cves):
260    """
261    Connect to the NVD database and find unpatched cves.
262    """
263    from oe.cve_check import Version
264
265    pn = d.getVar("PN")
266    real_pv = d.getVar("PV")
267    suffix = d.getVar("CVE_VERSION_SUFFIX")
268
269    cves_unpatched = []
270    cves_ignored = []
271    cves_status = []
272    cves_in_recipe = False
273    # CVE_PRODUCT can contain more than one product (eg. curl/libcurl)
274    products = d.getVar("CVE_PRODUCT").split()
275    # If this has been unset then we're not scanning for CVEs here (for example, image recipes)
276    if not products:
277        return ([], [], [], [])
278    pv = d.getVar("CVE_VERSION").split("+git")[0]
279
280    # If the recipe has been skipped/ignored we return empty lists
281    if pn in d.getVar("CVE_CHECK_SKIP_RECIPE").split():
282        bb.note("Recipe has been skipped by cve-check")
283        return ([], [], [], [])
284
285    cve_ignore = d.getVar("CVE_CHECK_IGNORE").split()
286
287    import sqlite3
288    db_file = d.expand("file:${CVE_CHECK_DB_FILE}?mode=ro")
289    conn = sqlite3.connect(db_file, uri=True)
290
291    # For each of the known product names (e.g. curl has CPEs using curl and libcurl)...
292    for product in products:
293        cves_in_product = False
294        if ":" in product:
295            vendor, product = product.split(":", 1)
296        else:
297            vendor = "%"
298
299        # Find all relevant CVE IDs.
300        cve_cursor = conn.execute("SELECT DISTINCT ID FROM PRODUCTS WHERE PRODUCT IS ? AND VENDOR LIKE ?", (product, vendor))
301        for cverow in cve_cursor:
302            cve = cverow[0]
303
304            if cve in cve_ignore:
305                bb.note("%s-%s ignores %s" % (product, pv, cve))
306                cves_ignored.append(cve)
307                continue
308            elif cve in patched_cves:
309                bb.note("%s has been patched" % (cve))
310                continue
311            # Write status once only for each product
312            if not cves_in_product:
313                cves_status.append([product, True])
314                cves_in_product = True
315                cves_in_recipe = True
316
317            vulnerable = False
318            ignored = False
319
320            product_cursor = conn.execute("SELECT * FROM PRODUCTS WHERE ID IS ? AND PRODUCT IS ? AND VENDOR LIKE ?", (cve, product, vendor))
321            for row in product_cursor:
322                (_, _, _, version_start, operator_start, version_end, operator_end) = row
323                #bb.debug(2, "Evaluating row " + str(row))
324                if cve in cve_ignore:
325                    ignored = True
326
327                if (operator_start == '=' and pv == version_start) or version_start == '-':
328                    vulnerable = True
329                else:
330                    if operator_start:
331                        try:
332                            vulnerable_start =  (operator_start == '>=' and Version(pv,suffix) >= Version(version_start,suffix))
333                            vulnerable_start |= (operator_start == '>' and Version(pv,suffix) > Version(version_start,suffix))
334                        except:
335                            bb.warn("%s: Failed to compare %s %s %s for %s" %
336                                    (product, pv, operator_start, version_start, cve))
337                            vulnerable_start = False
338                    else:
339                        vulnerable_start = False
340
341                    if operator_end:
342                        try:
343                            vulnerable_end  = (operator_end == '<=' and Version(pv,suffix) <= Version(version_end,suffix) )
344                            vulnerable_end |= (operator_end == '<' and Version(pv,suffix) < Version(version_end,suffix) )
345                        except:
346                            bb.warn("%s: Failed to compare %s %s %s for %s" %
347                                    (product, pv, operator_end, version_end, cve))
348                            vulnerable_end = False
349                    else:
350                        vulnerable_end = False
351
352                    if operator_start and operator_end:
353                        vulnerable = vulnerable_start and vulnerable_end
354                    else:
355                        vulnerable = vulnerable_start or vulnerable_end
356
357                if vulnerable:
358                    if ignored:
359                        bb.note("%s is ignored in %s-%s" % (cve, pn, real_pv))
360                        cves_ignored.append(cve)
361                    else:
362                        bb.note("%s-%s is vulnerable to %s" % (pn, real_pv, cve))
363                        cves_unpatched.append(cve)
364                    break
365            product_cursor.close()
366
367            if not vulnerable:
368                bb.note("%s-%s is not vulnerable to %s" % (pn, real_pv, cve))
369                patched_cves.add(cve)
370        cve_cursor.close()
371
372        if not cves_in_product:
373            bb.note("No CVE records found for product %s, pn %s" % (product, pn))
374            cves_status.append([product, False])
375
376    conn.close()
377
378    if not cves_in_recipe:
379        bb.note("No CVE records for products in recipe %s" % (pn))
380
381    return (list(cves_ignored), list(patched_cves), cves_unpatched, cves_status)
382
383def get_cve_info(d, cves):
384    """
385    Get CVE information from the database.
386    """
387
388    import sqlite3
389
390    cve_data = {}
391    db_file = d.expand("file:${CVE_CHECK_DB_FILE}?mode=ro")
392    conn = sqlite3.connect(db_file, uri=True)
393
394    for cve in cves:
395        cursor = conn.execute("SELECT * FROM NVD WHERE ID IS ?", (cve,))
396        for row in cursor:
397            cve_data[row[0]] = {}
398            cve_data[row[0]]["summary"] = row[1]
399            cve_data[row[0]]["scorev2"] = row[2]
400            cve_data[row[0]]["scorev3"] = row[3]
401            cve_data[row[0]]["modified"] = row[4]
402            cve_data[row[0]]["vector"] = row[5]
403        cursor.close()
404    conn.close()
405    return cve_data
406
407def cve_write_data_text(d, patched, unpatched, ignored, cve_data):
408    """
409    Write CVE information in WORKDIR; and to CVE_CHECK_DIR, and
410    CVE manifest if enabled.
411    """
412
413    cve_file = d.getVar("CVE_CHECK_LOG")
414    fdir_name  = d.getVar("FILE_DIRNAME")
415    layer = fdir_name.split("/")[-3]
416
417    include_layers = d.getVar("CVE_CHECK_LAYER_INCLUDELIST").split()
418    exclude_layers = d.getVar("CVE_CHECK_LAYER_EXCLUDELIST").split()
419
420    report_all = d.getVar("CVE_CHECK_REPORT_PATCHED") == "1"
421
422    if exclude_layers and layer in exclude_layers:
423        return
424
425    if include_layers and layer not in include_layers:
426        return
427
428    # Early exit, the text format does not report packages without CVEs
429    if not patched+unpatched+ignored:
430        return
431
432    nvd_link = "https://nvd.nist.gov/vuln/detail/"
433    write_string = ""
434    unpatched_cves = []
435    bb.utils.mkdirhier(os.path.dirname(cve_file))
436
437    for cve in sorted(cve_data):
438        is_patched = cve in patched
439        is_ignored = cve in ignored
440
441        if (is_patched or is_ignored) and not report_all:
442            continue
443
444        write_string += "LAYER: %s\n" % layer
445        write_string += "PACKAGE NAME: %s\n" % d.getVar("PN")
446        write_string += "PACKAGE VERSION: %s%s\n" % (d.getVar("EXTENDPE"), d.getVar("PV"))
447        write_string += "CVE: %s\n" % cve
448        if is_ignored:
449            write_string += "CVE STATUS: Ignored\n"
450        elif is_patched:
451            write_string += "CVE STATUS: Patched\n"
452        else:
453            unpatched_cves.append(cve)
454            write_string += "CVE STATUS: Unpatched\n"
455        write_string += "CVE SUMMARY: %s\n" % cve_data[cve]["summary"]
456        write_string += "CVSS v2 BASE SCORE: %s\n" % cve_data[cve]["scorev2"]
457        write_string += "CVSS v3 BASE SCORE: %s\n" % cve_data[cve]["scorev3"]
458        write_string += "VECTOR: %s\n" % cve_data[cve]["vector"]
459        write_string += "MORE INFORMATION: %s%s\n\n" % (nvd_link, cve)
460
461    if unpatched_cves and d.getVar("CVE_CHECK_SHOW_WARNINGS") == "1":
462        bb.warn("Found unpatched CVE (%s), for more information check %s" % (" ".join(unpatched_cves),cve_file))
463
464    with open(cve_file, "w") as f:
465        bb.note("Writing file %s with CVE information" % cve_file)
466        f.write(write_string)
467
468    if d.getVar("CVE_CHECK_COPY_FILES") == "1":
469        deploy_file = d.getVar("CVE_CHECK_RECIPE_FILE")
470        bb.utils.mkdirhier(os.path.dirname(deploy_file))
471        with open(deploy_file, "w") as f:
472            f.write(write_string)
473
474    if d.getVar("CVE_CHECK_CREATE_MANIFEST") == "1":
475        cvelogpath = d.getVar("CVE_CHECK_SUMMARY_DIR")
476        bb.utils.mkdirhier(cvelogpath)
477
478        with open(d.getVar("CVE_CHECK_TMP_FILE"), "a") as f:
479            f.write("%s" % write_string)
480
481def cve_check_write_json_output(d, output, direct_file, deploy_file, manifest_file):
482    """
483    Write CVE information in the JSON format: to WORKDIR; and to
484    CVE_CHECK_DIR, if CVE manifest if enabled, write fragment
485    files that will be assembled at the end in cve_check_write_rootfs_manifest.
486    """
487
488    import json
489
490    write_string = json.dumps(output, indent=2)
491    with open(direct_file, "w") as f:
492        bb.note("Writing file %s with CVE information" % direct_file)
493        f.write(write_string)
494
495    if d.getVar("CVE_CHECK_COPY_FILES") == "1":
496        bb.utils.mkdirhier(os.path.dirname(deploy_file))
497        with open(deploy_file, "w") as f:
498            f.write(write_string)
499
500    if d.getVar("CVE_CHECK_CREATE_MANIFEST") == "1":
501        cvelogpath = d.getVar("CVE_CHECK_SUMMARY_DIR")
502        index_path = d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")
503        bb.utils.mkdirhier(cvelogpath)
504        fragment_file = os.path.basename(deploy_file)
505        fragment_path = os.path.join(cvelogpath, fragment_file)
506        with open(fragment_path, "w") as f:
507            f.write(write_string)
508        with open(index_path, "a+") as f:
509            f.write("%s\n" % fragment_path)
510
511def cve_write_data_json(d, patched, unpatched, ignored, cve_data, cve_status):
512    """
513    Prepare CVE data for the JSON format, then write it.
514    """
515
516    output = {"version":"1", "package": []}
517    nvd_link = "https://nvd.nist.gov/vuln/detail/"
518
519    fdir_name  = d.getVar("FILE_DIRNAME")
520    layer = fdir_name.split("/")[-3]
521
522    include_layers = d.getVar("CVE_CHECK_LAYER_INCLUDELIST").split()
523    exclude_layers = d.getVar("CVE_CHECK_LAYER_EXCLUDELIST").split()
524
525    report_all = d.getVar("CVE_CHECK_REPORT_PATCHED") == "1"
526
527    if exclude_layers and layer in exclude_layers:
528        return
529
530    if include_layers and layer not in include_layers:
531        return
532
533    unpatched_cves = []
534
535    product_data = []
536    for s in cve_status:
537        p = {"product": s[0], "cvesInRecord": "Yes"}
538        if s[1] == False:
539            p["cvesInRecord"] = "No"
540        product_data.append(p)
541
542    package_version = "%s%s" % (d.getVar("EXTENDPE"), d.getVar("PV"))
543    package_data = {
544        "name" : d.getVar("PN"),
545        "layer" : layer,
546        "version" : package_version,
547        "products": product_data
548    }
549    cve_list = []
550
551    for cve in sorted(cve_data):
552        is_patched = cve in patched
553        is_ignored = cve in ignored
554        status = "Unpatched"
555        if (is_patched or is_ignored) and not report_all:
556            continue
557        if is_ignored:
558            status = "Ignored"
559        elif is_patched:
560            status = "Patched"
561        else:
562            # default value of status is Unpatched
563            unpatched_cves.append(cve)
564
565        issue_link = "%s%s" % (nvd_link, cve)
566
567        cve_item = {
568            "id" : cve,
569            "summary" : cve_data[cve]["summary"],
570            "scorev2" : cve_data[cve]["scorev2"],
571            "scorev3" : cve_data[cve]["scorev3"],
572            "vector" : cve_data[cve]["vector"],
573            "status" : status,
574            "link": issue_link
575        }
576        cve_list.append(cve_item)
577
578    package_data["issue"] = cve_list
579    output["package"].append(package_data)
580
581    direct_file = d.getVar("CVE_CHECK_LOG_JSON")
582    deploy_file = d.getVar("CVE_CHECK_RECIPE_FILE_JSON")
583    manifest_file = d.getVar("CVE_CHECK_SUMMARY_FILE_NAME_JSON")
584
585    cve_check_write_json_output(d, output, direct_file, deploy_file, manifest_file)
586
587def cve_write_data(d, patched, unpatched, ignored, cve_data, status):
588    """
589    Write CVE data in each enabled format.
590    """
591
592    if d.getVar("CVE_CHECK_FORMAT_TEXT") == "1":
593        cve_write_data_text(d, patched, unpatched, ignored, cve_data)
594    if d.getVar("CVE_CHECK_FORMAT_JSON") == "1":
595        cve_write_data_json(d, patched, unpatched, ignored, cve_data, status)
596