From fb8b3140df38745ca873b330fd03986f1e29a4a1 Mon Sep 17 00:00:00 2001 From: bendo-eXX Date: Tue, 14 Apr 2026 14:54:04 +0200 Subject: [PATCH] fix(CSAF2.1): change relationships to product_paths --- .../mandatoryTests/mandatoryTest_6_1_44.js | 8 +- tests/csaf_2_1/mandatoryTest_6_1_44.js | 83 +++++++++++++++++++ 2 files changed, 87 insertions(+), 4 deletions(-) diff --git a/csaf_2_1/mandatoryTests/mandatoryTest_6_1_44.js b/csaf_2_1/mandatoryTests/mandatoryTest_6_1_44.js index 9adbfb1f..671deaff 100644 --- a/csaf_2_1/mandatoryTests/mandatoryTest_6_1_44.js +++ b/csaf_2_1/mandatoryTests/mandatoryTest_6_1_44.js @@ -47,7 +47,7 @@ const inputSchema = /** @type {const} */ ({ full_product_names: { elements: fullProductNameSchema, }, - relationships: { + product_paths: { elements: { additionalProperties: true, optionalProperties: { @@ -136,11 +136,11 @@ export function mandatoryTest_6_1_44(doc) { ) }) - doc.product_tree?.relationships?.forEach((relationship, index) => { - const fullProductName = relationship.full_product_name + doc.product_tree?.product_paths?.forEach((productPath, index) => { + const fullProductName = productPath.full_product_name if (fullProductName) { checkFullProductName( - `/product_tree/relationships/${index}/full_product_name`, + `/product_tree/product_paths/${index}/full_product_name`, fullProductName ) } diff --git a/tests/csaf_2_1/mandatoryTest_6_1_44.js b/tests/csaf_2_1/mandatoryTest_6_1_44.js index 5116d5fe..4e67b2a2 100644 --- a/tests/csaf_2_1/mandatoryTest_6_1_44.js +++ b/tests/csaf_2_1/mandatoryTest_6_1_44.js @@ -6,4 +6,87 @@ describe('mandatoryTest_6_1_44', function () { it('only runs on relevant documents', function () { assert.equal(mandatoryTest_6_1_44({ product_tree: 'mydoc' }).isValid, true) }) + + it('validates branches and skips invalid ones', function () { + assert.equal( + mandatoryTest_6_1_44({ + product_tree: { + branches: [ + { + product: { + product_identification_helper: { + serial_numbers: ['*P\\*\\*?\\*'], + }, + }, + branches: [ + { + product: 'invalid', + }, + { + branches: [{}], + }, + ], + }, + ], + }, + }).isValid, + true + ) + }) + + it('validates product_paths and skips invalid ones', function () { + assert.equal( + mandatoryTest_6_1_44({ + product_tree: { + product_paths: [ + { + full_product_name: { + serial_numbers: ['*P\\*\\*?\\*'], + }, + }, + {}, + ], + }, + }).isValid, + true + ) + }) + + it('detects invalid serial numbers in branches', function () { + assert.equal( + mandatoryTest_6_1_44({ + product_tree: { + branches: [ + { + product: { + product_identification_helper: { + serial_numbers: ['P*A*'], + }, + }, + }, + ], + }, + }).isValid, + false + ) + }) + + it('detects invalid serial numbers in product_paths', function () { + assert.equal( + mandatoryTest_6_1_44({ + product_tree: { + product_paths: [ + { + full_product_name: { + product_identification_helper: { + serial_numbers: ['P*A*'], + }, + }, + }, + ], + }, + }).isValid, + false + ) + }) })