create-spdx-2.2: Add support for custom Annotations
PATCH 1/1 create-spdx-2.2: Add support for custom Annotations
This change adds a new variable to track which recipe variables are added as SPDX Annotations.
Usage: add SPDX_CUSTOME_ANNOTATION_VARS = <some recipe variable>
The recipe spdx json will contain an annotation stanza that looks something like this:
"annotations": [
{
"annotationDate": "2023-02-13T19:44:20Z",
"annotationType": "OTHER",
"annotator": "Tool: oe-spdx-creator - 1.0",
"comment": "CUSTOM_VARIABLE=some value or string"
},--- meta/classes/create-spdx-2.2.bbclass | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
meta/classes/create-spdx-2.2.bbclass +6 -1
@@ -30,6 +30,8 @@ SPDX_PRETTY ??= "0" SPDX_LICENSES ??= "${COREBASE}/meta/files/spdx-licenses.json" +SPDX_CUSTOM_ANNOTATION_VARS ??= "" + SPDX_ORG ??= "OpenEmbedded ()" SPDX_SUPPLIER ??= "Organization: ${SPDX_ORG}" SPDX_SUPPLIER[doc] = "The SPDX PackageSupplier field for SPDX packages created from \
@@ -402,7 +404,6 @@ def collect_dep_sources(d, dep_recipes): return sources - python do_create_spdx() { from datetime import datetime, timezone import oe.sbom
@@ -479,6 +480,10 @@ python do_create_spdx() { if description: recipe.description = description + if d.getVar("SPDX_CUSTOM_ANNOTATION_VARS"): + for var in d.getVar('SPDX_CUSTOM_ANNOTATION_VARS').split(): + recipe.annotations.append(create_annotation(d, var + "=" + d.getVar(var))) + # Some CVEs may be patched during the build process without incrementing the version number, # so querying for CVEs based on the CPE id can lead to false positives. To account for this, # save the CVEs fixed by patches to source information field in the SPDX.
Signature · 1 line
2.25.1
Quoted 5 lines · Saul Wold
This change adds a new variable to track which recipe variables are added as SPDX Annotations.
Usage: add
SPDX_CUSTOME_ANNOTATION_VARS= <some recipe variable>
nit: CUSTOM
Quoted 39 lines
The recipe spdx json will contain an annotation stanza that looks something like this:
"annotations": [ { "annotationDate": "2023-02-13T19:44:20Z", "annotationType": "OTHER", "annotator": "Tool: oe-spdx-creator - 1.0", "comment": "CUSTOM_VARIABLE=some value or string" },Signed-off-by Saul Wold <[email protected]>--- meta/classes/create-spdx-2.2.bbclass | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)meta/classes/create-spdx-2.2.bbclass +2
-1@@ -30,6 +30,8 @@ SPDX_PRETTY ??= "0" SPDX_LICENSES ??= "${COREBASE}/meta/files/spdx-licenses.json" +SPDX_CUSTOM_ANNOTATION_VARS ??= "" + SPDX_ORG ??= "OpenEmbedded ()" SPDX_SUPPLIER ??= "Organization: ${SPDX_ORG}" SPDX_SUPPLIER[doc] = "The SPDX PackageSupplier field for SPDX packages created from \@@ -402,7 +404,6 @@ def collect_dep_sources(d, dep_recipes): return sources - python do_create_spdx() { from datetime import datetime, timezone import oe.sbom
meta/classes/create-spdx-2.2.bbclass python do_create_spdx() { · line 486
Quoted 7 lines
meta/classes/create-spdx-2.2.bbclass +4
-0@@ -479,6 +480,10 @@ python do_create_spdx() { if description: recipe.description = description + if d.getVar("SPDX_CUSTOM_ANNOTATION_VARS"): + for var in d.getVar('SPDX_CUSTOM_ANNOTATION_VARS').split(): + recipe.annotations.append(create_annotation(d, var + "=" + d.getVar(var))) +
Seems reasonable. If we need more configuration options, I think we can add it later with flags, e.g.
MY_VAR = "foo"
MY_VAR[spdx-annotator] = "Me!"
SPDX_CUSTOM_ANNOTATION_VARS = "MY_VAR"
Aslo, in the future if users want package annotations, we can probably do:
SPDX_CUSTOM_ANNOTATION_VARS:${PN}
Quoted 6 lines
meta/classes/create-spdx-2.2.bbclass +0
-1# Some CVEs may be patched during the build process without incrementing the version number, # so querying for CVEs based on the CPE id can lead to false positives. To account for this, # save the CVEs fixed by patches to source information field in the SPDX. --2.25.1
Quoted 9 lines · Joshua Watt
Quoted 5 lines · Saul Wold
This change adds a new variable to track which recipe variables are added as SPDX Annotations.
Usage: add
SPDX_CUSTOME_ANNOTATION_VARS= <some recipe variable>nit: CUSTOM
v2 will come shortly (I will try to address the flags)
Quoted 50 lines
Quoted 39 lines
The recipe spdx json will contain an annotation stanza that looks something like this:
"annotations": [ { "annotationDate": "2023-02-13T19:44:20Z", "annotationType": "OTHER", "annotator": "Tool: oe-spdx-creator - 1.0", "comment": "CUSTOM_VARIABLE=some value or string" },Signed-off-by Saul Wold <[email protected]>--- meta/classes/create-spdx-2.2.bbclass | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)meta/classes/create-spdx-2.2.bbclass +2
-1@@ -30,6 +30,8 @@ SPDX_PRETTY ??= "0" SPDX_LICENSES ??= "${COREBASE}/meta/files/spdx-licenses.json" +SPDX_CUSTOM_ANNOTATION_VARS ??= "" + SPDX_ORG ??= "OpenEmbedded ()" SPDX_SUPPLIER ??= "Organization: ${SPDX_ORG}" SPDX_SUPPLIER[doc] = "The SPDX PackageSupplier field for SPDX packages created from \@@ -402,7 +404,6 @@ def collect_dep_sources(d, dep_recipes): return sources - python do_create_spdx() { from datetime import datetime, timezone import oe.sbommeta/classes/create-spdx-2.2.bbclass python do_create_spdx() { · line 486
Quoted 7 lines
meta/classes/create-spdx-2.2.bbclass +4
-0@@ -479,6 +480,10 @@ python do_create_spdx() { if description: recipe.description = description + if d.getVar("SPDX_CUSTOM_ANNOTATION_VARS"): + for var in d.getVar('SPDX_CUSTOM_ANNOTATION_VARS').split(): + recipe.annotations.append(create_annotation(d, var + "=" + d.getVar(var))) +Seems reasonable. If we need more configuration options, I think we can add it later with flags, e.g.
Quoted 4 lines
MY_VAR= "foo"
MY_VAR[spdx-annotator] = "Me!"
SPDX_CUSTOM_ANNOTATION_VARS= "MY_VAR"
What did you think the output should be here? ie what does the comment line contain? Today the annotation would contain:
"comment": "MY_VAR=foo"
What should the comment line contain if a flag or multiple flags exists? Or the CUSTOM_ANNOTATION code only looks for one flag [spdx-annotator]?
"comment": "Me!=foo"
Thoughts?
Quoted 4 lines
Aslo, in the future if users want package annotations, we can probably do:
SPDX_CUSTOM_ANNOTATION_VARS:${PN}
Do you really mean SPDX_CUSTOM_ANNOTATIONS_VARS:pn-${PN}
I tested this and it appears to work, along with the :append:pn-${PN} style.
Sau!
Quoted 7 lines
Quoted 7 lines
meta/classes/create-spdx-2.2.bbclass +0
-1# Some CVEs may be patched during the build process without incrementing the version number, # so querying for CVEs based on the CPE id can lead to false positives. To account for this, # save the CVEs fixed by patches to source information field in the SPDX. --2.25.1
Quoted 5 lines · Saul Wold (local)
Quoted 2 lines · Joshua Watt
Quoted 1 line · Saul Wold
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
This change adds a new variable to track which recipe variables are added as SPDX Annotations.
Usage: add
SPDX_CUSTOME_ANNOTATION_VARS= <some recipe variable>nit: CUSTOM
v2 will come shortly (I will try to address the flags)
Sorry, I wasn't trying to say we needed to do that today; that was for posterity. I'm fine with omitting the flags and adding them in later if necessary; I don't have crystal ball to tell whats needed today, so it might be best to wait until we know.
Quoted 82 lines
Quoted 51 lines
Quoted 42 lines
The recipe spdx json will contain an annotation stanza that looks something like this:
"annotations": [
{
"annotationDate": "2023-02-13T19:44:20Z", "annotationType": "OTHER",
"annotator": "Tool: oe-spdx-creator - 1.0", "comment": "CUSTOM_VARIABLE=some value or string" },Signed-off-by Saul Wold <[email protected]>---
meta/classes/create-spdx-2.2.bbclass | 7 ++++++-1 file changed, 6 insertions(+), 1 deletion(-)meta/classes/create-spdx-2.2.bbclass +0
-0@@ -30,6 +30,8 @@ SPDX_PRETTY ??= "0"
SPDX_LICENSES??= "${COREBASE}/meta/files/spdx-licenses.json"meta/classes/create-spdx-2.2.bbclass +2
-0+SPDX_CUSTOM_ANNOTATION_VARS ??= "" +
SPDX_ORG??= "OpenEmbedded ()"
SPDX_SUPPLIER??= "Organization: ${SPDX_ORG}"
SPDX_SUPPLIER[doc] = "The SPDX PackageSupplier field for SPDX packages created from \meta/classes/create-spdx-2.2.bbclass +0
-0@@ -402,7 +404,6 @@ def collect_dep_sources(d, dep_recipes):return sources
-
pythondo_create_spdx(){
from datetime import datetime, timezone
import oe.sbommeta/classes/create-spdx-2.2.bbclass +0
-0@@ -479,6 +480,10 @@ python do_create_spdx() {if description:
recipe.description = descriptionQuoted 5 lines
+ if
d.getVar("SPDX_CUSTOM_ANNOTATION_VARS"):
+ for var in d.getVar('SPDX_CUSTOM_ANNOTATION_VARS').split():
+recipe.annotations.append(create_annotation(d, var + "=" + d.getVar(var)))
+Seems reasonable. If we need more configuration options, I think we can add it later with flags, e.g.
Quoted 4 lines
MY_VAR= "foo"
MY_VAR[spdx-annotator] = "Me!"
SPDX_CUSTOM_ANNOTATION_VARS= "MY_VAR"What did you think the output should be here? ie what does the comment line contain? Today the annotation would contain:
"comment": "MY_VAR=foo"
What should the comment line contain if a flag or multiple flags exists? Or the
CUSTOM_ANNOTATIONcode only looks for one flag [spdx-annotator]?"comment": "Me!=foo"
Thoughts?
Quoted 4 lines
Aslo, in the future if users want package annotations, we can probably do:
SPDX_CUSTOM_ANNOTATION_VARS:${PN}
Do you really mean SPDX_CUSTOM_ANNOTATIONS_VARS:pn-${PN}
I tested this and it appears to work, along with the :append:pn-${PN} style.
Sau!
Quoted 7 lines
Quoted 7 lines
# Some CVEs may be patched during the build process without incrementing the version number,
# so querying for CVEs based on the CPE id can lead to false positives. To account for this, # save the CVEs fixed by patches to source information field in the SPDX.Signature · 1 line
2.25.1