From e6dba28e95810676e3848b3ae1c6a8a3385ae04d Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Thu, 1 Feb 2024 14:09:22 -0500 Subject: [PATCH 1/6] Warn of prior disjointedness declarations in core: and types: A follow-on patch will regenerate Make-managed files. References: * https://github.com/ucoProject/UCO/issues/586 Signed-off-by: Alex Nelson --- ontology/uco/core/core.ttl | 11 +++++++++++ ontology/uco/types/types.ttl | 22 ++++++++++++++++++++++ tests/examples/Makefile | 2 ++ tests/examples/disjointedness_PASS.json | 18 ++++++++++++++++++ tests/examples/test_validation.py | 9 +++++++++ 5 files changed, 62 insertions(+) create mode 100644 tests/examples/disjointedness_PASS.json diff --git a/ontology/uco/core/core.ttl b/ontology/uco/core/core.ttl index e061bd54..2764132d 100644 --- a/ontology/uco/core/core.ttl +++ b/ontology/uco/core/core.ttl @@ -378,6 +378,17 @@ core:UcoInherentCharacterizationThing sh:targetClass core:UcoInherentCharacterizationThing ; . +core:UcoInherentCharacterizationThing-disjointWith-UcoObject-shape + a sh:NodeShape ; + sh:message "observable:UcoInherentCharacterizationThing and observable:UcoObject are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ; + sh:not [ + a sh:NodeShape ; + sh:class core:UcoObject ; + ] ; + sh:severity sh:Warning ; + sh:targetClass core:UcoInherentCharacterizationThing ; + . + core:UcoObject a owl:Class , diff --git a/ontology/uco/types/types.ttl b/ontology/uco/types/types.ttl index ad91bedb..0b8ac9c7 100644 --- a/ontology/uco/types/types.ttl +++ b/ontology/uco/types/types.ttl @@ -195,6 +195,17 @@ types:Thread ] ; . +types:Thread-disjointWith-co-List-shape + a sh:NodeShape ; + sh:message "types:Thread and co:List are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ; + sh:not [ + a sh:NodeShape ; + sh:class co:List ; + ] ; + sh:severity sh:Warning ; + sh:targetClass types:Thread ; + . + types:ThreadItem a owl:Class , @@ -213,6 +224,17 @@ types:ThreadItem ] ; . +types:ThreadItem-disjointWith-co-ListItem-shape + a sh:NodeShape ; + sh:message "types:ThreadItem and co:ListItem are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ; + sh:not [ + a sh:NodeShape ; + sh:class co:ListItem ; + ] ; + sh:severity sh:Warning ; + sh:targetClass types:ThreadItem ; + . + types:entry a owl:ObjectProperty ; rdfs:label "entry"@en ; diff --git a/tests/examples/Makefile b/tests/examples/Makefile index 80f59e04..6b36e63b 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 \ + disjointedness_PASS_validation.ttl \ event_XFAIL_validation.ttl \ file_url_PASS_validation.ttl \ has_facet_inverse_functional_PASS_validation.ttl \ @@ -98,6 +99,7 @@ check: \ configuration_setting_XFAIL_validation.ttl \ database_records_PASS_validation.ttl \ database_records_XFAIL_validation.ttl \ + disjointedness_PASS_validation.ttl \ event_XFAIL_validation.ttl \ file_url_PASS_validation.ttl \ has_facet_inverse_functional_PASS_validation.ttl \ diff --git a/tests/examples/disjointedness_PASS.json b/tests/examples/disjointedness_PASS.json new file mode 100644 index 00000000..227775a6 --- /dev/null +++ b/tests/examples/disjointedness_PASS.json @@ -0,0 +1,18 @@ +{ + "@context": { + "kb": "http://example.org/kb/", + "core": "https://ontology.unifiedcyberontology.org/uco/core/", + "observable": "https://ontology.unifiedcyberontology.org/uco/observable/", + "xsd": "http://www.w3.org/2001/XMLSchema#" + }, + "@graph": [ + { + "@id": "kb:File-33a25932-3a1a-4828-a90f-d31818b495ce", + "@type": [ + "observable:File", + "observable:FileFacet" + ], + "rdfs:comment": "This node will trigger a violation in UCO 2.0.0 for designating itself a File and FileFacet, which are disjoint due to File being a (eventual) subclass of UcoObject, and FileFacet being a (eventual) subclass of UcoInherentCharacterizationThing." + } + ] +} diff --git a/tests/examples/test_validation.py b/tests/examples/test_validation.py index c714d0c3..91807153 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_disjointedness_PASS() -> None: + confirm_validation_results( + "disjointedness_PASS_validation.ttl", + True, + expected_focus_node_severities={ + ("http://example.org/kb/File-33a25932-3a1a-4828-a90f-d31818b495ce", str(NS_SH.Warning)), + } + ) + def test_event_XFAIL() -> None: confirm_validation_results( "event_XFAIL_validation.ttl", From 9460e743b1358e5753de71dbc6d1057954a27723 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Thu, 1 Feb 2024 17:57:37 -0500 Subject: [PATCH 2/6] Regenerate Make-managed files References: * https://github.com/ucoProject/UCO/issues/586 Signed-off-by: Alex Nelson --- .../disjointedness_PASS_validation.ttl | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/examples/disjointedness_PASS_validation.ttl diff --git a/tests/examples/disjointedness_PASS_validation.ttl b/tests/examples/disjointedness_PASS_validation.ttl new file mode 100644 index 00000000..c88a7234 --- /dev/null +++ b/tests/examples/disjointedness_PASS_validation.ttl @@ -0,0 +1,21 @@ +@prefix core: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix sh: . +@prefix xsd: . + +[] + a sh:ValidationReport ; + sh:conforms "true"^^xsd:boolean ; + sh:result [ + a sh:ValidationResult ; + sh:focusNode ; + sh:resultMessage "observable:UcoInherentCharacterizationThing and observable:UcoObject are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ; + sh:resultSeverity sh:Warning ; + sh:sourceConstraintComponent sh:NotConstraintComponent ; + sh:sourceShape core:UcoInherentCharacterizationThing-disjointWith-UcoObject-shape ; + sh:value ; + ] ; + . + From 13f877bc50071e52357464d9c2478376fa6bd6cc Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 10 May 2024 10:14:55 -0400 Subject: [PATCH 3/6] Warn if an AlternateDataStream instance is not also a FileSystemObject A follow-on patch will regenerate Make-managed files. References: * https://github.com/ucoProject/UCO/issues/590 Signed-off-by: Alex Nelson --- ontology/uco/observable/observable.ttl | 8 +++++++ tests/examples/Makefile | 2 ++ .../examples/alternate_data_stream_PASS.json | 21 +++++++++++++++++++ tests/examples/test_validation.py | 9 ++++++++ 4 files changed, 40 insertions(+) create mode 100644 tests/examples/alternate_data_stream_PASS.json diff --git a/ontology/uco/observable/observable.ttl b/ontology/uco/observable/observable.ttl index 6f5553b2..37dc84be 100644 --- a/ontology/uco/observable/observable.ttl +++ b/ontology/uco/observable/observable.ttl @@ -239,6 +239,14 @@ observable:AlternateDataStream rdfs:subClassOf observable:ObservableObject ; rdfs:label "AlternateDataStream"@en ; rdfs:comment "An alternate data stream is data content stored within an NTFS file that is independent of the standard content stream of the file and is hidden from access by default NTFS file viewing mechanisms."@en ; + rdfs:seeAlso [ + a sh:NodeShape ; + rdfs:comment "This anonymous shape is attached with rdfs:seeAlso in order to associate a warning-severity class constraint, that will only be necessary as an independent shape until UCO 2.0.0."@en ; + sh:class observable:FileSystemObject ; + sh:message "In UCO 2.0.0, uco-observable:AlternateDataStream will be a subclass of uco-observable:FileSystemObject. In preparation for UCO 2.0.0, the additional type uco-observable:FileSystemObject should be assigned to this node."@en ; + sh:severity sh:Warning ; + sh:targetClass observable:AlternateDataStream ; + ] ; sh:targetClass observable:AlternateDataStream ; . diff --git a/tests/examples/Makefile b/tests/examples/Makefile index 80f59e04..712ba277 100644 --- a/tests/examples/Makefile +++ b/tests/examples/Makefile @@ -21,6 +21,7 @@ all: \ action_inheritance_PASS_validation.ttl \ action_inheritance_XFAIL_validation.ttl \ action_result_PASS_validation.ttl \ + alternate_data_stream_PASS_validation.ttl \ co_PASS_validation.ttl \ co_XFAIL_validation.ttl \ configuration_setting_PASS_validation.ttl \ @@ -92,6 +93,7 @@ check: \ action_inheritance_PASS_validation.ttl \ action_inheritance_XFAIL_validation.ttl \ action_result_PASS_validation.ttl \ + alternate_data_stream_PASS_validation.ttl \ co_PASS_validation.ttl \ co_XFAIL_validation.ttl \ configuration_setting_PASS_validation.ttl \ diff --git a/tests/examples/alternate_data_stream_PASS.json b/tests/examples/alternate_data_stream_PASS.json new file mode 100644 index 00000000..e6abd5bb --- /dev/null +++ b/tests/examples/alternate_data_stream_PASS.json @@ -0,0 +1,21 @@ +{ + "@context": { + "kb": "http://example.org/kb/", + "observable": "https://ontology.unifiedcyberontology.org/uco/observable/", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#" + }, + "@graph": [ + { + "@id": "kb:AlternateDataStream-07b3c41a-080c-4916-8375-c18148763e13", + "@type": "observable:AlternateDataStream", + "rdfs:comment": "This node should trigger a sh:Warning from not being a observable:FileSystemObject" + }, + { + "@id": "kb:AlternateDataStream-b2d4968b-4490-4b44-a56b-832058834454", + "@type": [ + "observable:AlternateDataStream", + "observable:FileSystemObject" + ] + } + ] +} diff --git a/tests/examples/test_validation.py b/tests/examples/test_validation.py index c714d0c3..a2ef1138 100644 --- a/tests/examples/test_validation.py +++ b/tests/examples/test_validation.py @@ -177,6 +177,15 @@ def test_action_result_PASS_validation() -> None: g = load_validation_graph("action_result_PASS_validation.ttl", True) assert isinstance(g, rdflib.Graph) +def test_alternate_data_stream_PASS_validation() -> None: + confirm_validation_results( + "alternate_data_stream_PASS_validation.ttl", + True, + expected_focus_node_severities={ + ("http://example.org/kb/AlternateDataStream-07b3c41a-080c-4916-8375-c18148763e13", str(NS_SH.Warning)), + } + ) + def test_configuration_setting_PASS_validation() -> None: g = load_validation_graph("configuration_setting_PASS_validation.ttl", True) assert isinstance(g, rdflib.Graph) From 5a40aa46f7ead5290ab180e4b40e9c184bb50c2d Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 10 May 2024 10:15:15 -0400 Subject: [PATCH 4/6] Regenerate Make-managed files References: * https://github.com/ucoProject/UCO/issues/590 Signed-off-by: Alex Nelson --- .../alternate_data_stream_PASS_validation.ttl | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/examples/alternate_data_stream_PASS_validation.ttl diff --git a/tests/examples/alternate_data_stream_PASS_validation.ttl b/tests/examples/alternate_data_stream_PASS_validation.ttl new file mode 100644 index 00000000..d13a07eb --- /dev/null +++ b/tests/examples/alternate_data_stream_PASS_validation.ttl @@ -0,0 +1,28 @@ +@prefix observable: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix sh: . +@prefix xsd: . + +[] + a sh:ValidationReport ; + sh:conforms "true"^^xsd:boolean ; + sh:result [ + a sh:ValidationResult ; + sh:focusNode ; + sh:resultMessage "In UCO 2.0.0, uco-observable:AlternateDataStream will be a subclass of uco-observable:FileSystemObject. In preparation for UCO 2.0.0, the additional type uco-observable:FileSystemObject should be assigned to this node."@en ; + sh:resultSeverity sh:Warning ; + sh:sourceConstraintComponent sh:ClassConstraintComponent ; + sh:sourceShape [ + a sh:NodeShape ; + rdfs:comment "This anonymous shape is attached with rdfs:seeAlso in order to associate a warning-severity class constraint, that will only be necessary as an independent shape until UCO 2.0.0."@en ; + sh:class observable:FileSystemObject ; + sh:message "In UCO 2.0.0, uco-observable:AlternateDataStream will be a subclass of uco-observable:FileSystemObject. In preparation for UCO 2.0.0, the additional type uco-observable:FileSystemObject should be assigned to this node."@en ; + sh:severity sh:Warning ; + sh:targetClass observable:AlternateDataStream ; + ] ; + sh:value ; + ] ; + . + From 79de6094ba9d63b379b02c18893d2a2802686267 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 14 Jun 2024 08:43:48 -0400 Subject: [PATCH 5/6] Fix typo A follow-on patch will regenerate Make-managed files. References: * https://github.com/ucoProject/UCO/issues/586 Signed-off-by: Alex Nelson --- ontology/uco/core/core.ttl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ontology/uco/core/core.ttl b/ontology/uco/core/core.ttl index e4bf1777..8bd191fb 100644 --- a/ontology/uco/core/core.ttl +++ b/ontology/uco/core/core.ttl @@ -379,7 +379,7 @@ core:UcoInherentCharacterizationThing core:UcoInherentCharacterizationThing-disjointWith-UcoObject-shape a sh:NodeShape ; - sh:message "observable:UcoInherentCharacterizationThing and observable:UcoObject are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ; + sh:message "core:UcoInherentCharacterizationThing and core:UcoObject are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ; sh:not [ a sh:NodeShape ; sh:class core:UcoObject ; From 845b8197a80ca4f1db1d0ef656872a74f906e7c4 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 14 Jun 2024 08:52:45 -0400 Subject: [PATCH 6/6] Regenerate Make-managed files References: * https://github.com/ucoProject/UCO/issues/586 Signed-off-by: Alex Nelson --- tests/examples/disjointedness_PASS_validation.ttl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/examples/disjointedness_PASS_validation.ttl b/tests/examples/disjointedness_PASS_validation.ttl index c88a7234..02ba4683 100644 --- a/tests/examples/disjointedness_PASS_validation.ttl +++ b/tests/examples/disjointedness_PASS_validation.ttl @@ -11,7 +11,7 @@ sh:result [ a sh:ValidationResult ; sh:focusNode ; - sh:resultMessage "observable:UcoInherentCharacterizationThing and observable:UcoObject are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ; + sh:resultMessage "core:UcoInherentCharacterizationThing and core:UcoObject are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ; sh:resultSeverity sh:Warning ; sh:sourceConstraintComponent sh:NotConstraintComponent ; sh:sourceShape core:UcoInherentCharacterizationThing-disjointWith-UcoObject-shape ;