Skip to content

Commit

Permalink
refactor(schema): simplify prefix validation regex (#280)
Browse files Browse the repository at this point in the history
Annoying yak shave:

- I have an ecosystem cross-reference unit test for osv.dev in the
works, which relies on using the regex in the schema definition,
verbatim.

- [Python 3.7 has a FutureWarning on set
constructs](https://docs.python.org/dev/whatsnew/3.7.html#re), where as
far as I can tell, `(:[[:digit:]]+)?` would need to be written as
`(:\[[:digit:]]+)?`, which isn't valid in the JSON Schema (more in
python/cpython#74534)

-
https://json-schema.org/draft/2020-12/json-schema-core#name-regular-expressions
says JSON Schema regex is ECMA-262, so what gets used in the schema
needs to be the subset that works with
https://docs.python.org/3/library/re.html

  - https://xkcd.com/1171/

---------

Signed-off-by: Andrew Pollock <[email protected]>
Signed-off-by: Andrew Pollock <[email protected]>
  • Loading branch information
andrewpollock authored Sep 15, 2024
1 parent 2e1329f commit b011fba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion validation/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
"type": "string",
"title": "Currently supported ecosystems",
"description": "These ecosystems are also documented at https://ossf.github.io/osv-schema/#affectedpackage-field",
"pattern": "^(AlmaLinux|Alpine|Android|Bioconductor|Bitnami|Chainguard|ConanCenter|CRAN|crates.io|Debian|GHC|GitHub Actions|GIT|Go|Hackage|Hex|Linux|Maven|npm|NuGet|openSUSE|OSS-Fuzz|Packagist|Photon OS|Pub|PyPI|Red Hat|Rocky Linux|RubyGems|SUSE|SwiftURL|Ubuntu|Wolfi)(:[[:digit:]]+)?"
"pattern": "^(AlmaLinux|Alpine|Android|Bioconductor|Bitnami|Chainguard|ConanCenter|CRAN|crates.io|Debian|GHC|GitHub Actions|GIT|Go|Hackage|Hex|Linux|Maven|npm|NuGet|openSUSE|OSS-Fuzz|Packagist|Photon OS|Pub|PyPI|Red Hat|Rocky Linux|RubyGems|SUSE|SwiftURL|Ubuntu|wolfi)(:[0-9]+)?"
},
"prefix": {
"type": "string",
Expand Down

0 comments on commit b011fba

Please sign in to comment.