From 007029b0f44b809e0ee985ec22eab01828970f10 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Sun, 21 Aug 2022 21:50:54 -0400 Subject: [PATCH] Restore isConfigurationOf; add usesConfiguration Sean removed `tool:ConfiguredTool` and `tool:isConfigurationOf` from the implementation for Issue 405, without explanation. His revised demonstration of how to represent a tool being used with a configuration within an action included this excerpt (not complete UCO JSON-LD, but sufficient to demonstrate the design issue): ```json [ { "@id": "kb:relationship-d6d18770-cb60-4779-b28a-905846dbd3f4", "@type": "uco-core:Relationship", "uco-core:source": "kb:AnalyticTool-DAE5EE58-E5ED-4588-93BE-CDEC6FAA9C6A", "uco-core:target": "kb:Configuration-4bc42c81-e9e7-4f48-b066-17e7fdca0f92", "uco-core:kindOfRelationship": "Has_Configuration", "uco-core:startTime": "2010-01-15T17:59:43.25Z", }, { "@id": "kb:Analysis-7cd51fa7-63ee-4f40-a482-9ce8333c7556", "@type": "uco-analysis:Analysis", "uco-core:name": "compute string similarity", "uco-action:instrument": [ "kb:AnalyticTool-DAE5EE58-E5ED-4588-93BE-CDEC6FAA9C6A", "kb:relationship-d6d18770-cb60-4779-b28a-905846dbd3f4", "kb:Configuration-4bc42c81-e9e7-4f48-b066-17e7fdca0f92" ] } ] ``` `tool:ToolConfigurationTypeFacet` was also removed, and I agree that that is obviated with the `Configuration` class. Because that `Facet` is removed, another mechanism is needed to link a configuration to a `Tool` or a `Software`. This patch restores `ConfiguredTool`, and adds a similar class `ConfiguredSoftware` to meet the expanded objective of Issue 432. `isConfigurationOf` is restored as a more generically-specified property, leaving type-scoping to the SHACL associations. `configuration:usesConfiguration` is added to link a `ConfiguredX` instance to a `Configuration`. With the above new and restored properties and classes, the above JSON-LD snippet is now expressible like this, most notably removing the complexity of references in `action:instrument`: ```json [ { "@id": "kb:configured-tool-c6718138-e953-4731-bf52-d7d89eae9c85", "@type": [ "uco-tool:AnalyticTool", "uco-tool:ConfiguredTool", ], "uco-configuration:isConfigurationOf": "kb:AnalyticTool-DAE5EE58-E5ED-4588-93BE-CDEC6FAA9C6A", "uco-configuration:usesConfiguration": "kb:Configuration-4bc42c81-e9e7-4f48-b066-17e7fdca0f92", "uco-core:objectCreatedTime": "2010-01-15T17:59:43.25Z", }, { "@id": "kb:Analysis-7cd51fa7-63ee-4f40-a482-9ce8333c7556", "@type": "uco-analysis:Analysis", "uco-core:name": "compute string similarity", "uco-action:instrument": "kb:configured-tool-c6718138-e953-4731-bf52-d7d89eae9c85" } ] ``` Tests are updated to exercise the new classes and properties. A follow-on patch will regenerate Make-managed files. References: * https://github.com/ucoProject/UCO/issues/405 * https://github.com/ucoProject/UCO/issues/432 Signed-off-by: Alex Nelson --- ontology/uco/configuration/configuration.ttl | 17 +++++++++++ ontology/uco/observable/observable.ttl | 28 +++++++++++++++++++ ontology/uco/tool/tool.ttl | 25 +++++++++++++++++ .../examples/configuration_setting_PASS.json | 15 ++++++++++ .../examples/configuration_setting_XFAIL.json | 16 +++++++++++ tests/examples/test_validation.py | 10 +++++-- 6 files changed, 109 insertions(+), 2 deletions(-) diff --git a/ontology/uco/configuration/configuration.ttl b/ontology/uco/configuration/configuration.ttl index 625c4f06..0649cb4c 100644 --- a/ontology/uco/configuration/configuration.ttl +++ b/ontology/uco/configuration/configuration.ttl @@ -163,6 +163,16 @@ configuration:dependencyType rdfs:range xsd:string ; . +configuration:isConfigurationOf + a + owl:ObjectProperty , + owl:IrreflexiveProperty + ; + rdfs:label "isConfigurationOf"@en ; + rdfs:comment "The object which has been configured to run in a more specified manner than another object. This property is expected to have a more specific range when associated with a class, such as a configured Tool having this property have a range of a Tool."@en ; + rdfs:range core:UcoObject ; + . + configuration:itemDescription a owl:DatatypeProperty ; rdfs:label "itemDescription"@en ; @@ -205,3 +215,10 @@ configuration:usageContextAssumptions rdfs:range xsd:string ; . +configuration:usesConfiguration + a owl:ObjectProperty ; + rdfs:label "usesConfiguration"@en ; + rdfs:comment "A configuration used by an object."@en ; + rdfs:range configuration:Configuration ; + . + diff --git a/ontology/uco/observable/observable.ttl b/ontology/uco/observable/observable.ttl index df82e70f..a717d51a 100644 --- a/ontology/uco/observable/observable.ttl +++ b/ontology/uco/observable/observable.ttl @@ -1,4 +1,5 @@ # imports: https://ontology.unifiedcyberontology.org/uco/action +# imports: https://ontology.unifiedcyberontology.org/uco/configuration # imports: https://ontology.unifiedcyberontology.org/uco/core # imports: https://ontology.unifiedcyberontology.org/uco/identity # imports: https://ontology.unifiedcyberontology.org/uco/location @@ -7,6 +8,7 @@ @prefix action: . @prefix co: . +@prefix configuration: . @prefix core: . @prefix identity: . @prefix location: . @@ -24,6 +26,7 @@ rdfs:label "uco-observable"@en ; owl:imports , + , , , , @@ -1284,6 +1287,31 @@ observable:ComputerSpecificationFacet sh:targetClass observable:ComputerSpecificationFacet ; . +observable:ConfiguredSoftware + a + owl:Class , + sh:NodeShape + ; + rdfs:subClassOf observable:Software ; + rdfs:label "ConfiguredSoftware"@en ; + rdfs:comment "A ConfiguredSoftware is a Software that is known to be configured to run in a more specified manner than some unconfigured or less-configured Software."@en ; + sh:property + [ + sh:class configuration:Configuration ; + sh:maxCount "1"^^xsd:integer ; + sh:nodeKind sh:BlankNodeOrIRI ; + sh:path configuration:usesConfiguration ; + ] , + [ + sh:class observable:Software ; + sh:maxCount "1"^^xsd:integer ; + sh:nodeKind sh:BlankNodeOrIRI ; + sh:path configuration:isConfigurationOf ; + ] + ; + sh:targetClass observable:ConfiguredSoftware ; + . + observable:Contact a owl:Class , diff --git a/ontology/uco/tool/tool.ttl b/ontology/uco/tool/tool.ttl index 36013a05..4e41d6a7 100644 --- a/ontology/uco/tool/tool.ttl +++ b/ontology/uco/tool/tool.ttl @@ -184,6 +184,31 @@ tool:CompilerType sh:targetClass tool:CompilerType ; . +tool:ConfiguredTool + a + owl:Class , + sh:NodeShape + ; + rdfs:subClassOf tool:Tool ; + rdfs:label "ConfiguredTool"@en ; + rdfs:comment "A ConfiguredTool is a Tool that is known to be configured to run in a more specified manner than some unconfigured or less-configured Tool."@en ; + sh:property + [ + sh:class configuration:Configuration ; + sh:maxCount "1"^^xsd:integer ; + sh:nodeKind sh:BlankNodeOrIRI ; + sh:path configuration:usesConfiguration ; + ] , + [ + sh:class tool:Tool ; + sh:maxCount "1"^^xsd:integer ; + sh:nodeKind sh:BlankNodeOrIRI ; + sh:path configuration:isConfigurationOf ; + ] + ; + sh:targetClass tool:ConfiguredTool ; + . + tool:DefensiveTool a owl:Class , diff --git a/tests/examples/configuration_setting_PASS.json b/tests/examples/configuration_setting_PASS.json index 2c61ea06..5d34271b 100644 --- a/tests/examples/configuration_setting_PASS.json +++ b/tests/examples/configuration_setting_PASS.json @@ -9,6 +9,21 @@ { "rdfs:comment": "Settings are numbered with a binary tracking system. 2^0 = itemObject set. 2^1 = itemValue set. With the mutually-exclusive property shapes on ConfigurationSettingType, setting 3 would be invalid." }, + { + "@id": "kb:tool-1", + "@type": "tool:Tool" + }, + { + "@id": "kb:configured-object-1", + "@type": "tool:ConfiguredTool", + "configuration:isConfigurationOf": { + "@id": "kb:tool-1" + }, + "configuration:usesConfiguration": { + "@id": "kb:configuration-1" + } + }, + { "@id": "kb:thing-1", "@type": "core:UcoObject" diff --git a/tests/examples/configuration_setting_XFAIL.json b/tests/examples/configuration_setting_XFAIL.json index f740f66e..cb5a375a 100644 --- a/tests/examples/configuration_setting_XFAIL.json +++ b/tests/examples/configuration_setting_XFAIL.json @@ -3,6 +3,7 @@ "configuration": "https://ontology.unifiedcyberontology.org/uco/configuration/", "core": "https://ontology.unifiedcyberontology.org/uco/core/", "kb": "http://example.org/kb/", + "observable": "https://ontology.unifiedcyberontology.org/uco/observable/", "tool": "https://ontology.unifiedcyberontology.org/uco/tool/" }, "@graph": [ @@ -13,6 +14,21 @@ "@id": "kb:thing-2", "@type": "core:UcoObject" }, + { + "@id": "kb:software-1", + "@type": "observable:Software" + }, + { + "@id": "kb:configured-object-2", + "@type": "tool:ConfiguredTool", + "rdfs:comment": "This will trigger an error, as kb:software-1 is not declared here to be a tool:Tool. It can be, but it has not been declared here.", + "configuration:isConfigurationOf": { + "@id": "kb:software-1" + }, + "configuration:usesConfiguration": { + "@id": "kb:configuration-2" + } + }, { "@id": "kb:configuration-2", "@type": "configuration:Configuration", diff --git a/tests/examples/test_validation.py b/tests/examples/test_validation.py index 9094b533..fd1807f6 100644 --- a/tests/examples/test_validation.py +++ b/tests/examples/test_validation.py @@ -182,8 +182,14 @@ def test_configuration_setting_PASS_validation() -> None: assert isinstance(g, rdflib.Graph) def test_configuration_setting_XFAIL_validation() -> None: - g = load_validation_graph("configuration_setting_XFAIL_validation.ttl", False) - assert isinstance(g, rdflib.Graph) + confirm_validation_results( + "configuration_setting_XFAIL_validation.ttl", + False, + expected_focus_node_severities={ + ("http://example.org/kb/configuration-entry-3", str(NS_SH.Violation)), + ("http://example.org/kb/configured-object-2", str(NS_SH.Violation)), + } +) def test_hash_PASS() -> None: g = load_validation_graph("hash_PASS_validation.ttl", True)