Skip to content

Commit

Permalink
Restore isConfigurationOf; add usesConfiguration
Browse files Browse the repository at this point in the history
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:
* #405
* #432

Signed-off-by: Alex Nelson <[email protected]>
  • Loading branch information
ajnelson-nist committed Aug 22, 2022
1 parent bf603a3 commit 007029b
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 2 deletions.
17 changes: 17 additions & 0 deletions ontology/uco/configuration/configuration.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down Expand Up @@ -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 ;
.

28 changes: 28 additions & 0 deletions ontology/uco/observable/observable.ttl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -7,6 +8,7 @@

@prefix action: <https://ontology.unifiedcyberontology.org/uco/action/> .
@prefix co: <http://purl.org/co/> .
@prefix configuration: <https://ontology.unifiedcyberontology.org/uco/configuration/> .
@prefix core: <https://ontology.unifiedcyberontology.org/uco/core/> .
@prefix identity: <https://ontology.unifiedcyberontology.org/uco/identity/> .
@prefix location: <https://ontology.unifiedcyberontology.org/uco/location/> .
Expand All @@ -24,6 +26,7 @@
rdfs:label "uco-observable"@en ;
owl:imports
<https://ontology.unifiedcyberontology.org/uco/action> ,
<https://ontology.unifiedcyberontology.org/uco/configuration> ,
<https://ontology.unifiedcyberontology.org/uco/core> ,
<https://ontology.unifiedcyberontology.org/uco/identity> ,
<https://ontology.unifiedcyberontology.org/uco/location> ,
Expand Down Expand Up @@ -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 ,
Expand Down
25 changes: 25 additions & 0 deletions ontology/uco/tool/tool.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ,
Expand Down
15 changes: 15 additions & 0 deletions tests/examples/configuration_setting_PASS.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 16 additions & 0 deletions tests/examples/configuration_setting_XFAIL.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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",
Expand Down
10 changes: 8 additions & 2 deletions tests/examples/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 007029b

Please sign in to comment.