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

Issue 606: Enforce InformationResource and NeverInformationResource disjointedness #613

Closed
wants to merge 7 commits into from
Closed
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
42 changes: 42 additions & 0 deletions ontology/uco/core/core.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,26 @@ core:IdentityAbstraction
sh:targetClass core:IdentityAbstraction ;
.

core:InformationResource
a
owl:Class ,
sh:NodeShape
;
rdfs:subClassOf core:UcoThing ;
owl:disjointWith core:NeverInformationResource ;
sh:targetClass core:InformationResource ;
.

core:InformationResource-disjointWith-NeverInformationResource-shape
a sh:NodeShape ;
sh:message "core:InformationResource and core:NeverInformationResource are disjoint classes."@en ;
sh:not [
a sh:NodeShape ;
sh:class core:NeverInformationResource ;
] ;
sh:targetClass core:InformationResource ;
.

core:Item
a
owl:Class ,
Expand Down Expand Up @@ -317,6 +337,24 @@ core:ModusOperandi
sh:targetClass core:ModusOperandi ;
.

core:NeverInformationResource
a
owl:Class ,
sh:NodeShape
;
rdfs:subClassOf core:NonInformationResource ;
sh:targetClass core:NeverInformationResource ;
.

core:NonInformationResource
a
owl:Class ,
sh:NodeShape
;
rdfs:subClassOf core:UcoThing ;
sh:targetClass core:NonInformationResource ;
.

core:Relationship
a
owl:Class ,
Expand Down Expand Up @@ -484,6 +522,7 @@ core:UcoThing-identifier-regex-shape
a sh:NodeShape ;
rdfs:comment "This shape is given an independent IRI for applications that have sufficient controls in place to deactivate this advisory of node identification practice."@en ;
rdfs:seeAlso sh:deactivated ;
sh:description "This shape advises that nodes identify themselves with IRIs that are sufficiently unique that collisions between independent node assigners are unlikely. This shape excepts nodes that are explicitly typed as Information Resources."@en ;
sh:severity sh:Info ;
sh:sparql [
a sh:SPARQLConstraint ;
Expand All @@ -495,6 +534,9 @@ core:UcoThing-identifier-regex-shape
SELECT $this
WHERE {
$this a/rdfs:subClassOf* core:UcoThing .
FILTER NOT EXISTS {
$this a/rdfs:subClassOf* core:InformationResource .
}
FILTER (
! REGEX (
STR($this),
Expand Down
10 changes: 8 additions & 2 deletions ontology/uco/identity/identity.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ identity:Organization
owl:Class ,
sh:NodeShape
;
rdfs:subClassOf identity:Identity ;
rdfs:subClassOf
core:NeverInformationResource ,
identity:Identity
;
rdfs:label "Organization"@en ;
rdfs:comment "An organization is a grouping of identifying characteristics unique to a group of people who work together in an organized way for a shared purpose. [based on https://dictionary.cambridge.org/us/dictionary/english/organization]"@en ;
sh:targetClass identity:Organization ;
Expand All @@ -182,7 +185,10 @@ identity:Person
owl:Class ,
sh:NodeShape
;
rdfs:subClassOf identity:Identity ;
rdfs:subClassOf
core:NeverInformationResource ,
identity:Identity
;
rdfs:label "Person"@en ;
rdfs:comment "A person is a grouping of identifying characteristics unique to a human being regarded as an individual. [based on https://www.lexico.com/en/definition/person]"@en ;
sh:targetClass identity:Person ;
Expand Down
21 changes: 19 additions & 2 deletions ontology/uco/observable/observable.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -2214,7 +2214,10 @@ observable:Device
owl:Class ,
sh:NodeShape
;
rdfs:subClassOf observable:ObservableObject ;
rdfs:subClassOf
core:NeverInformationResource ,
observable:ObservableObject
;
rdfs:label "Device"@en ;
rdfs:comment "A device is a piece of equipment or a mechanism designed to serve a special purpose or perform a special function. [based on https://www.merriam-webster.com/dictionary/device]"@en ;
sh:targetClass observable:Device ;
Expand Down Expand Up @@ -7350,12 +7353,26 @@ observable:WebPage
owl:Class ,
sh:NodeShape
;
rdfs:subClassOf observable:ObservableObject ;
rdfs:subClassOf
core:InformationResource ,
observable:WebResource
;
rdfs:label "WebPage"@en ;
rdfs:comment "A web page is a specific collection of information provided by a website and displayed to a user in a web browser. A website typically consists of many web pages linked together in a coherent fashion. [based on https://en.wikipedia.org/wiki/Web_page]"@en ;
sh:targetClass observable:WebPage ;
.

observable:WebResource
a
owl:Class ,
sh:NodeShape
;
rdfs:subClassOf observable:ObservableObject ;
rdfs:label "WebResource"@en ;
rdfs:seeAlso <https://www.rfc-editor.org/rfc/rfc9110.html#name-resources> ;
sh:targetClass observable:WebResource ;
.

observable:WhoIs
a
owl:Class ,
Expand Down
11 changes: 9 additions & 2 deletions ontology/uco/types/types.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ types:Dictionary
owl:Class ,
sh:NodeShape
;
rdfs:subClassOf core:UcoInherentCharacterizationThing ;
rdfs:subClassOf
core:NeverInformationResource ,
core:UcoInherentCharacterizationThing
;
rdfs:label "Dictionary"@en ;
rdfs:comment "A dictionary is list of (term/key, value) pairs with each term/key existing no more than once."@en ;
sh:property [
Expand Down Expand Up @@ -101,7 +104,10 @@ types:Hash
owl:Class ,
sh:NodeShape
;
rdfs:subClassOf core:UcoInherentCharacterizationThing ;
rdfs:subClassOf
core:NeverInformationResource ,
core:UcoInherentCharacterizationThing
;
rdfs:label "Hash"@en ;
rdfs:comment "A hash is a grouping of characteristics unique to the result of applying a mathematical algorithm that maps data of arbitrary size to a bit string (the 'hash') and is a one-way function, that is, a function which is practically infeasible to invert. This is commonly used for integrity checking of data. [based on https://en.wikipedia.org/wiki/Cryptographic_hash_function]"@en ;
sh:property
Expand Down Expand Up @@ -184,6 +190,7 @@ types:Thread
;
rdfs:subClassOf
co:Bag ,
core:NeverInformationResource ,
core:UcoInherentCharacterizationThing
;
rdfs:label "Thread"@en ;
Expand Down
4 changes: 4 additions & 0 deletions tests/examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ all: \
has_facet_inverse_functional_XFAIL_validation.ttl \
hash_PASS_validation.ttl \
hash_XFAIL_validation.ttl \
information_resource_PASS_validation.ttl \
information_resource_XFAIL_validation.ttl \
location_PASS_validation.ttl \
location_XFAIL_validation.ttl \
message_thread_PASS_validation.ttl \
Expand Down Expand Up @@ -108,6 +110,8 @@ check: \
has_facet_inverse_functional_XFAIL_validation.ttl \
hash_PASS_validation.ttl \
hash_XFAIL_validation.ttl \
information_resource_PASS_validation.ttl \
information_resource_XFAIL_validation.ttl \
location_PASS_validation.ttl \
location_XFAIL_validation.ttl \
message_thread_PASS_validation.ttl \
Expand Down
71 changes: 71 additions & 0 deletions tests/examples/information_resource_PASS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"@context": {
"core": "https://ontology.unifiedcyberontology.org/uco/core/",
"kb": "http://example.org/kb/",
"identity": "https://ontology.unifiedcyberontology.org/uco/identity/",
"observable": "https://ontology.unifiedcyberontology.org/uco/observable/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#"
},
"@graph": [
{
"@id": "http://example.org/~bob",
"@type": "observable:WebResource",
"core:name": "Bob",
"core:description": "Bob's company home page.",
"rdfs:seeAlso": [
{
"@id": "kb:Person-a3d3af3d-ea1d-47f6-bc02-ac334ded6549"
},
{
"@id": "kb:WebPage-1c05c378-124e-4d3c-898a-fb5a8d178cf8"
}
]
},

{
"@id": "kb:Person-a3d3af3d-ea1d-47f6-bc02-ac334ded6549",
"@type": "identity:Person",
"core:name": "Bob",
"rdfs:seeAlso": {
"@id": "http://example.org/~bob"
}
},
{
"@id": "kb:WebPage-1c05c378-124e-4d3c-898a-fb5a8d178cf8",
"@type": "observable:WebPage",
"core:description": "Bob's company home page.",
"rdfs:seeAlso": {
"@id": "http://example.org/~bob"
}
},
{
"@id": "http://example.org/~chris",
"@type": "observable:WebResource",
"rdfs:comment": "This node will trigger an info-level result from not designating itself a InformationResource, and not ending with a UUID."
},
{
"@id": "https://mc.example.co.jp/",
"@type": "observable:WebPage",
"rdfs:comment": [
"This node should trigger no errors, even when incorporating the annotations on the same identifier from another JSON dict.",
"This JSON dict was provided by a market analyst in Japan."
]
},
{
"@id": "https://mc.example.co.jp/",
"@type": ["core:NonInformationResource", "observable:WebResource"],
"rdfs:comment": [
"This node should trigger no errors, even when incorporating the annotations on the same identifier from another JSON dict.",
"This JSON dict was provided by a market analyst in France."
]
},
{
"@id": "https://mc.example.co.jp/lang-fr/",
"@type": "observable:WebPage",
"rdfs:comment": [
"This node should trigger no errors.",
"This JSON dict was provided by a market analyst in France."
]
}
]
}
78 changes: 78 additions & 0 deletions tests/examples/information_resource_PASS_validation.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@prefix core: <https://ontology.unifiedcyberontology.org/uco/core/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

[]
a sh:ValidationReport ;
sh:conforms "true"^^xsd:boolean ;
sh:result
[
a sh:ValidationResult ;
sh:focusNode <http://example.org/~bob> ;
sh:resultMessage "UcoThings are suggested to end with a UUID." ;
sh:resultSeverity sh:Info ;
sh:sourceConstraint [
a sh:SPARQLConstraint ;
rdfs:seeAlso <https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3> ;
sh:message "UcoThings are suggested to end with a UUID."@en ;
sh:select '''
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX core: <https://ontology.unifiedcyberontology.org/uco/core/>
SELECT $this
WHERE {
$this a/rdfs:subClassOf* core:UcoThing .
FILTER NOT EXISTS {
$this a/rdfs:subClassOf* core:InformationResource .
}
FILTER (
! REGEX (
STR($this),
"[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$",
"i"
)
)
}
''' ;
] ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:sourceShape core:UcoThing-identifier-regex-shape ;
sh:value <http://example.org/~bob> ;
] ,
[
a sh:ValidationResult ;
sh:focusNode <http://example.org/~chris> ;
sh:resultMessage "UcoThings are suggested to end with a UUID." ;
sh:resultSeverity sh:Info ;
sh:sourceConstraint [
a sh:SPARQLConstraint ;
rdfs:seeAlso <https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3> ;
sh:message "UcoThings are suggested to end with a UUID."@en ;
sh:select '''
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX core: <https://ontology.unifiedcyberontology.org/uco/core/>
SELECT $this
WHERE {
$this a/rdfs:subClassOf* core:UcoThing .
FILTER NOT EXISTS {
$this a/rdfs:subClassOf* core:InformationResource .
}
FILTER (
! REGEX (
STR($this),
"[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$",
"i"
)
)
}
''' ;
] ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:sourceShape core:UcoThing-identifier-regex-shape ;
sh:value <http://example.org/~chris> ;
]
;
.

29 changes: 29 additions & 0 deletions tests/examples/information_resource_XFAIL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"@context": {
"core": "https://ontology.unifiedcyberontology.org/uco/core/",
"kb": "http://example.org/kb/",
"identity": "https://ontology.unifiedcyberontology.org/uco/identity/",
"observable": "https://ontology.unifiedcyberontology.org/uco/observable/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#"
},
"@graph": [
{
"@id": "http://example.org/~bob",
"@type": [
"identity:Person",
"observable:WebPage"
],
"core:name": "Bob",
"core:description": "Bob's company home page.",
"rdfs:comment": "This node will trigger an error from conflating a node as both a person and the person's home page.",
"rdfs:seeAlso": [
{
"@id": "kb:Person-a3d3af3d-ea1d-47f6-bc02-ac334ded6549"
},
{
"@id": "kb:WebPage-1c05c378-124e-4d3c-898a-fb5a8d178cf8"
}
]
}
]
}
21 changes: 21 additions & 0 deletions tests/examples/information_resource_XFAIL_validation.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@prefix core: <https://ontology.unifiedcyberontology.org/uco/core/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

[]
a sh:ValidationReport ;
sh:conforms "false"^^xsd:boolean ;
sh:result [
a sh:ValidationResult ;
sh:focusNode <http://example.org/~bob> ;
sh:resultMessage "core:InformationResource and core:NeverInformationResource are disjoint classes."@en ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:NotConstraintComponent ;
sh:sourceShape core:InformationResource-disjointWith-NeverInformationResource-shape ;
sh:value <http://example.org/~bob> ;
] ;
.

Loading
Loading