Message ID | 20241216080646.959345-1-hongxu.jia@windriver.com |
---|---|
State | New |
Headers | show |
Series | [V2] meta/lib/oe/sbom30.py: fix alias in simplelicensing_customIdToUri not extracted | expand |
On Mon, Dec 16, 2024 at 1:06 AM Hongxu Jia <hongxu.jia@windriver.com> wrote: > > After commit [spdx 3.0: Rework how SPDX aliases are linked] applied, it set > license_text_map with SPDX alias other than actual ID > > The property of simplelicensing_customIdToUri is ListProp(ObjectProp(DictionaryEntry))), > and class DictionaryEntry has key and value, the property of value is StringProp other > than ObjectProp in which could not support to decode/extract SPDX alias with actual ID > in image jsonld file > ----------- > "simplelicensing_customIdToUri": [ > { > "type": "DictionaryEntry", > "key": "LicenseRef-PD", > "value": "http://spdxdocs.org/openembedded-alias/by-doc-hash/d53e90e23b12c4ad640809a74a810e86f31c76cdbdf36487712d22a33d53362a/sqlite3-native/UNIHASH/license-text/PD" > } > ], > ----------- > > Add special code in the linking to manually go through all of the > simplelicensing_customIdToUri DictionaryEntry items and resolve > any aliases to actual objects > ----------- > "simplelicensing_customIdToUri": [ > { > "type": "DictionaryEntry", > "key": "LicenseRef-PD", > "value": "http://spdx.org/spdxdocs/sqlite3-native-e5cc0672-d8dd-57e8-a2df-fe4615831fda/162c62b5b011cd3f82f413b3dae4d6d1542201552c964d5ce69fe170e0720b85/license-text/PD" > } > ] > ----------- > > Suggested-by: jpewhacker@gmail.com > Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> > --- > meta/lib/oe/sbom30.py | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/meta/lib/oe/sbom30.py b/meta/lib/oe/sbom30.py > index 65603e69b7..ad2fce41d9 100644 > --- a/meta/lib/oe/sbom30.py > +++ b/meta/lib/oe/sbom30.py > @@ -855,6 +855,16 @@ class ObjectSet(oe.spdx30.SHACLObjectSet): > self.doc.import_ = sorted(imports.values(), key=lambda e: e.externalSpdxId) > bb.debug(1, "Linking...") > self.link() > + > + # Manually go through all of the simplelicensing_customIdToUri DictionaryEntry > + # items and resolve any aliases to actual objects. > + for lic in self.foreach_type(oe.spdx30.simplelicensing_LicenseExpression): > + for d in lic.simplelicensing_customIdToUri: > + if d.value.startswith(OE_ALIAS_PREFIX): > + obj = self.find_by_id(d.value) > + if obj is not None: > + d.value = obj._id This is correct, but you need to add: else: self.missing_ids.add(d.value) Otherwise LGTM > + > self.missing_ids -= set(imports.keys()) > return self.missing_ids > > -- > 2.25.1 >
OK, I will correct it in v3 //Hongxu
diff --git a/meta/lib/oe/sbom30.py b/meta/lib/oe/sbom30.py index 65603e69b7..ad2fce41d9 100644 --- a/meta/lib/oe/sbom30.py +++ b/meta/lib/oe/sbom30.py @@ -855,6 +855,16 @@ class ObjectSet(oe.spdx30.SHACLObjectSet): self.doc.import_ = sorted(imports.values(), key=lambda e: e.externalSpdxId) bb.debug(1, "Linking...") self.link() + + # Manually go through all of the simplelicensing_customIdToUri DictionaryEntry + # items and resolve any aliases to actual objects. + for lic in self.foreach_type(oe.spdx30.simplelicensing_LicenseExpression): + for d in lic.simplelicensing_customIdToUri: + if d.value.startswith(OE_ALIAS_PREFIX): + obj = self.find_by_id(d.value) + if obj is not None: + d.value = obj._id + self.missing_ids -= set(imports.keys()) return self.missing_ids
After commit [spdx 3.0: Rework how SPDX aliases are linked] applied, it set license_text_map with SPDX alias other than actual ID The property of simplelicensing_customIdToUri is ListProp(ObjectProp(DictionaryEntry))), and class DictionaryEntry has key and value, the property of value is StringProp other than ObjectProp in which could not support to decode/extract SPDX alias with actual ID in image jsonld file ----------- "simplelicensing_customIdToUri": [ { "type": "DictionaryEntry", "key": "LicenseRef-PD", "value": "http://spdxdocs.org/openembedded-alias/by-doc-hash/d53e90e23b12c4ad640809a74a810e86f31c76cdbdf36487712d22a33d53362a/sqlite3-native/UNIHASH/license-text/PD" } ], ----------- Add special code in the linking to manually go through all of the simplelicensing_customIdToUri DictionaryEntry items and resolve any aliases to actual objects ----------- "simplelicensing_customIdToUri": [ { "type": "DictionaryEntry", "key": "LicenseRef-PD", "value": "http://spdx.org/spdxdocs/sqlite3-native-e5cc0672-d8dd-57e8-a2df-fe4615831fda/162c62b5b011cd3f82f413b3dae4d6d1542201552c964d5ce69fe170e0720b85/license-text/PD" } ] ----------- Suggested-by: jpewhacker@gmail.com Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> --- meta/lib/oe/sbom30.py | 10 ++++++++++ 1 file changed, 10 insertions(+)