Skip to content

Commit

Permalink
[vigiles.bbclass] add default values to mandatory fields in SBOM
Browse files Browse the repository at this point in the history
Added "set_package_field_defaults" to set default values to missing mandatory fields.
Linuxlink expects these fields in the SBOM and would return 500 if these are missing.
  • Loading branch information
indresh-timesys committed Jul 13, 2023
1 parent 05bc6a4 commit a0c1f04
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions classes/vigiles.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,22 @@ def vigiles_image_collect(d):
elif "runtime" in component_type_list:
dict_out['packages'][dep]["comment"] = dependency_only_comment["runtime"]

def set_package_field_defaults(manifest):
for pkg, pkg_dict in manifest.get("packages", {}).items():
if not pkg_dict.get("version", ""):
pkg_dict["version"] = "unset"
if not pkg_dict.get("cve_version", ""):
pkg_dict["cve_version"] = pkg_dict["version"]
if not pkg_dict.get("name", ""):
pkg_dict["name"] = pkg
if not pkg_dict.get("cve_product", ""):
pkg_dict["cve_product"] = pkg
if not pkg_dict.get("license", ""):
pkg_dict["license"] = "unknown"
if not pkg_dict.get("checksums", ""):
pkg_dict["checksums"] = []
return manifest

sys_dict = vigiles_get_build_dict(d)

backfill_list = d.getVar('VIGILES_BACKFILL', True).split()
Expand Down Expand Up @@ -619,6 +635,9 @@ def vigiles_image_collect(d):
for key in pkg_list:
add_dependencies(key)

# Add default package fields
dict_out = set_package_field_defaults(dict_out)

return dict_out

python do_vigiles_image() {
Expand Down

0 comments on commit a0c1f04

Please sign in to comment.