diff options
author | Marta Rybczynska <rybczynska@gmail.com> | 2022-04-22 16:17:50 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-05-03 17:50:06 +0100 |
commit | dcd40cfa375c272eda1ccc3063a48c5ec0a50ab5 (patch) | |
tree | 51411d9ff97fc5923fb1652ac0a41d4ce9906b01 /meta/lib | |
parent | 5b0093ecee4b249da588524ec13c5a86029fe1c1 (diff) | |
download | poky-dcd40cfa375c272eda1ccc3063a48c5ec0a50ab5.tar.gz |
cve-check: add json format
Backport to dunfell from master df567de36ae5964bee433ebb97e8bf702034994a
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. The text format is enabled by default
to maintain compatibility, while the JSON format is disabled
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: 92b6011ab25fd36e2f8900a4db6883cdebc3cd3d)
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oe/cve_check.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/meta/lib/oe/cve_check.py b/meta/lib/oe/cve_check.py index a1d7c292af..1d3c775bbe 100644 --- a/meta/lib/oe/cve_check.py +++ b/meta/lib/oe/cve_check.py | |||
@@ -63,3 +63,19 @@ def _cmpkey(release, patch_l, pre_l, pre_v): | |||
63 | else: | 63 | else: |
64 | _pre = float(pre_v) if pre_v else float('-inf') | 64 | _pre = float(pre_v) if pre_v else float('-inf') |
65 | return _release, _patch, _pre | 65 | return _release, _patch, _pre |
66 | |||
67 | def cve_check_merge_jsons(output, data): | ||
68 | """ | ||
69 | Merge the data in the "package" property to the main data file | ||
70 | output | ||
71 | """ | ||
72 | if output["version"] != data["version"]: | ||
73 | bb.error("Version mismatch when merging JSON outputs") | ||
74 | return | ||
75 | |||
76 | for product in output["package"]: | ||
77 | if product["name"] == data["package"][0]["name"]: | ||
78 | bb.error("Error adding the same package twice") | ||
79 | return | ||
80 | |||
81 | output["package"].append(data["package"][0]) | ||