spdx-3-model
spdx-3-model copied to clipboard
contentIdentifierValue must match contentIdentifierType
From ContentIdentifier:
[implicit] The contentIdentifierValue must match the selected contentIdentifierType.
Suggested SHACL shapes:
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix spdxcore: <https://spdx.org/rdf/3.0.1/terms/Core/> .
@prefix spdxsw: <https://spdx.org/rdf/3.0.1/terms/Software/> .
@prefix spdxswcontid: <https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/> .
spdxcore:ContentIdentifierValueShape
a sh:NodeShape ;
sh:targetClass spdxsw:ContentIdentifier ;
sh:or (
[
sh:property [
sh:path spdxsw:contentIdentifierType ;
sh:hasValue spdxswcontid:gitoid ;
],
[
sh:path spdxsw:contentIdentifierValue ;
sh:pattern "^gitoid:(blob|tree|commit|tag):(sha1:[a-f0-9]{40}|sha256:[a-f0-9]{64})$" ;
]
]
[
sh:property [
sh:path spdxsw:contentIdentifierType ;
sh:hasValue spdxswcontid:swhid ;
],
[
sh:path spdxsw:contentIdentifierValue ;
sh:pattern "^swh:1:(snp|rel|rev|dir|cnt):[a-f0-9]{40}(;(origin=[^;]+|visit=swh:1:(snp|rel|rev|dir|cnt):[a-f0-9]{40}|anchor=swh:1:(snp|rel|rev|dir|cnt):[a-f0-9]{40}|path=[^;]+|lines=[0-9]+(-[0-9]+)?|bytes=[0-9]+(-[0-9]+)?))*$" ;
]
]
) ;
sh:message "The contentIdentifierValue must match the selected contentIdentifierType."@en .
Test data:
@prefix ex: <http://example.org/ns#> .
@prefix spdxcore: <https://spdx.org/rdf/3.0.1/terms/Core/> .
@prefix spdxsw: <https://spdx.org/rdf/3.0.1/terms/Software/> .
@prefix spdxswcontid: <https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:ValidGitoidSha1
a spdxsw:ContentIdentifier ;
spdxsw:contentIdentifierType spdxswcontid:gitoid ;
spdxsw:contentIdentifierValue "gitoid:blob:sha1:261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64"^^xsd:anyURI .
ex:ValidGitoidSha256
a spdxsw:ContentIdentifier ;
spdxsw:contentIdentifierType spdxswcontid:gitoid ;
spdxsw:contentIdentifierValue "gitoid:commit:sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"^^xsd:anyURI .
ex:ValidSwhid
a spdxsw:ContentIdentifier ;
spdxsw:contentIdentifierType spdxswcontid:swhid ;
spdxsw:contentIdentifierValue "swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2"^^xsd:anyURI .
ex:InvalidGitoidSha1
a spdxsw:ContentIdentifier ;
spdxsw:contentIdentifierType spdxswcontid:gitoid ;
spdxsw:contentIdentifierValue "gitoid:blob:sha1:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"^^xsd:anyURI .
ex:InvalidGitoidSha256
a spdxsw:ContentIdentifier ;
spdxsw:contentIdentifierType spdxswcontid:gitoid ;
spdxsw:contentIdentifierValue "gitoid:invalid:sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"^^xsd:anyURI .
ex:InvalidSwhid
a spdxsw:ContentIdentifier ;
spdxsw:contentIdentifierType spdxswcontid:swhid ;
spdxsw:contentIdentifierValue "swh:1:snp:94a9ed024d38597 93618152ea559a168bbcbb5e2"^^xsd:anyURI .
Test script: https://raw.githubusercontent.com/condots/dots/refs/heads/main/scripts/shacl/test.py
Test results:
----------------------------------------------------------------------------------------------------
Severity: sh:Violation
Source Shape: spdxcore:ContentIdentifierValueShape
Focus Node: ex:InvalidSwhid
Value Node: ex:InvalidSwhid
Result Path: None
Message: The contentIdentifierValue must match the selected contentIdentifierType.
----------------------------------------------------------------------------------------------------
Severity: sh:Violation
Source Shape: spdxcore:ContentIdentifierValueShape
Focus Node: ex:InvalidGitoidSha1
Value Node: ex:InvalidGitoidSha1
Result Path: None
Message: The contentIdentifierValue must match the selected contentIdentifierType.
----------------------------------------------------------------------------------------------------
Severity: sh:Violation
Source Shape: spdxcore:ContentIdentifierValueShape
Focus Node: ex:InvalidGitoidSha256
Value Node: ex:InvalidGitoidSha256
Result Path: None
Message: The contentIdentifierValue must match the selected contentIdentifierType.
----------------------------------------------------------------------------------------------------
Found 3 SHACL violations!