Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions ontology/uco/action/action.ttl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# imports: https://ontology.unifiedcyberontology.org/uco/core/1.0.0
# imports: https://ontology.unifiedcyberontology.org/uco/identity/1.0.0
# imports: https://ontology.unifiedcyberontology.org/uco/location/1.0.0
# imports: https://ontology.unifiedcyberontology.org/uco/pattern/1.0.0
# imports: https://ontology.unifiedcyberontology.org/uco/types/1.0.0
# imports: https://ontology.unifiedcyberontology.org/uco/vocabulary/1.0.0

@prefix action: <https://ontology.unifiedcyberontology.org/uco/action/> .
@prefix core: <https://ontology.unifiedcyberontology.org/uco/core/> .
@prefix identity: <https://ontology.unifiedcyberontology.org/uco/identity/> .
@prefix location: <https://ontology.unifiedcyberontology.org/uco/location/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix pattern: <https://ontology.unifiedcyberontology.org/uco/pattern/> .
Expand All @@ -21,7 +22,7 @@
rdfs:label "uco-action"@en ;
rdfs:comment "This ontology defines classes and properties for characterizing actions."@en-US ;
owl:imports
core:1.0.0 ,
identity:1.0.0 ,
location:1.0.0 ,
pattern:1.0.0 ,
types:1.0.0 ,
Expand All @@ -41,6 +42,22 @@ action:Action
rdfs:subClassOf core:UcoObject ;
rdfs:label "Action"@en ;
rdfs:comment "An action is something that may be done or performed."@en ;
sh:and (
[
a sh:PropertyShape ;
sh:class identity:Person ;
sh:path action:performer ;
]
[
a sh:NodeShape ;
rdfs:seeAlso <https://www.w3.org/TR/shacl/#NotConstraintComponent> ;
sh:not [
a sh:PropertyShape ;
sh:hasValue "true"^^xsd:boolean ;
sh:path action:isAutomated ;
] ;
]
) ;
sh:property
[
sh:class action:Action ;
Expand Down Expand Up @@ -89,6 +106,12 @@ action:Action
sh:nodeKind sh:IRI ;
sh:path action:location ;
] ,
[
sh:datatype xsd:boolean ;
sh:maxCount "1"^^xsd:integer ;
sh:nodeKind sh:Literal ;
sh:path action:isAutomated ;
] ,
[
sh:datatype xsd:dateTime ;
sh:maxCount "1"^^xsd:integer ;
Expand Down Expand Up @@ -447,6 +470,13 @@ action:instrument
rdfs:range core:UcoObject ;
.

action:isAutomated
a owl:DatatypeProperty ;
rdfs:label "isAutomated"@en ;
rdfs:comment "An assertion of whether or not the action is automated."@en ;
rdfs:range xsd:boolean ;
.

action:location
a owl:ObjectProperty ;
rdfs:label "location"@en ;
Expand Down
2 changes: 2 additions & 0 deletions tests/examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ all: \
has_facet_inverse_functional_XFAIL_validation.ttl \
hash_PASS_validation.ttl \
hash_XFAIL_validation.ttl \
isAutomated_XFAIL_validation.ttl \
location_PASS_validation.ttl \
location_XFAIL_validation.ttl \
message_thread_PASS_validation.ttl \
Expand Down Expand Up @@ -95,6 +96,7 @@ check: \
has_facet_inverse_functional_XFAIL_validation.ttl \
hash_PASS_validation.ttl \
hash_XFAIL_validation.ttl \
isAutomated_XFAIL_validation.ttl \
location_PASS_validation.ttl \
location_XFAIL_validation.ttl \
message_thread_PASS_validation.ttl \
Expand Down
18 changes: 18 additions & 0 deletions tests/examples/isAutomated_XFAIL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"@context": {
"action": "https://ontology.unifiedcyberontology.org/uco/action/",
"identity": "https://ontology.unifiedcyberontology.org/uco/identity/",
"kb": "http://example.org/kb/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#"
},
"@graph": {
"@id": "kb:person-automated-action-c51e0065-ba55-4177-bc08-e71963c22c26",
"@type": "action:Action",
"rdfs:comment": "This will fail SHACL validation because an automated action is required to not have a human performer.",
"action:isAutomated": true,
"action:performer": {
"@id": "kb:person-c6c7ccc6-2b6c-41e0-ad74-d895bd209ac8",
"@type": "identity:Person"
}
}
}
21 changes: 21 additions & 0 deletions tests/examples/isAutomated_XFAIL_validation.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@prefix action: <https://ontology.unifiedcyberontology.org/uco/action/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

[]
a sh:ValidationReport ;
sh:conforms "false"^^xsd:boolean ;
sh:result [
a sh:ValidationResult ;
sh:focusNode <http://example.org/kb/person-automated-action-c51e0065-ba55-4177-bc08-e71963c22c26> ;
sh:resultMessage 'Node kb:person-automated-action-c51e0065-ba55-4177-bc08-e71963c22c26 does not conform to all shapes in [ rdf:type sh:PropertyShape ; sh:class identity:Person ; sh:path action:performer ] , [ rdf:type sh:NodeShape ; rdfs:seeAlso <https://www.w3.org/TR/shacl/#NotConstraintComponent> ; sh:not [ rdf:type sh:PropertyShape ; sh:hasValue Literal("true" = True, datatype=xsd:boolean) ; sh:path action:isAutomated ] ]' ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:AndConstraintComponent ;
sh:sourceShape action:Action ;
sh:value <http://example.org/kb/person-automated-action-c51e0065-ba55-4177-bc08-e71963c22c26> ;
] ;
.

4 changes: 4 additions & 0 deletions tests/examples/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ def test_co_XFAIL_validation() -> None:
}
)

def test_isAutomated_XFAIL_validation() -> None:
g = load_validation_graph("isAutomated_XFAIL_validation.ttl", False)
assert isinstance(g, rdflib.Graph)

def test_location_PASS_validation() -> None:
"""
Confirm the PASS instance data passes validation.
Expand Down