Skip to content

Commit

Permalink
Add shape and test constraining performer of automated actions
Browse files Browse the repository at this point in the history
A follow-on patch will regenerate Make-managed files.

References:
* #448

Signed-off-by: Alex Nelson <[email protected]>
  • Loading branch information
ajnelson-nist committed Nov 1, 2022
1 parent acc6da2 commit e3baa52
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
21 changes: 19 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
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"
}
}
}
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

0 comments on commit e3baa52

Please sign in to comment.