From f717616ecc50fa1677fbdc022baa2b1025cf1a76 Mon Sep 17 00:00:00 2001 From: Sean Barnum Date: Wed, 19 Jul 2023 14:27:13 -0400 Subject: [PATCH 1/8] Added classes, properties and shapes for Event Added new core:Event class with appropriate SHACL shapes Added new core:eventType property Added new core:eventContext property Added new core:eventAttribute property --- ontology/uco/core/core.ttl | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/ontology/uco/core/core.ttl b/ontology/uco/core/core.ttl index aaa52614..d4bd8fc0 100644 --- a/ontology/uco/core/core.ttl +++ b/ontology/uco/core/core.ttl @@ -171,6 +171,43 @@ core:EnclosingCompilation sh:targetClass core:EnclosingCompilation ; . +core:Event + a + owl:Class, + sh:NodeShape + ; + rdfs:subClassOf core:UcoObject ; + rdfs:label "Event"@en ; + rdfs:comment "An Event is a noteworthy occurrence (something that happens or might happen)."@en ; + sh:property + [ + sh:datatype xsd:string ; + sh:nodeKind sh:Literal ; + sh:path core:eventType ; + ], + [ + sh:nodeKind sh:IRI ; + sh:class core:UcoObject ; + sh:path core:eventContext ; + ], + [ + sh:datatype xsd:string ; + sh:nodeKind sh:Literal ; + sh:path core:startTime ; + ], + [ + sh:datatype xsd:string ; + sh:nodeKind sh:Literal ; + sh:path core:endTime ; + ], + [ + sh:nodeKind sh:IRI ; + sh:class types:Dictionary ; + sh:path core:eventAttribute ; + ] ; + sh:targetClass core:Event +. + core:ExternalReference a owl:Class , @@ -518,6 +555,27 @@ core:endTime rdfs:range xsd:dateTime ; . +core:eventContext + a owl:ObjectProperty; + rdfs:label "Event Context"@en ; + rdfs:comment "An event context describes the association of actions and objects relating to an event."@en ; + rdfs:range core:UcoObject + . + +core:eventAttribute + a owl:ObjectProperty; + rdfs:label "Event Attribute"@en ; + rdfs:comment "An event attribute specifies an ad-hoc attribute/value for an event."@en ; + rdfs:range types:Dictionary + . + +core:eventType + a owl:DatatypeProperty; + rdfs:label "Event Type"@en ; + rdfs:comment "An event type specifies a classification type for the event."@en ; + rdfs:range xsd:string + . + core:externalIdentifier a owl:DatatypeProperty ; rdfs:label "externalIdentifier"@en ; From ba4b77194d88874ca69a74aafb659266bd64900b Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 19 Jul 2023 15:08:58 -0400 Subject: [PATCH 2/8] Normalize --- ontology/uco/core/core.ttl | 107 +++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/ontology/uco/core/core.ttl b/ontology/uco/core/core.ttl index d4bd8fc0..057ffb82 100644 --- a/ontology/uco/core/core.ttl +++ b/ontology/uco/core/core.ttl @@ -171,42 +171,43 @@ core:EnclosingCompilation sh:targetClass core:EnclosingCompilation ; . -core:Event - a - owl:Class, - sh:NodeShape +core:Event + a + owl:Class , + sh:NodeShape ; - rdfs:subClassOf core:UcoObject ; - rdfs:label "Event"@en ; - rdfs:comment "An Event is a noteworthy occurrence (something that happens or might happen)."@en ; + rdfs:subClassOf core:UcoObject ; + rdfs:label "Event"@en ; + rdfs:comment "An Event is a noteworthy occurrence (something that happens or might happen)."@en ; sh:property - [ - sh:datatype xsd:string ; - sh:nodeKind sh:Literal ; - sh:path core:eventType ; - ], - [ - sh:nodeKind sh:IRI ; - sh:class core:UcoObject ; - sh:path core:eventContext ; - ], - [ - sh:datatype xsd:string ; - sh:nodeKind sh:Literal ; - sh:path core:startTime ; - ], - [ - sh:datatype xsd:string ; - sh:nodeKind sh:Literal ; - sh:path core:endTime ; - ], - [ - sh:nodeKind sh:IRI ; - sh:class types:Dictionary ; - sh:path core:eventAttribute ; - ] ; - sh:targetClass core:Event -. + [ + sh:class core:UcoObject ; + sh:nodeKind sh:IRI ; + sh:path core:eventContext ; + ] , + [ + sh:class types:Dictionary ; + sh:nodeKind sh:IRI ; + sh:path core:eventAttribute ; + ] , + [ + sh:datatype xsd:string ; + sh:nodeKind sh:Literal ; + sh:path core:endTime ; + ] , + [ + sh:datatype xsd:string ; + sh:nodeKind sh:Literal ; + sh:path core:eventType ; + ] , + [ + sh:datatype xsd:string ; + sh:nodeKind sh:Literal ; + sh:path core:startTime ; + ] + ; + sh:targetClass core:Event ; + . core:ExternalReference a @@ -555,25 +556,25 @@ core:endTime rdfs:range xsd:dateTime ; . -core:eventContext - a owl:ObjectProperty; - rdfs:label "Event Context"@en ; - rdfs:comment "An event context describes the association of actions and objects relating to an event."@en ; - rdfs:range core:UcoObject - . - -core:eventAttribute - a owl:ObjectProperty; - rdfs:label "Event Attribute"@en ; - rdfs:comment "An event attribute specifies an ad-hoc attribute/value for an event."@en ; - rdfs:range types:Dictionary - . - -core:eventType - a owl:DatatypeProperty; - rdfs:label "Event Type"@en ; - rdfs:comment "An event type specifies a classification type for the event."@en ; - rdfs:range xsd:string +core:eventAttribute + a owl:ObjectProperty ; + rdfs:label "Event Attribute"@en ; + rdfs:comment "An event attribute specifies an ad-hoc attribute/value for an event."@en ; + rdfs:range types:Dictionary ; + . + +core:eventContext + a owl:ObjectProperty ; + rdfs:label "Event Context"@en ; + rdfs:comment "An event context describes the association of actions and objects relating to an event."@en ; + rdfs:range core:UcoObject ; + . + +core:eventType + a owl:DatatypeProperty ; + rdfs:label "Event Type"@en ; + rdfs:comment "An event type specifies a classification type for the event."@en ; + rdfs:range xsd:string ; . core:externalIdentifier From 36ee2363dcd17b5a9fa36e77a2c86081800ebb68 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Thu, 20 Jul 2023 16:37:08 -0400 Subject: [PATCH 3/8] Fix datatype constraints Signed-off-by: Alex Nelson --- ontology/uco/core/core.ttl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ontology/uco/core/core.ttl b/ontology/uco/core/core.ttl index 057ffb82..6b8c566e 100644 --- a/ontology/uco/core/core.ttl +++ b/ontology/uco/core/core.ttl @@ -191,19 +191,19 @@ core:Event sh:path core:eventAttribute ; ] , [ - sh:datatype xsd:string ; + sh:datatype xsd:dateTime ; sh:nodeKind sh:Literal ; sh:path core:endTime ; ] , [ - sh:datatype xsd:string ; + sh:datatype xsd:dateTime ; sh:nodeKind sh:Literal ; - sh:path core:eventType ; + sh:path core:startTime ; ] , [ sh:datatype xsd:string ; sh:nodeKind sh:Literal ; - sh:path core:startTime ; + sh:path core:eventType ; ] ; sh:targetClass core:Event ; From 9cf555adabcdf9ee0fba34d48059ffb017a3e42d Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 25 Aug 2023 13:12:19 -0400 Subject: [PATCH 4/8] Add stub reference to types:Dictionary References: * https://github.com/ucoProject/UCO/issues/541 Signed-off-by: Alex Nelson --- ontology/uco/core/core.ttl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ontology/uco/core/core.ttl b/ontology/uco/core/core.ttl index 6b8c566e..7accb6fa 100644 --- a/ontology/uco/core/core.ttl +++ b/ontology/uco/core/core.ttl @@ -736,6 +736,11 @@ core:value rdfs:range xsd:string ; . +types:Dictionary + a owl:Class ; + rdfs:isDefinedBy ; + . + [] a owl:AllDisjointClasses ; owl:members ( From d5ad31fb9cd4a466514103175888083dc7c32923 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Thu, 9 Nov 2023 09:21:19 -0500 Subject: [PATCH 5/8] Designate ObservablePattern a subclass of Pattern, adding namespace import This patch also has the Observable namespace import the Pattern namespace, to attain first access to the Pattern class. No effects were observed on Make-managed files. References: * https://github.com/ucoProject/UCO/issues/543 Signed-off-by: Alex Nelson --- ontology/uco/observable/observable.ttl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ontology/uco/observable/observable.ttl b/ontology/uco/observable/observable.ttl index 050119f7..14792916 100644 --- a/ontology/uco/observable/observable.ttl +++ b/ontology/uco/observable/observable.ttl @@ -3,6 +3,7 @@ # imports: https://ontology.unifiedcyberontology.org/uco/core/1.2.0 # imports: https://ontology.unifiedcyberontology.org/uco/identity/1.2.0 # imports: https://ontology.unifiedcyberontology.org/uco/location/1.2.0 +# imports: https://ontology.unifiedcyberontology.org/uco/pattern/1.2.0 # imports: https://ontology.unifiedcyberontology.org/uco/types/1.2.0 # imports: https://ontology.unifiedcyberontology.org/uco/vocabulary/1.2.0 @@ -14,6 +15,7 @@ @prefix location: . @prefix observable: . @prefix owl: . +@prefix pattern: . @prefix rdf: . @prefix rdfs: . @prefix sh: . @@ -31,6 +33,7 @@ core:1.2.0 , identity:1.2.0 , location:1.2.0 , + pattern:1.2.0 , types:1.2.0 , vocabulary:1.2.0 ; @@ -5038,7 +5041,10 @@ observable:ObservablePattern owl:Class , sh:NodeShape ; - rdfs:subClassOf observable:Observable ; + rdfs:subClassOf + observable:Observable , + pattern:Pattern + ; rdfs:label "ObservablePattern"@en ; rdfs:comment "An observable pattern is a grouping of characteristics unique to a logical pattern composed of observable object and observable action properties."@en ; sh:targetClass observable:ObservablePattern ; From 885acb56a318b2c5c7c8601b485117393aecb7fb Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Thu, 9 Nov 2023 13:16:25 -0500 Subject: [PATCH 6/8] Revert direct Pattern namespace import The previous patch included a direct Pattern namespace import. This turns out to not be necessary because the Pattern namespace is already in the transitive `owl:imports` closure, via the Action namespace. Hence, the `Pattern` class is already available for `ObservablePattern`. I realized this when I noticed the `catalog-v001.xml` file didn't require an update from adding the direct import. References: * https://github.com/ucoProject/UCO/issues/543 Signed-off-by: Alex Nelson --- ontology/uco/observable/observable.ttl | 2 -- 1 file changed, 2 deletions(-) diff --git a/ontology/uco/observable/observable.ttl b/ontology/uco/observable/observable.ttl index 14792916..2da20c1f 100644 --- a/ontology/uco/observable/observable.ttl +++ b/ontology/uco/observable/observable.ttl @@ -3,7 +3,6 @@ # imports: https://ontology.unifiedcyberontology.org/uco/core/1.2.0 # imports: https://ontology.unifiedcyberontology.org/uco/identity/1.2.0 # imports: https://ontology.unifiedcyberontology.org/uco/location/1.2.0 -# imports: https://ontology.unifiedcyberontology.org/uco/pattern/1.2.0 # imports: https://ontology.unifiedcyberontology.org/uco/types/1.2.0 # imports: https://ontology.unifiedcyberontology.org/uco/vocabulary/1.2.0 @@ -33,7 +32,6 @@ core:1.2.0 , identity:1.2.0 , location:1.2.0 , - pattern:1.2.0 , types:1.2.0 , vocabulary:1.2.0 ; From 6669aabdd5de5c7100eb7d0264b9639de10eae1f Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 17 Nov 2023 09:53:29 -0500 Subject: [PATCH 7/8] Designate action:Action and core:Event disjoint In an OWL-only sense, the ontology portion of this patch could have been accomplished by adding one triple to `action:Action`. For the sake of symmetry and explicitness, `core:Event` also picked up the `owl:disjointWith` statement. To satisfy OWL syntactic requirements, a stub reference to `action:Action` is added, as was done for `types:Dictionary` for Issue 541 (discussed in PR 542). To enforce disjointedness with SHACL, a new independent shape is added, `action:Action-disjointWith-Event-shape`. A follow-on patch will regenerate Make-managed files. EDIT 2023-11-22: An initial version of this patch included an inlined anonymous `sh:NodeShape`. I now believe the scenario that shape mitigates (multi-import of a shapes graph leading to SHACL-scoped syntax errors) is unlikely, and I also saw that the noted rationale around `sh:not` was confused with another predicate (`sh:inversePath`). References: * https://github.com/ucoProject/UCO/issues/563 * https://github.com/ucoProject/UCO/pull/542 Signed-off-by: Alex Nelson --- ontology/uco/action/action.ttl | 11 +++++++++++ ontology/uco/core/core.ttl | 7 +++++++ tests/examples/Makefile | 2 ++ tests/examples/event_XFAIL.json | 28 ++++++++++++++++++++++++++++ tests/examples/test_validation.py | 9 +++++++++ 5 files changed, 57 insertions(+) create mode 100644 tests/examples/event_XFAIL.json diff --git a/ontology/uco/action/action.ttl b/ontology/uco/action/action.ttl index d5a5bf26..95b4e3c5 100644 --- a/ontology/uco/action/action.ttl +++ b/ontology/uco/action/action.ttl @@ -40,6 +40,7 @@ action:Action rdfs:subClassOf core:UcoObject ; rdfs:label "Action"@en ; rdfs:comment "An action is something that may be done or performed."@en ; + owl:disjointWith core:Event ; sh:property [ sh:class action:Action ; @@ -150,6 +151,16 @@ action:Action sh:targetClass action:Action ; . +action:Action-disjointWith-Event-shape + a sh:NodeShape ; + sh:message "action:Action and core:Event are disjoint classes."@en ; + sh:not [ + a sh:NodeShape ; + sh:class core:Event ; + ] ; + sh:targetClass action:Action ; + . + action:ActionArgumentFacet a owl:Class , diff --git a/ontology/uco/core/core.ttl b/ontology/uco/core/core.ttl index 7accb6fa..bdb092e4 100644 --- a/ontology/uco/core/core.ttl +++ b/ontology/uco/core/core.ttl @@ -1,3 +1,4 @@ +@prefix action: . @prefix core: . @prefix owl: . @prefix rdf: . @@ -15,6 +16,11 @@ owl:versionIRI core:1.2.0 ; . +action:Action + a owl:Class ; + rdfs:isDefinedBy ; + . + core:Annotation a owl:Class , @@ -179,6 +185,7 @@ core:Event rdfs:subClassOf core:UcoObject ; rdfs:label "Event"@en ; rdfs:comment "An Event is a noteworthy occurrence (something that happens or might happen)."@en ; + owl:disjointWith action:Action ; sh:property [ sh:class core:UcoObject ; diff --git a/tests/examples/Makefile b/tests/examples/Makefile index 56d619d1..80f59e04 100644 --- a/tests/examples/Makefile +++ b/tests/examples/Makefile @@ -27,6 +27,7 @@ all: \ configuration_setting_XFAIL_validation.ttl \ database_records_PASS_validation.ttl \ database_records_XFAIL_validation.ttl \ + event_XFAIL_validation.ttl \ file_url_PASS_validation.ttl \ has_facet_inverse_functional_PASS_validation.ttl \ has_facet_inverse_functional_XFAIL_validation.ttl \ @@ -97,6 +98,7 @@ check: \ configuration_setting_XFAIL_validation.ttl \ database_records_PASS_validation.ttl \ database_records_XFAIL_validation.ttl \ + event_XFAIL_validation.ttl \ file_url_PASS_validation.ttl \ has_facet_inverse_functional_PASS_validation.ttl \ has_facet_inverse_functional_XFAIL_validation.ttl \ diff --git a/tests/examples/event_XFAIL.json b/tests/examples/event_XFAIL.json new file mode 100644 index 00000000..9f2a59d9 --- /dev/null +++ b/tests/examples/event_XFAIL.json @@ -0,0 +1,28 @@ +{ + "@context": { + "kb": "http://example.org/kb/", + "action": "https://ontology.unifiedcyberontology.org/uco/action/", + "core": "https://ontology.unifiedcyberontology.org/uco/core/", + "xsd": "http://www.w3.org/2001/XMLSchema#" + }, + "@graph": [ + { + "@id": "kb:Action-0-03ee1fe6-12cf-4a35-b7dd-06d4e69369b5", + "@type": [ + "action:Action", + "core:Event" + ], + "rdfs:comment": "This node will trigger an XFAIL for designating itself an Action and Event, which are disjoint classes." + }, + { + "@id": "kb:Action-1-763c1ff2-d18d-427b-aa82-30d90701a644", + "@type": "action:Action", + "rdfs:comment": "This node should pass validation." + }, + { + "@id": "kb:Event-1-ee9450b6-3535-473d-984d-17a91408a54f", + "@type": "event:Event", + "rdfs:comment": "This node should pass validation." + } + ] +} diff --git a/tests/examples/test_validation.py b/tests/examples/test_validation.py index 285dfdec..c714d0c3 100644 --- a/tests/examples/test_validation.py +++ b/tests/examples/test_validation.py @@ -207,6 +207,15 @@ def test_database_records_XFAIL() -> None: } ) +def test_event_XFAIL() -> None: + confirm_validation_results( + "event_XFAIL_validation.ttl", + False, + expected_focus_node_severities = { + ("http://example.org/kb/Action-0-03ee1fe6-12cf-4a35-b7dd-06d4e69369b5", str(NS_SH.Violation)), + } + ) + def test_file_url_PASS_validation() -> None: confirm_validation_results( "file_url_PASS_validation.ttl", From f599294b80554141d5c5ec3279b5c27881a39f95 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 22 Nov 2023 12:24:52 -0500 Subject: [PATCH 8/8] Regenerate Make-managed files References: * https://github.com/ucoProject/UCO/issues/563 Signed-off-by: Alex Nelson --- tests/examples/event_XFAIL_validation.ttl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/examples/event_XFAIL_validation.ttl diff --git a/tests/examples/event_XFAIL_validation.ttl b/tests/examples/event_XFAIL_validation.ttl new file mode 100644 index 00000000..be6dbd96 --- /dev/null +++ b/tests/examples/event_XFAIL_validation.ttl @@ -0,0 +1,21 @@ +@prefix action: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix sh: . +@prefix xsd: . + +[] + a sh:ValidationReport ; + sh:conforms "false"^^xsd:boolean ; + sh:result [ + a sh:ValidationResult ; + sh:focusNode ; + sh:resultMessage "action:Action and core:Event are disjoint classes."@en ; + sh:resultSeverity sh:Violation ; + sh:sourceConstraintComponent sh:NotConstraintComponent ; + sh:sourceShape action:Action-disjointWith-Event-shape ; + sh:value ; + ] ; + . +