From 38c0fb31618e5d7ef2beead2d9a2e39ab2d7f3a3 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 16 Oct 2024 11:21:50 -0400 Subject: [PATCH 1/2] Change OperatingSystem parent class to Software; update previously-in-common property placement A follow-on patch will regenerate Make-managed files. References: * https://github.com/ucoProject/UCO/issues/632 Signed-off-by: Alex Nelson --- ontology/uco/observable/observable.ttl | 28 ++------------ tests/examples/Makefile | 6 ++- tests/examples/operating_system_PASS.json | 7 +--- tests/examples/operating_system_XFAIL.json | 44 ++++++++++++++++++++++ tests/examples/test_validation.py | 15 +++++--- 5 files changed, 61 insertions(+), 39 deletions(-) create mode 100644 tests/examples/operating_system_XFAIL.json diff --git a/ontology/uco/observable/observable.ttl b/ontology/uco/observable/observable.ttl index 9e56a95..9d3536b 100644 --- a/ontology/uco/observable/observable.ttl +++ b/ontology/uco/observable/observable.ttl @@ -5146,17 +5146,9 @@ observable:OperatingSystem owl:Class , sh:NodeShape ; - rdfs:subClassOf observable:ObservableObject ; + rdfs:subClassOf observable:Software ; rdfs:label "OperatingSystem"@en ; rdfs:comment "An operating system is the software that manages computer hardware, software resources, and provides common services for computer programs. [based on https://en.wikipedia.org/wiki/Operating_system]"@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:Software ; - sh:message "In UCO 2.0.0, uco-observable:OperatingSystem will be a subclass of uco-observable:Software. In preparation for UCO 2.0.0, the additional type uco-observable:Software should be assigned to this node."@en ; - sh:severity sh:Warning ; - sh:targetClass observable:OperatingSystem ; - ] ; sh:targetClass observable:OperatingSystem ; . @@ -5169,12 +5161,6 @@ observable:OperatingSystemFacet rdfs:label "OperatingSystemFacet"@en ; rdfs:comment "An operating system facet is a grouping of characteristics unique to the software that manages computer hardware, software resources, and provides common services for computer programs. [based on https://en.wikipedia.org/wiki/Operating_system]"@en ; sh:property - [ - sh:class identity:Identity ; - sh:maxCount "1"^^xsd:integer ; - sh:nodeKind sh:IRI ; - sh:path observable:manufacturer ; - ] , [ sh:class types:Dictionary ; sh:maxCount "1"^^xsd:integer ; @@ -5199,12 +5185,6 @@ observable:OperatingSystemFacet sh:nodeKind sh:Literal ; sh:path observable:bitness ; ] , - [ - sh:datatype xsd:string ; - sh:maxCount "1"^^xsd:integer ; - sh:nodeKind sh:Literal ; - sh:path observable:version ; - ] , [ sh:datatype xsd:string ; sh:nodeKind sh:Literal ; @@ -5212,15 +5192,13 @@ observable:OperatingSystemFacet ] , [ sh:maxCount "0"^^xsd:integer ; - sh:message "In UCO 2.0.0, uco-observable:manufacturer will not be associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; + sh:message "As of UCO 2.0.0, uco-observable:manufacturer is not associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; sh:path observable:manufacturer ; - sh:severity sh:Warning ; ] , [ sh:maxCount "0"^^xsd:integer ; - sh:message "In UCO 2.0.0, uco-observable:version will not be associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; + sh:message "As of UCO 2.0.0, uco-observable:version is not associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; sh:path observable:version ; - sh:severity sh:Warning ; ] ; sh:targetClass observable:OperatingSystemFacet ; diff --git a/tests/examples/Makefile b/tests/examples/Makefile index fdaccf2..84f64a8 100644 --- a/tests/examples/Makefile +++ b/tests/examples/Makefile @@ -43,8 +43,9 @@ all: \ message_thread_XFAIL_validation.ttl \ object_status_PASS_validation.ttl \ object_status_XFAIL_validation.ttl \ - operating_system_PASS_validation.ttl \ observable_creation_time_XFAIL_validation.ttl \ + operating_system_PASS_validation.ttl \ + operating_system_XFAIL_validation.ttl \ owl_axiom_PASS_validation.ttl \ owl_axiom_XFAIL_validation.ttl \ owl_properties_PASS_validation.ttl \ @@ -121,8 +122,9 @@ check: \ message_thread_XFAIL_validation.ttl \ object_status_PASS_validation.ttl \ object_status_XFAIL_validation.ttl \ - operating_system_PASS_validation.ttl \ observable_creation_time_XFAIL_validation.ttl \ + operating_system_PASS_validation.ttl \ + operating_system_XFAIL_validation.ttl \ owl_axiom_PASS_validation.ttl \ owl_axiom_XFAIL_validation.ttl \ owl_properties_PASS_validation.ttl \ diff --git a/tests/examples/operating_system_PASS.json b/tests/examples/operating_system_PASS.json index c97ff49..a72adbf 100644 --- a/tests/examples/operating_system_PASS.json +++ b/tests/examples/operating_system_PASS.json @@ -31,16 +31,11 @@ { "@id": "kb:OperatingSystemFacet-35047ef2-ffd6-45e8-8b3c-2e8e4bfe7c2b", "@type": "observable:OperatingSystemFacet", - "rdfs:comment": "This node will trigger a warning for housing the manufacturer and version properties, meant to be moved to SoftwareFacet.", "observable:bitness": "64", "observable:installDate": { "@type": "xsd:dateTime", "@value": "2024-09-13T09:00:00-04:00" - }, - "observable:manufacturer": { - "@id": "kb:Organization-4ea8a5bf-60ea-43ba-9ba6-f852ce8f8b54" - }, - "observable:version": "40" + } } ] } diff --git a/tests/examples/operating_system_XFAIL.json b/tests/examples/operating_system_XFAIL.json new file mode 100644 index 0000000..4711337 --- /dev/null +++ b/tests/examples/operating_system_XFAIL.json @@ -0,0 +1,44 @@ +{ + "@context": { + "core": "https://ontology.unifiedcyberontology.org/uco/core/", + "identity": "https://ontology.unifiedcyberontology.org/uco/identity/", + "kb": "http://example.org/kb/", + "observable": "https://ontology.unifiedcyberontology.org/uco/observable/", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "xsd": "http://www.w3.org/2001/XMLSchema#" + }, + "@graph": [ + { + "@id": "kb:Organization-cc6ee776-d770-409d-a84b-06aa6009b670", + "@type": "identity:Organization", + "core:name": "Example OS Company" + }, + { + "@id": "kb:OperatingSystem-0a6c3dcd-9a53-4d1b-a635-afbcedab9760", + "@type": "observable:OperatingSystem", + "core:description": "The Example Operating System instance deployed on workstation C-304-33", + "core:hasFacet": [ + { + "@id": "kb:SoftwareFacet-6b474a08-99f7-4dbd-8cd1-ef81ddff6bc3", + "@type": "observable:SoftwareFacet", + "observable:cpeid": "cpe:2.3:o:exampleosco:exampleos:40:*:*:*:*:*:*:*", + "observable:language": "en-us" + }, + { + "@id": "kb:OperatingSystemFacet-483cc1a7-f1f1-472f-87e0-3e076fad46ec", + "@type": "observable:OperatingSystemFacet", + "rdfs:comment": "This node will trigger an error for housing the manufacturer and version properties, now required to be on SoftwareFacet.", + "observable:bitness": "64", + "observable:installDate": { + "@type": "xsd:dateTime", + "@value": "2024-09-13T09:00:00-04:00" + }, + "observable:manufacturer": { + "@id": "kb:Organization-cc6ee776-d770-409d-a84b-06aa6009b670" + }, + "observable:version": "40" + } + ] + } + ] +} diff --git a/tests/examples/test_validation.py b/tests/examples/test_validation.py index b0702d4..41959ae 100644 --- a/tests/examples/test_validation.py +++ b/tests/examples/test_validation.py @@ -451,14 +451,17 @@ def test_operating_system_PASS() -> None: confirm_validation_results( "operating_system_PASS_validation.ttl", True, + expected_focus_node_severities=set() + ) + +def test_operating_system_XFAIL() -> None: + confirm_validation_results( + "operating_system_XFAIL_validation.ttl", + False, expected_focus_node_severities={ ( - "http://example.org/kb/OperatingSystem-427dd103-2553-4ccc-ad57-1df4e88b174d", - str(NS_SH.Warning) - ), - ( - "http://example.org/kb/OperatingSystemFacet-35047ef2-ffd6-45e8-8b3c-2e8e4bfe7c2b", - str(NS_SH.Warning) + "http://example.org/kb/OperatingSystemFacet-483cc1a7-f1f1-472f-87e0-3e076fad46ec", + str(NS_SH.Violation) ), } ) From ca5ef4305a8c0df0cf5e6c21501f791bc81b9dbb Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 16 Oct 2024 11:22:05 -0400 Subject: [PATCH 2/2] Regenerate Make-managed files References: * https://github.com/ucoProject/UCO/issues/632 Signed-off-by: Alex Nelson --- .../operating_system_PASS_validation.ttl | 47 ------------------- .../operating_system_XFAIL_validation.ttl | 40 ++++++++++++++++ 2 files changed, 40 insertions(+), 47 deletions(-) create mode 100644 tests/examples/operating_system_XFAIL_validation.ttl diff --git a/tests/examples/operating_system_PASS_validation.ttl b/tests/examples/operating_system_PASS_validation.ttl index 7687a1b..33496ff 100644 --- a/tests/examples/operating_system_PASS_validation.ttl +++ b/tests/examples/operating_system_PASS_validation.ttl @@ -1,4 +1,3 @@ -@prefix observable: . @prefix owl: . @prefix rdf: . @prefix rdfs: . @@ -8,51 +7,5 @@ [] a sh:ValidationReport ; sh:conforms "true"^^xsd:boolean ; - sh:result - [ - a sh:ValidationResult ; - sh:focusNode ; - sh:resultMessage "In UCO 2.0.0, uco-observable:OperatingSystem will be a subclass of uco-observable:Software. In preparation for UCO 2.0.0, the additional type uco-observable:Software 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:Software ; - sh:message "In UCO 2.0.0, uco-observable:OperatingSystem will be a subclass of uco-observable:Software. In preparation for UCO 2.0.0, the additional type uco-observable:Software should be assigned to this node."@en ; - sh:severity sh:Warning ; - sh:targetClass observable:OperatingSystem ; - ] ; - sh:value ; - ] , - [ - a sh:ValidationResult ; - sh:focusNode ; - sh:resultMessage "In UCO 2.0.0, uco-observable:manufacturer will not be associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; - sh:resultPath observable:manufacturer ; - sh:resultSeverity sh:Warning ; - sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; - sh:sourceShape [ - sh:maxCount "0"^^xsd:integer ; - sh:message "In UCO 2.0.0, uco-observable:manufacturer will not be associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; - sh:path observable:manufacturer ; - sh:severity sh:Warning ; - ] ; - ] , - [ - a sh:ValidationResult ; - sh:focusNode ; - sh:resultMessage "In UCO 2.0.0, uco-observable:version will not be associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; - sh:resultPath observable:version ; - sh:resultSeverity sh:Warning ; - sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; - sh:sourceShape [ - sh:maxCount "0"^^xsd:integer ; - sh:message "In UCO 2.0.0, uco-observable:version will not be associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; - sh:path observable:version ; - sh:severity sh:Warning ; - ] ; - ] - ; . diff --git a/tests/examples/operating_system_XFAIL_validation.ttl b/tests/examples/operating_system_XFAIL_validation.ttl new file mode 100644 index 0000000..9250763 --- /dev/null +++ b/tests/examples/operating_system_XFAIL_validation.ttl @@ -0,0 +1,40 @@ +@prefix observable: . +@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 "As of UCO 2.0.0, uco-observable:manufacturer is not associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; + sh:resultPath observable:manufacturer ; + sh:resultSeverity sh:Violation ; + sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; + sh:sourceShape [ + sh:maxCount "0"^^xsd:integer ; + sh:message "As of UCO 2.0.0, uco-observable:manufacturer is not associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; + sh:path observable:manufacturer ; + ] ; + ] , + [ + a sh:ValidationResult ; + sh:focusNode ; + sh:resultMessage "As of UCO 2.0.0, uco-observable:version is not associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; + sh:resultPath observable:version ; + sh:resultSeverity sh:Violation ; + sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; + sh:sourceShape [ + sh:maxCount "0"^^xsd:integer ; + sh:message "As of UCO 2.0.0, uco-observable:version is not associated with uco-observable:OperatingSystemFacet. Please place this on a uco-observable:SoftwareFacet instead."@en ; + sh:path observable:version ; + ] ; + ] + ; + . +