From e15e3622aa275290065f286fafe432ecb9c62bac Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Thu, 6 Feb 2025 11:57:26 +0100 Subject: [PATCH 1/7] chore: test protobuf acknowledged BC Signed-off-by: Jan Kowalleck --- tools/src/test/proto/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/src/test/proto/test.sh b/tools/src/test/proto/test.sh index d313af79..8e13d3cc 100755 --- a/tools/src/test/proto/test.sh +++ b/tools/src/test/proto/test.sh @@ -77,8 +77,8 @@ function schema-breaking-version () { --error-format "$LOG_FORMAT" } - # compare '1.6' '1.5' # <-- possible breaks are acknowledged - # compare '1.5' '1.4' # <-- possible breaks are acknowledged + compare '1.6' '1.5' || echo "possible breaks are acknowledged for this specific version only" + compare '1.5' '1.4' || echo "possible breaks are acknowledged for this specific version only" compare '1.4' '1.3' echo '>> OK.' >&2 From d858245b2dade3f68819ceff4f138a7104673d05 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Thu, 6 Feb 2025 12:24:17 +0100 Subject: [PATCH 2/7] versionCompare Signed-off-by: Jan Kowalleck --- tools/src/test/proto/buf_breaking-version.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/src/test/proto/buf_breaking-version.yaml b/tools/src/test/proto/buf_breaking-version.yaml index e3fecdfd..70b9d672 100644 --- a/tools/src/test/proto/buf_breaking-version.yaml +++ b/tools/src/test/proto/buf_breaking-version.yaml @@ -3,4 +3,12 @@ version: v2 breaking: # https://buf.build/docs/configuration/v2/buf-yaml#breaking use: # see https://buf.build/docs/breaking/overview#rules-and-categories - - WIRE \ No newline at end of file + - WIRE + exceptions: + - path: schema/bom-1.5.proto + except: + - RULE_ID + severity: WARN + # - 'schema/bom-1.5.proto' # possible breaks are acknowledged for this specific version only + #- 'schema/bom-1.6.proto' # possible breaks are acknowledged for this specific version only + # DO NOT ADD NEW VERSIONS HERE WITHOUT CONSULTING THE CDX CORE-WORKING-GROUP From a1a4033edfb91563fe285dd8ff9098896685d90e Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Thu, 6 Feb 2025 12:34:58 +0100 Subject: [PATCH 3/7] versionCompare Signed-off-by: Jan Kowalleck --- tools/src/test/proto/buf_breaking-version.yaml | 15 +++++++-------- tools/src/test/proto/test.sh | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/src/test/proto/buf_breaking-version.yaml b/tools/src/test/proto/buf_breaking-version.yaml index 70b9d672..582961fb 100644 --- a/tools/src/test/proto/buf_breaking-version.yaml +++ b/tools/src/test/proto/buf_breaking-version.yaml @@ -4,11 +4,10 @@ version: v2 breaking: # https://buf.build/docs/configuration/v2/buf-yaml#breaking use: # see https://buf.build/docs/breaking/overview#rules-and-categories - WIRE - exceptions: - - path: schema/bom-1.5.proto - except: - - RULE_ID - severity: WARN - # - 'schema/bom-1.5.proto' # possible breaks are acknowledged for this specific version only - #- 'schema/bom-1.6.proto' # possible breaks are acknowledged for this specific version only - # DO NOT ADD NEW VERSIONS HERE WITHOUT CONSULTING THE CDX CORE-WORKING-GROUP + ignore_only: + # DO NOT ADD NEW VERSIONS HERE WITHOUT CONSULTING THE CDX CORE-WORKING-GROUP + FIELD_WIRE_COMPATIBLE_CARDINALITY: + - 'schema/bom-1.6.proto' + - 'schema/bom-1.5.proto' + FIELD_WIRE_COMPATIBLE_TYPE: + - 'schema/bom-1.5.proto' diff --git a/tools/src/test/proto/test.sh b/tools/src/test/proto/test.sh index 8e13d3cc..ce3b60e9 100755 --- a/tools/src/test/proto/test.sh +++ b/tools/src/test/proto/test.sh @@ -50,7 +50,7 @@ function schema-breaking-version () { then LOG_FORMAT='github-actions' else - LOG_FORMAT='text' + LOG_FORMAT='json' fi function compare() { From 90da24a2920798a5692e1b535582d86bad4d8733 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Thu, 6 Feb 2025 12:36:05 +0100 Subject: [PATCH 4/7] versionCompare Signed-off-by: Jan Kowalleck --- tools/src/test/proto/buf_breaking-version.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/src/test/proto/buf_breaking-version.yaml b/tools/src/test/proto/buf_breaking-version.yaml index 582961fb..9ab71078 100644 --- a/tools/src/test/proto/buf_breaking-version.yaml +++ b/tools/src/test/proto/buf_breaking-version.yaml @@ -5,9 +5,11 @@ breaking: # https://buf.build/docs/configuration/v2/buf-yaml#breaking use: # see https://buf.build/docs/breaking/overview#rules-and-categories - WIRE ignore_only: - # DO NOT ADD NEW VERSIONS HERE WITHOUT CONSULTING THE CDX CORE-WORKING-GROUP + # possible breaks are acknowledged for this specific findings only FIELD_WIRE_COMPATIBLE_CARDINALITY: + # DO NOT ADD NEW VERSIONS HERE WITHOUT CONSULTING THE CDX CORE-WORKING-GROUP - 'schema/bom-1.6.proto' - 'schema/bom-1.5.proto' FIELD_WIRE_COMPATIBLE_TYPE: + # DO NOT ADD NEW VERSIONS HERE WITHOUT CONSULTING THE CDX CORE-WORKING-GROUP - 'schema/bom-1.5.proto' From 59e5441fcf0156b29fe3aa08f478de6b1a6b1690 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Thu, 6 Feb 2025 12:56:29 +0100 Subject: [PATCH 5/7] versionCompare Signed-off-by: Jan Kowalleck --- tools/src/test/proto/test.sh | 48 +++++++++++++----------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/tools/src/test/proto/test.sh b/tools/src/test/proto/test.sh index ce3b60e9..a4a4b166 100755 --- a/tools/src/test/proto/test.sh +++ b/tools/src/test/proto/test.sh @@ -13,6 +13,13 @@ REMOTE="https://github.com/${GITHUB_REPOSITORY:-CycloneDX/specification}.git" BUF_IMAGE_VERSION='1.50.0' BUF_IMAGE="bufbuild/buf:$BUF_IMAGE_VERSION" +LOG_FORMAT='text' # set to 'json' to see details +if [[ -n "${GITHUB_WORKFLOW:-}" ]] +then + LOG_FORMAT='github-actions' +fi + + ## ---- @@ -24,20 +31,13 @@ function prepare () { function schema-lint () { echo '> lint schema files' >&2 - if [[ -n "${GITHUB_WORKFLOW:-}" ]] - then - LOG_FORMAT='github-actions' - else - LOG_FORMAT='text' - fi - docker run --rm \ --volume "${ROOT_PATH}/${SCHEMA_DIR}:/workspace/${SCHEMA_DIR}:ro" \ --volume "${THIS_PATH}/buf_lint.yaml:/workspace/buf.yaml:ro" \ --workdir '/workspace' \ "$BUF_IMAGE" \ lint --path "$SCHEMA_DIR" \ - --error-format "$LOG_FORMAT" + --error-format "${LOG_FORMAT:-$LOG_FORMAT_DEFAULT}" echo '>> OK.' >&2 } @@ -46,19 +46,12 @@ function schema-lint () { function schema-breaking-version () { echo '> test schema for breaking changes against previous version' >&2 - if [[ -n "${GITHUB_WORKFLOW:-}" ]] - then - LOG_FORMAT='github-actions' - else - LOG_FORMAT='json' - fi - function compare() { - NEW="bom-${1}.proto" - OLD="bom-${2}.proto" + local NEW="bom-${1}.proto" + local OLD="bom-${2}.proto" - NEW_NP="$(mktemp)" - OLD_NP="$(mktemp)" + local NEW_NP="$(mktemp)" + local OLD_NP="$(mktemp)" # remove package identifier -> so that the comparisson works as expected sed 's/^package .*//' "${ROOT_PATH}/${SCHEMA_DIR}/${NEW}" > "$NEW_NP" @@ -87,13 +80,6 @@ function schema-breaking-version () { function schema-breaking-remote () { echo '> test schema for breaking changes against remote' >&2 - if [[ -n "${GITHUB_WORKFLOW:-}" ]] - then - LOG_FORMAT='github-actions' - else - LOG_FORMAT='text' - fi - docker run --rm \ --volume "${ROOT_PATH}/${SCHEMA_DIR}:/workspace/${SCHEMA_DIR}:ro" \ --volume "${THIS_PATH}/buf_breaking-remote.yaml:/workspace/buf.yaml:ro" \ @@ -110,10 +96,10 @@ function schema-functional () { echo '> test all examples against the respective schema' >&2 function validate() { - FILE="$1" - SCHEMA_VERS="$2" - SCHEMA_FILE="bom-${SCHEMA_VERS}.proto" - MESSAGE="cyclonedx.v${SCHEMA_VERS/./_}.Bom" + local FILE="$1" + local SCHEMA_VERS="$2" + local SCHEMA_FILE="bom-${SCHEMA_VERS}.proto" + local MESSAGE="cyclonedx.v${SCHEMA_VERS/./_}.Bom" echo ">> validate $(realpath --relative-to="$PWD" "$FILE") as ${MESSAGE} of ${SCHEMA_FILE}" >&2 @@ -133,7 +119,7 @@ function schema-functional () { shopt -s globstar for test_res in "$ROOT_PATH"/"$TEST_RES_DIR"/*/valid-*.textproto do - SCHEMA_VERS="$(basename "$(dirname "$test_res")")" + local SCHEMA_VERS="$(basename "$(dirname "$test_res")")" validate "$test_res" "$SCHEMA_VERS" done From d747f1578b57c58d0f42807bf1d52d497ea3b585 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Thu, 6 Feb 2025 12:59:13 +0100 Subject: [PATCH 6/7] versionCompare Signed-off-by: Jan Kowalleck --- tools/src/test/proto/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/test/proto/test.sh b/tools/src/test/proto/test.sh index a4a4b166..76f7a470 100755 --- a/tools/src/test/proto/test.sh +++ b/tools/src/test/proto/test.sh @@ -37,7 +37,7 @@ function schema-lint () { --workdir '/workspace' \ "$BUF_IMAGE" \ lint --path "$SCHEMA_DIR" \ - --error-format "${LOG_FORMAT:-$LOG_FORMAT_DEFAULT}" + --error-format "$LOG_FORMAT" echo '>> OK.' >&2 } From f99dd79096ed085833cbe7cdac47a6151efe6cb0 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Thu, 6 Feb 2025 13:03:25 +0100 Subject: [PATCH 7/7] versionCompare Signed-off-by: Jan Kowalleck --- tools/src/test/proto/test.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/src/test/proto/test.sh b/tools/src/test/proto/test.sh index 76f7a470..b1554770 100755 --- a/tools/src/test/proto/test.sh +++ b/tools/src/test/proto/test.sh @@ -50,8 +50,9 @@ function schema-breaking-version () { local NEW="bom-${1}.proto" local OLD="bom-${2}.proto" - local NEW_NP="$(mktemp)" - local OLD_NP="$(mktemp)" + local NEW_NP OLD_NP + NEW_NP="$(mktemp)" + OLD_NP="$(mktemp)" # remove package identifier -> so that the comparisson works as expected sed 's/^package .*//' "${ROOT_PATH}/${SCHEMA_DIR}/${NEW}" > "$NEW_NP" @@ -116,10 +117,11 @@ function schema-functional () { --to /dev/null } + local SCHEMA_VERS shopt -s globstar for test_res in "$ROOT_PATH"/"$TEST_RES_DIR"/*/valid-*.textproto do - local SCHEMA_VERS="$(basename "$(dirname "$test_res")")" + SCHEMA_VERS="$(basename "$(dirname "$test_res")")" validate "$test_res" "$SCHEMA_VERS" done