summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorMarta Rybczynska <rybczynska@gmail.com>2022-03-29 14:54:31 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-03-30 13:07:41 +0100
commit777f1d42b62ab482efa5a24600f4aeba1b156c64 (patch)
tree57f34b66df4db825abf4802101e689ca38abd2c0 /meta/lib
parentbbdf96885dbd8c3f5e2e9f084571ca659a809016 (diff)
downloadpoky-777f1d42b62ab482efa5a24600f4aeba1b156c64.tar.gz
cve-check: add json format
Add an option to output the CVE check in a JSON-based format. This format is easier to parse in software than the original text-based one and allows post-processing by other tools. Output formats are now handed by CVE_CHECK_FORMAT_TEXT and CVE_CHECK_FORMAT_JSON. Both of them are enabled by default. The JSON output format gets generated in a similar way to the text format with the exception of the manifest: appending to JSON arrays requires parsing the file. Because of that we first write JSON fragments and then assemble them in one pass at the end. (From OE-Core rev: df567de36ae5964bee433ebb97e8bf702034994a) Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/cve_check.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/meta/lib/oe/cve_check.py b/meta/lib/oe/cve_check.py
index 0302beeb4a..e445b7a6ae 100644
--- a/meta/lib/oe/cve_check.py
+++ b/meta/lib/oe/cve_check.py
@@ -146,3 +146,19 @@ def get_cpe_ids(cve_product, version):
146 cpe_ids.append(cpe_id) 146 cpe_ids.append(cpe_id)
147 147
148 return cpe_ids 148 return cpe_ids
149
150def cve_check_merge_jsons(output, data):
151 """
152 Merge the data in the "package" property to the main data file
153 output
154 """
155 if output["version"] != data["version"]:
156 bb.error("Version mismatch when merging JSON outputs")
157 return
158
159 for product in output["package"]:
160 if product["name"] == data["package"][0]["name"]:
161 bb.error("Error adding the same package twice")
162 return
163
164 output["package"].append(data["package"][0])