Skip to content

Commit 59ad322

Browse files
committed
MDEV-34979 postfix
Do not produce CPE element in SBOM, if mariadb-connector-c commit hash is not tagged (and thus does not correspond to any released version)
1 parent 33e0796 commit 59ad322

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cmake/generate_sbom.cmake

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ FUNCTION(SBOM_GET_CPE name version var)
4848
"boost" "boost:boost"
4949
"thrift" "apache:thrift"
5050
)
51-
LIST(FIND cpe_prefix_map "${name}" i)
52-
IF(i GREATER -1)
53-
MATH(EXPR next_idx "${i}+1")
51+
LIST(FIND cpe_prefix_map "${name}" idx_cpe_mapping)
52+
# Version needs to have at least one dot character in it.
53+
# Otherwise, we assume it is a git hash, and do not generate CPE
54+
STRING(FIND "${version}" "." idx_version_dot)
55+
IF((idx_cpe_mapping GREATER -1) AND (idx_version_dot GREATER -1))
56+
MATH(EXPR next_idx "${idx_cpe_mapping}+1")
5457
LIST(GET cpe_prefix_map ${next_idx} cpe_name_and_vendor)
5558
STRING(REGEX REPLACE "[^0-9\\.]" "" cleaned_version "${version}")
5659
SET(${var} "cpe:2.3:a:${cpe_name_and_vendor}:${cleaned_version}:*:*:*:*:*:*:*" PARENT_SCOPE)
@@ -101,10 +104,9 @@ FUNCTION (sbom_get_supplier repo_name repo_user varname)
101104
SET(${varname} "MariaDB" PARENT_SCOPE)
102105
ELSEIF (repo_name MATCHES "boost")
103106
SET(${varname} "Boost.org" PARENT_SCOPE)
107+
ELSEIF(repo_user MATCHES "mariadb-corporation|mariadb")
108+
SET(${varname} "MariaDB")
104109
ELSE()
105-
IF(repo_user MATCHES "mariadb-corporation|mariadb")
106-
set(repo_user "MariaDB")
107-
ENDIF()
108110
# Capitalize just first letter in repo_user
109111
STRING(SUBSTRING "${repo_user}" 0 1 first_letter)
110112
STRING(SUBSTRING "${repo_user}" 1 -1 rest)

0 commit comments

Comments
 (0)