Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion schema/2.0/model/cyclonedx-common-2.0.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@
"description": "Defines a syntax for representing two character language code (ISO-639) followed by an optional two character country code. The language code must be lower case. If the country code is specified, the country code must be upper case. The language code and country code must be separated by a minus sign. Examples: en, en-US, fr, fr-CA"
},
"signatures": {
"$ref": "cyclonedx-jss_X590_2023_10-2.0.schema.json#/$defs/signatures",
"$ref": "cyclonedx-jss_x590_2023_10-2.0.schema.json#/$defs/signatures",
"title": "Signatures",
"description": "Enveloped signatures in [JSON Signature Scheme (JSS/ITU-T X.590)](https://www.itu.int/epublications/publication/itu-t-x-590-2023-10-json-signature-scheme-jss)."
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://cyclonedx.org/schema/2.0/model/cyclonedx-jss_X590_2023_10-2.0.schema.json",
"$id": "https://cyclonedx.org/schema/2.0/model/cyclonedx-jss_x590_2023_10-2.0.schema.json",
"type": "null",
"title": "CycloneDX Model for JSON Signature Scheme (JSS)",
"$comment" : "OWASP CycloneDX is an Ecma International standard (ECMA-424) developed in collaboration between the OWASP Foundation and Ecma Technical Committee 54 (TC54). The standard is published under a royalty-free patent policy. This JSON schema is the reference implementation and is licensed under the Apache License 2.0.",
Expand Down
22 changes: 11 additions & 11 deletions tools/src/main/js/linter/checks/schema-id-pattern.check.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
/**
* CycloneDX Schema Linter - Schema ID Pattern Check
*
*
* Validates that the $id property of each modular schema matches
* the expected CycloneDX pattern.
*
*
* @license Apache-2.0
*/

import { LintCheck, registerCheck, Severity } from '../index.js';

/**
* Default pattern for CycloneDX schema IDs
*
*
* Valid patterns:
* https://cyclonedx.org/schema/bom-1.7.schema.json
* https://cyclonedx.org/schema/2.0/cyclonedx-2.0.schema.json
* https://cyclonedx.org/schema/2.0/model/cyclonedx-cryptography-2.0.schema.json
*
*
* Pattern breakdown:
* - Base URL: https://cyclonedx.org/schema/
* - Optional version path: e.g., 2.0/, 1.7/, 3.0/
* - Optional subdirectory: e.g., model/, extension/
* - Schema name: e.g., bom-1.7, cyclonedx-2.0, cyclonedx-cryptography-2.0
* - Extension: .schema.json
*/
const DEFAULT_PATTERN = '^https://cyclonedx\\.org/schema/(\\d+\\.\\d+/)?([a-z][a-z0-9-]*/)?[a-z][a-z0-9.-]*\\.schema\\.json$';
const DEFAULT_PATTERN = '^https://cyclonedx\\.org/schema/(\\d+\\.\\d+/)?([a-z][a-z0-9-]*/)?[a-z][a-z0-9_.-]*\\.schema\\.json$';

/**
* Check that validates schema $id follows expected pattern
Expand All @@ -42,7 +42,7 @@ class SchemaIdPatternCheck extends LintCheck {
async run(schema, rawContent, config = {}) {
const issues = [];
const pattern = new RegExp(config.pattern || DEFAULT_PATTERN);

// Check root $id
if (!schema.$id) {
issues.push(this.createIssue(
Expand All @@ -54,13 +54,13 @@ class SchemaIdPatternCheck extends LintCheck {
issues.push(this.createIssue(
`Schema $id does not match expected pattern. Got: "${schema.$id}"`,
'$.$id',
{
{
actual: schema.$id,
expectedPattern: pattern.toString()
}
));
}

// Check for valid $id format (must be a valid URI)
if (schema.$id) {
try {
Expand All @@ -73,7 +73,7 @@ class SchemaIdPatternCheck extends LintCheck {
));
}
}

// Optionally check for $id in definitions (for modular schemas)
if (config.checkDefinitions !== false && schema.definitions) {
for (const [defName, def] of Object.entries(schema.definitions)) {
Expand All @@ -89,7 +89,7 @@ class SchemaIdPatternCheck extends LintCheck {
}
}
}

// Check $defs (JSON Schema draft-2019-09+)
if (config.checkDefinitions !== false && schema.$defs) {
for (const [defName, def] of Object.entries(schema.$defs)) {
Expand All @@ -105,7 +105,7 @@ class SchemaIdPatternCheck extends LintCheck {
}
}
}

return issues;
}
}
Expand Down
Loading