Skip to contentSkip to conversation

Add CPE_NAME to os-release

PATCH Superseded Armin Kuster 2 participants 4 messages May 3, 2023

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Add CPE_NAME to os-release

I am sending this change as several recipes in meta-security interogate the system to determine which OS is running so that they can behave accordingly. I would prefer core carry this rather than meta-security. This may also help with the overall OE/Yocto Security story.

Armin Kuster (1):
os-release: Add CPE_NAME

 meta/recipes-core/os-release/os-release.bb | 8 ++++++++
 1 file changed, 8 insertions(+)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/1 os-release: Add CPE_NAME

Its time we add the CPE_NAME to os-release.

The vendor field is hardcoded to "openembedded" as it is the base framework. We will use "DISTRO" to identify which variation of openembedded is being used.

---
 meta/recipes-core/os-release/os-release.bb | 8 ++++++++
 1 file changed, 8 insertions(+)
meta/recipes-core/os-release/os-release.bb +8 -0
index 860ee97224..aa37dec7c7 100644
@@ -16,6 +16,7 @@ do_configure[noexec] = "1"
 #                     HOME_URL SUPPORT_URL BUG_REPORT_URL
 OS_RELEASE_FIELDS = "\
     ID ID_LIKE NAME VERSION VERSION_ID VERSION_CODENAME PRETTY_NAME \
+    CPE_NAME \
 "
 OS_RELEASE_UNQUOTED_FIELDS = "ID VERSION_ID VARIANT_ID"
 
@@ -25,6 +26,13 @@ VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in
 VERSION_ID = "${DISTRO_VERSION}"
 VERSION_CODENAME = "${DISTRO_CODENAME}"
 PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"
+
+# The vendor field is hardcoded to "openembedded" as it is the base
+# framework for all derivatives Distos.
+# We use "DISTRO" to identify which variation of openembedded core 
+# is being used. 
+CPE_NAME="cpe:/o:openembedded:${DISTRO}:${VERSION_ID}"
+
 BUILD_ID ?= "${DATETIME}"
 BUILD_ID[vardepsexclude] = "DATETIME"
 
Signature · 1 line
2.25.1
#2 lore raw

Re: [OE-core] [PATCH 1/1] os-release: Add CPE_NAME

Quoted 27 lines · Armin Kuster

Its time we add the CPE_NAME to os-release.

The vendor field is hardcoded to "openembedded" as it is the base framework. We will use "DISTRO" to identify which variation of openembedded is being used.

---
 meta/recipes-core/os-release/os-release.bb | 8 ++++++++
 1 file changed, 8 insertions(+)
meta/recipes-core/os-release/os-release.bb +1 -0
index 860ee97224..aa37dec7c7 100644
@@ -16,6 +16,7 @@ do_configure[noexec] = "1"
 #                     HOME_URL SUPPORT_URL BUG_REPORT_URL
 OS_RELEASE_FIELDS = "\
     ID ID_LIKE NAME VERSION VERSION_ID VERSION_CODENAME PRETTY_NAME \
+    CPE_NAME \
 "
 OS_RELEASE_UNQUOTED_FIELDS = "ID VERSION_ID VARIANT_ID"
 
@@ -25,6 +26,13 @@ VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in
 VERSION_ID = "${DISTRO_VERSION}"
 VERSION_CODENAME = "${DISTRO_CODENAME}"
 PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"

meta/recipes-core/os-release/os-release.bb VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in · line 38

Quoted 10 lines
meta/recipes-core/os-release/os-release.bb +7 -0
+
+# The vendor field is hardcoded to "openembedded" as it is the base
+# framework for all derivatives Distos.
+# We use "DISTRO" to identify which variation of openembedded core 
+# is being used. 
+CPE_NAME="cpe:/o:openembedded:${DISTRO}:${VERSION_ID}"
+
 BUILD_ID ?= "${DATETIME}"
 BUILD_ID[vardepsexclude] = "DATETIME"
 

I know a bit more about the context of this and I don't think it is clear in the above comment. I'd like to suggest something a little stronger, how about:

"""
The vendor field is hardcoded to "openembedded" deliberately. We'd advise developers leave it as this value to clearly identify the underlying build environment from which the OS was constructed. We understand people will want to identify themselves as the people who built the image, we'd suggest using the DISTRO element to do this, so that is customisable.
This end result combines to mean systems can be traced back to both who built them and which system was used, which is ultimately the goal of the CPE.
"""

Perhaps we'd also want to do:

CPE_DISTRO ??= "${DISTRO}" CPE_NAME="cpe:/o:openembedded:${CPE_DISTRO}:${VERSION_ID}"

to make it clear we're suggesting which bit be customised?

Cheers,

Richard

author
#3 lore raw

Re: [OE-core] [PATCH 1/1] os-release: Add CPE_NAME

Quoted 42 lines · Richard Purdie
Quoted 27 lines · Armin Kuster

Its time we add the CPE_NAME to os-release.

The vendor field is hardcoded to "openembedded" as it is the base framework. We will use "DISTRO" to identify which variation of openembedded is being used.

---
  meta/recipes-core/os-release/os-release.bb | 8 ++++++++
  1 file changed, 8 insertions(+)
meta/recipes-core/os-release/os-release.bb +1 -0
index 860ee97224..aa37dec7c7 100644
@@ -16,6 +16,7 @@ do_configure[noexec] = "1"
  #                     HOME_URL SUPPORT_URL BUG_REPORT_URL
  OS_RELEASE_FIELDS = "\
      ID ID_LIKE NAME VERSION VERSION_ID VERSION_CODENAME PRETTY_NAME \
+    CPE_NAME \
  "
  OS_RELEASE_UNQUOTED_FIELDS = "ID VERSION_ID VARIANT_ID"
 
@@ -25,6 +26,13 @@ VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in
  VERSION_ID = "${DISTRO_VERSION}"
  VERSION_CODENAME = "${DISTRO_CODENAME}"
  PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"

meta/recipes-core/os-release/os-release.bb VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in · line 38

Quoted 10 lines
meta/recipes-core/os-release/os-release.bb +7 -0
+
+# The vendor field is hardcoded to "openembedded" as it is the base
+# framework for all derivatives Distos.
+# We use "DISTRO" to identify which variation of openembedded core
+# is being used.
+CPE_NAME="cpe:/o:openembedded:${DISTRO}:${VERSION_ID}"
+
  BUILD_ID ?= "${DATETIME}"
  BUILD_ID[vardepsexclude] = "DATETIME"
 

I know a bit more about the context of this and I don't think it is clear in the above comment. I'd like to suggest something a little stronger, how about:

Quoted 11 lines

"""
The vendor field is hardcoded to "openembedded" deliberately. We'd advise developers leave it as this value to clearly identify the underlying build environment from which the OS was constructed. We understand people will want to identify themselves as the people who built the image, we'd suggest using the DISTRO element to do this, so that is customisable.
This end result combines to mean systems can be traced back to both who built them and which system was used, which is ultimately the goal of the CPE.
"""

Works for me.

Quoted 4 lines

Perhaps we'd also want to do:

CPE_DISTRO ??= "${DISTRO}" CPE_NAME="cpe:/o:openembedded:${CPE_DISTRO}:${VERSION_ID}"

Like this better.

Quoted 2 lines

to make it clear we're suggesting which bit be customised?

Thanks for the review. v2 shortly.

-armin

Quoted 8 lines

Cheers,

Richard