Skip to content

[Defect]: JS functional tests fail for 2.0 (schema path + Ajv 2020-12 meta-schema) #835

@Mehrn0ush

Description

@Mehrn0ush

Describe the defect

tools/src/test/js/json-schema-functional-tests.js fails when run with -v 2.0.

There are two concrete causes:

  1. Schema path mismatch
    The harness currently expects schema/bom-2.0.schema.json, but the CycloneDX 2.0 schema is located under schema/2.0/ (e.g. schema/2.0/cyclonedx-2.0.schema.json).

  2. Ajv draft 2020-12 meta-schema not loaded
    When compiling the 2.0 schema (which declares $schema: https://json-schema.org/draft/2020-12/schema), Ajv throws:
    Error: no schema with key or ref "https://json-schema.org/draft/2020-12/schema"

This prevents functional validation of the 2.0 test vectors under tools/src/test/resources/2.0.

  1. 2.0 cryptography test vectors out of sync with schema
    A few 2.0 "valid-*" cryptography examples use string values where the bundled 2.0 schema defines arrays
    (e.g. algorithmProperties.implementationPlatform and securedBy.algorithmRef). These vectors fail
    validation until updated to match the schema.

Steps to reproduce

From repo root:

cd tools/src/test/js
npm install
node json-schema-functional-tests.js -v 2.0

Proposed fix:
Update the affected 2.0 cryptography test vectors to align with the bundled schema (wrap single values in one-element arrays).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions