Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: validate now accepts components with external bom #308

277 changes: 157 additions & 120 deletions cdxev/auxiliary/schema/bom-1.3-custom.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@
"required": [
"type",
"name",
"version",
"bom-ref"
],
"properties": {
Expand Down Expand Up @@ -541,76 +540,140 @@
}
}
},
"allOf": [
"anyOf": [
{
"anyOf": [
{
"required": [
"licenses"
],
"properties": {
"licenses": {
"minItems": 1
}
}
},
{
"required": [
"copyright"
],
"properties": {
"copyright": {
"minLength": 1
}
}
"properties": {
"licenses": {
"minItems": 1
}
]
}
},
{
"anyOf": [
{
"required": [
"supplier"
]
},
{
"required": [
"author"
]
"properties": {
"copyright": {
"minLength": 1
}
]
},
{
"if": {
"properties": {
"copyright": {
"pattern": "([Ff][Ee][Ss][Tt][Oo])"
}
}
],
"if": {
"$comment": "This condition is true for components which reference an external SBOM. Most non-standard requirements don't apply to these components.",
"required": [
"externalReferences"
],
"properties": {
"externalReferences": {
"contains": {
"properties": {
"type": {
"const": "bom"
}
}
},
}
}
}
},
"then": {
"$comment": "This 'then' schema produces a validation error which helps the validator logic recognize a component as referencing an external SBOM. It will not make validation fail.",
"required": [
"this_is_an_externally_described_component"
]
},
"else": {
"$comment": "These requirements only apply to components which DO NOT reference an external SBOM.",
"allOf": [
{
"required": [
"copyright"
"version"
]
},
{
"anyOf": [
{
"required": [
"licenses"
]
},
{
"required": [
"copyright"
]
}
]
},
{
"anyOf": [
{
"required": [
"supplier"
]
},
{
"required": [
"author"
]
}
]
},
"then": {
{
"if": {
"not": {
"allOf": [
{
"required": [
"licenses"
]
},
{
"properties": {
"copyright": {
"pattern": "([Ff][Ee][Ss][Tt][Oo])"
}
},
"required": [
"copyright"
]
},
"then": {
"if": {
"not": {
"allOf": [
{
"required": [
"licenses"
]
},
{
"properties": {
"copyright": {
"pattern": "([Ff][Ee][Ss][Tt][Oo])"
}
}
}
]
}
},
"then": {
"properties": {
"supplier": {
"properties": {
"copyright": {
"name": {
"pattern": "([Ff][Ee][Ss][Tt][Oo])"
}
}
}
]
},
"required": [
"supplier"
],
"dependencies": {
"supplier": {
"properties": {
"supplier": {
"required": [
"name"
]
}
}
}
}
}
},
"then": {
}
},
{
"if": {
"properties": {
"supplier": {
"properties": {
Expand All @@ -634,53 +697,48 @@
}
}
}
}
}
},
{
"if": {
"properties": {
"supplier": {
"properties": {
"name": {
"pattern": "([Ff][Ee][Ss][Tt][Oo])"
}
}
}
},
"required": [
"supplier"
],
"dependencies": {
"supplier": {
"then": {
"if": {
"not": {
"allOf": [
{
"required": [
"licenses"
]
},
{
"properties": {
"copyright": {
"pattern": "([Ff][Ee][Ss][Tt][Oo])"
}
}
}
]
}
},
"then": {
"properties": {
"supplier": {
"required": [
"name"
]
"copyright": {
"pattern": "([Ff][Ee][Ss][Tt][Oo])"
}
}
},
"required": [
"copyright"
]
}
}
},
"then": {
{
"if": {
"not": {
"allOf": [
{
"required": [
"licenses"
]
},
{
"properties": {
"copyright": {
"pattern": "([Ff][Ee][Ss][Tt][Oo])"
}
}
}
]
}
"properties": {
"author": {
"pattern": "([Ff][Ee][Ss][Tt][Oo])"
}
},
"required": [
"author"
]
},
"then": {
"properties": {
Expand All @@ -693,30 +751,8 @@
]
}
}
},
{
"if": {
"properties": {
"author": {
"pattern": "([Ff][Ee][Ss][Tt][Oo])"
}
},
"required": [
"author"
]
},
"then": {
"properties": {
"copyright": {
"pattern": "([Ff][Ee][Ss][Tt][Oo])"
}
},
"required": [
"copyright"
]
}
}
],
]
},
"additionalProperties": false
},
"swid": {
Expand Down Expand Up @@ -1124,7 +1160,8 @@
"type": "string",
"title": "URL",
"description": "The URL to the external reference",
"format": "iri-reference"
"format": "iri-reference",
"minLength": 1
},
"comment": {
"type": "string",
Expand Down
Loading
Loading