Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 549: Add objectStatus #631

Merged
merged 17 commits into from
Aug 30, 2024
Merged
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
38 changes: 38 additions & 0 deletions ontology/uco/core/core.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,20 @@ core:ModusOperandi
sh:targetClass core:ModusOperandi ;
.

core:ObjectStatusVocab
a rdfs:Datatype ;
rdfs:label "Object Status Vocabulary"@en-US ;
owl:equivalentClass [
a rdfs:Datatype ;
owl:onDatatype xsd:string ;
owl:oneOf (
"Draft"^^core:ObjectStatusVocab
"Final"^^core:ObjectStatusVocab
"Deprecated"^^core:ObjectStatusVocab
) ;
] ;
.

core:Relationship
a
owl:Class ,
Expand Down Expand Up @@ -451,6 +465,17 @@ core:UcoObject
sh:datatype xsd:string ;
sh:nodeKind sh:Literal ;
sh:path core:tag ;
] ,
[
sh:datatype core:ObjectStatusVocab ;
sh:in (
"Draft"^^core:ObjectStatusVocab
"Final"^^core:ObjectStatusVocab
"Deprecated"^^core:ObjectStatusVocab
) ;
sh:maxCount "1"^^xsd:integer ;
sh:nodeKind sh:Literal ;
sh:path core:objectStatus ;
]
;
sh:targetClass core:UcoObject ;
Expand Down Expand Up @@ -697,6 +722,19 @@ core:objectMarking
rdfs:range core:MarkingDefinitionAbstraction ;
.

core:objectStatus
a owl:AnnotationProperty ;
rdfs:label "objectStatus"@en ;
rdfs:comment "The current state of formality and acceptance for a UCO object."@en-US ;
rdfs:range core:ObjectStatusVocab ;
.

core:objectStatus-subjects-shape
a sh:NodeShape ;
sh:class core:UcoObject ;
sh:targetSubjectsOf core:objectStatus ;
.

core:referenceURL
a owl:DatatypeProperty ;
rdfs:label "referenceURL"@en ;
Expand Down
4 changes: 4 additions & 0 deletions tests/examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ all: \
location_XFAIL_validation.ttl \
message_thread_PASS_validation.ttl \
message_thread_XFAIL_validation.ttl \
object_status_PASS_validation.ttl \
object_status_XFAIL_validation.ttl \
observable_creation_time_PASS_validation.ttl \
owl_axiom_PASS_validation.ttl \
owl_axiom_XFAIL_validation.ttl \
Expand Down Expand Up @@ -116,6 +118,8 @@ check: \
location_XFAIL_validation.ttl \
message_thread_PASS_validation.ttl \
message_thread_XFAIL_validation.ttl \
object_status_PASS_validation.ttl \
object_status_XFAIL_validation.ttl \
observable_creation_time_PASS_validation.ttl \
owl_axiom_PASS_validation.ttl \
owl_axiom_XFAIL_validation.ttl \
Expand Down
16 changes: 16 additions & 0 deletions tests/examples/object_status_PASS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"@context": {
"core": "https://ontology.unifiedcyberontology.org/uco/core/",
"kb": "http://example.org/kb/"
},
"@graph": [
{
"@id": "kb:UcoObject-f86c567d-374a-4873-b9bc-a746ca2bf360",
"@type": "core:UcoObject",
"core:objectStatus": {
"@type": "core:ObjectStatusVocab",
"@value": "Draft"
}
}
]
}
11 changes: 11 additions & 0 deletions tests/examples/object_status_PASS_validation.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@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 "true"^^xsd:boolean ;
.

26 changes: 26 additions & 0 deletions tests/examples/object_status_XFAIL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"@context": {
"core": "https://ontology.unifiedcyberontology.org/uco/core/",
"kb": "http://example.org/kb/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#"
},
"@graph": [
{
"@id": "kb:UcoObject-6ae2b245-a8cd-45dc-9f40-5b2738879351",
"@type": "core:UcoObject",
"rdfs:comment": "This will trigger an error from using a value outside of the required vocabulary.",
"core:objectStatus": "Initial draft"
},
{
"@id": "kb:File-c9c36379-8eca-4a85-887c-b51f7721edfd",
"@type": "observable:File",
"core:hasFacet": {
"@id": "kb:ArchiveFileFacet-5884ca1c-2f5e-4e66-bdc6-7d48606f9fbc",
"@type": "observable:ArchiveFileFacet",
"rdfs:comment": "This will trigger an error from using objectStatus on a non-UcoObject thing.",
"core:objectStatus": "Draft",
"observable:archiveType": "Currently-unknown compressing-and-encrypting type seen multiple places, further research needed"
}
}
]
}
63 changes: 63 additions & 0 deletions tests/examples/object_status_XFAIL_validation.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@prefix core: <https://ontology.unifiedcyberontology.org/uco/core/> .
@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/ArchiveFileFacet-5884ca1c-2f5e-4e66-bdc6-7d48606f9fbc> ;
sh:resultMessage "Value does not have class core:UcoObject" ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:ClassConstraintComponent ;
sh:sourceShape core:objectStatus-subjects-shape ;
sh:value <http://example.org/kb/ArchiveFileFacet-5884ca1c-2f5e-4e66-bdc6-7d48606f9fbc> ;
] ,
[
a sh:ValidationResult ;
sh:focusNode <http://example.org/kb/UcoObject-6ae2b245-a8cd-45dc-9f40-5b2738879351> ;
sh:resultMessage "Value Literal(\"Initial draft\") not in list ['Literal(\"Draft\" = None, datatype=core:ObjectStatusVocab)', 'Literal(\"Final\" = None, datatype=core:ObjectStatusVocab)', 'Literal(\"Deprecated\" = None, datatype=core:ObjectStatusVocab)']" ;
sh:resultPath core:objectStatus ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:InConstraintComponent ;
sh:sourceShape [
sh:datatype core:ObjectStatusVocab ;
sh:in (
"Draft"^^core:ObjectStatusVocab
"Final"^^core:ObjectStatusVocab
"Deprecated"^^core:ObjectStatusVocab
) ;
sh:maxCount "1"^^xsd:integer ;
sh:nodeKind sh:Literal ;
sh:path core:objectStatus ;
] ;
sh:value "Initial draft" ;
] ,
[
a sh:ValidationResult ;
sh:focusNode <http://example.org/kb/UcoObject-6ae2b245-a8cd-45dc-9f40-5b2738879351> ;
sh:resultMessage "Value is not Literal with datatype core:ObjectStatusVocab" ;
sh:resultPath core:objectStatus ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:DatatypeConstraintComponent ;
sh:sourceShape [
sh:datatype core:ObjectStatusVocab ;
sh:in (
"Draft"^^core:ObjectStatusVocab
"Final"^^core:ObjectStatusVocab
"Deprecated"^^core:ObjectStatusVocab
) ;
sh:maxCount "1"^^xsd:integer ;
sh:nodeKind sh:Literal ;
sh:path core:objectStatus ;
] ;
sh:value "Initial draft" ;
]
;
.

22 changes: 22 additions & 0 deletions tests/examples/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,28 @@ def test_message_thread_PASS_validation() -> None:
def test_message_thread_XFAIL_validation() -> None:
confirm_validation_results("message_thread_XFAIL_validation.ttl", False)

def test_object_status_PASS() -> None:
confirm_validation_results(
"object_status_PASS_validation.ttl",
True,
)

def test_object_status_XFAIL() -> None:
confirm_validation_results(
"object_status_XFAIL_validation.ttl",
False,
expected_focus_node_severities={
(
"http://example.org/kb/UcoObject-6ae2b245-a8cd-45dc-9f40-5b2738879351",
str(NS_SH.Violation)
),
(
"http://example.org/kb/ArchiveFileFacet-5884ca1c-2f5e-4e66-bdc6-7d48606f9fbc",
str(NS_SH.Violation)
),
}
)

def test_observable_creation_time_PASS() -> None:
confirm_validation_results(
"observable_creation_time_PASS_validation.ttl",
Expand Down
Loading