ucoProject / UCO-Utility-Pre-0.7.0-Validator

Utility for validation of UCO 0.4.0, UCO 0.5.0, UCO 0.6.0 & UCO 0.7.0 content
Other
2 stars 4 forks source link

Non-existent ontology concepts are not recognized #7

Open ajnelson-nist opened 3 years ago

ajnelson-nist commented 3 years ago

A CASE community member showed me some Validator log output that caught an incorrect timestamp-literal format in a createdTime property. This was a good catch of the Validator. However, the createdTime property in this person's data was using an incorrect namespace, case-investigation:createdTime. The Investigation namespace does not define that property.

It appears the Validator is taking the "open world" assumption a bit too strongly. Concept names that the instance data assert are in the ontology, but that aren't actually in the ontology, are not being called out. Asserted data-literal types (such as xsd:dateTime) are checked.

Take for example this JSON-LD instance-data file:

{
  "@context": {
    "case-investigation": "https://caseontology.org/ontology/case/investigation#",
    "kb": "http://example.org/kb/",
    "rdf":"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs":"http://www.w3.org/2000/01/rdf-schema#",
    "uco-action": "https://unifiedcyberontology.org/ontology/uco/action#",
    "uco-core": "https://unifiedcyberontology.org/ontology/uco/core#",
    "uco-identity": "https://unifiedcyberontology.org/ontology/uco/identity#",
    "uco-location": "https://unifiedcyberontology.org/ontology/uco/location#",
    "uco-observable": "https://unifiedcyberontology.org/ontology/uco/observable#",
    "uco-types": "https://unifiedcyberontology.org/ontology/uco/types#",
    "xsd":"http://www.w3.org/2001/XMLSchema#"
  },
  "@id": "kb:demo",
  "@type": "uco-observable:ObservableObject",
  "case-investigation:createdTime": {
    "@type": "xsd:dateTime",
    "@value": "01/02/2003 01:02:03"
  },
  "uco-action:createdTime": {
    "@type": "xsd:dateTime",
    "@value": "01/02/2003 01:02:04"
  },
  "uco-core:createdTime": {
    "@type": "xsd:dateTime",
    "@value": "01/02/2003 01:02:05"
  },
  "uco-identity:createdTime": {
    "@type": "xsd:dateTime",
    "@value": "01/02/2003 01:02:06"
  },
  "uco-location:createdTime": {
    "@type": "xsd:dateTime",
    "@value": "01/02/2003 01:02:07"
  },
  "uco-types:createdTime": {
    "@type": "xsd:dateTime",
    "@value": "01/02/2003 01:02:08"
  },
  "uco-action:idontexist": {
    "@type": "xsd:dateTime",
    "@value": "01/02/2003 01:02:08"
  },
  "uco-action:ialsodontexist": false,
  "uco-action:methreeonnotexisting": "three"
}

Only uco-core:createdTime and uco-observable:ObservableObject are appropriate concept names.

This is the relevant portion of validator log output on that output:

VALIDATING createdTimes.json
Constraint Error: Line 21, Class <uco-observable:ObservableObject> Property <uco-observable:hasChanged> Data is missing required property.
Error: Line 21, Class <uco-observable:ObservableObject> Property <case-investigation:createdTime> '01/02/2003 01:02:03' is not a valid value of the atomic type 'xs:dateTime'.
Error: Line 21, Class <uco-observable:ObservableObject> Property <uco-action:idontexist> '01/02/2003 01:02:08' is not a valid value of the atomic type 'xs:dateTime'.
Error: Line 21, Class <uco-observable:ObservableObject> Property <uco-action:createdTime> '01/02/2003 01:02:04' is not a valid value of the atomic type 'xs:dateTime'.
Error: Line 21, Class <uco-observable:ObservableObject> Property <uco-identity:createdTime> '01/02/2003 01:02:06' is not a valid value of the atomic type 'xs:dateTime'.
Error: Line 21, Class <uco-observable:ObservableObject> Property <uco-types:createdTime> '01/02/2003 01:02:08' is not a valid value of the atomic type 'xs:dateTime'.
Error: Line 21, Class <uco-observable:ObservableObject> Property <uco-location:createdTime> '01/02/2003 01:02:07' is not a valid value of the atomic type 'xs:dateTime'.
Error: Line 21, Class <uco-observable:ObservableObject> Property <uco-core:createdTime> '01/02/2003 01:02:05' is not a valid value of the atomic type 'xs:dateTime'.

Note that the properties uco-action:ialsodontexist and uco-action:methreeonnotexisting are not called out. All of the xs:dateTime value-format errors are correctly called out. And the ontology is in fact loaded, indicated by the Constraint Error reported for uco-observable:hasChanged being absent. (Nevermind that that's an ontology bug, already filed in UCO's Jira.)

The Validator needs to close its open-world assumption a bit, and check for properties in tracked namespaces existing. Concepts the instance data assert to be in the ontology, but that aren't, should raise a validation error.