specification icon indicating copy to clipboard operation
specification copied to clipboard

[2.0]: dont use non-standard modifiers in patterns

Open jkowalleck opened this issue 4 months ago • 2 comments

https://json-schema.org/understanding-json-schema/reference/regular_expressions mentions to use only common/standard regex features

this means, to not use any modifiers

  • non-capturing groups (?:foo)
  • and any other modifiers - https://www.regular-expressions.info/refmodifiers.html

things to fix:

  • https://github.com/CycloneDX/specification/blob/2a860677bc58cc9accd7c8810eee1b4f29ce3343/schema/2.0/model/cyclonedx-common-2.0.schema.json#L139
  • to be continued

tooling

have a QA tool that asserts that only those common/standard regex patterns are used

jkowalleck avatar Jul 29 '26 19:07 jkowalleck

@jkowalleck do you need help with this one, or can I work on it? On 2.0-dev I only see (?: left in base64 in common and in the two timestamp patterns of the jss_X590 module, so I would swap those for plain groups and add a semantic test that fails on modifiers other than lookahead and on \d/\w/\s. That would cover the QA part of #988 too. Happy to leave it if you are already on it.

cvas22 avatar Nov 21 '26 08:11 cvas22

@cvas22 , having a linter for this one would be a nice-to-have feature, but it is not actually a blocker for the CDX 2.0 release. Any help with this would be appreciated. So if you could add a linter for pattern-best-practice that checks #989 and #988 would be fantastic.

After the linter is done, we can fork on individual fixing the JSON schema files.

PS: adding new test fixtures to the test suite is always welcome!

jkowalleck avatar Nov 23 '26 09:11 jkowalleck