From 04fcafe90325f5371cb55169199c5d4c16b8e4a7 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Tue, 30 Jan 2024 18:50:25 -0500 Subject: [PATCH] Start UCO-gufo profile from base branch A follow-on patch will regenerate Make-managed files. Signed-off-by: Alex Nelson --- .gitmodules | 4 ++ Makefile | 26 ++-------- dependencies/CDO-Shapes-gufo | 1 + dependencies/Makefile | 48 +----------------- dependencies/example.ttl | 16 ------ dependencies/example/README.md | 3 -- dependencies/example/example.owl | 18 ------- etc/dependency_files.tsv | 5 +- etc/domain_directories.tsv | 1 - ontology/uco-example.ttl | 23 --------- ontology/uco-gufo.ttl | 37 ++++++++++++++ shapes/Makefile | 84 -------------------------------- shapes/catalog-v001.xml | 26 ---------- shapes/sh-example.ttl | 62 ----------------------- tests/exemplars.ttl | 22 +++++++-- 15 files changed, 70 insertions(+), 306 deletions(-) create mode 160000 dependencies/CDO-Shapes-gufo delete mode 100644 dependencies/example.ttl delete mode 100644 dependencies/example/README.md delete mode 100644 dependencies/example/example.owl delete mode 100644 ontology/uco-example.ttl create mode 100644 ontology/uco-gufo.ttl delete mode 100644 shapes/Makefile delete mode 100644 shapes/catalog-v001.xml delete mode 100644 shapes/sh-example.ttl diff --git a/.gitmodules b/.gitmodules index 12ff227..081d4a0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,7 @@ +[submodule "dependencies/CDO-Shapes-gufo"] + path = dependencies/CDO-Shapes-gufo + url = https://github.com/Cyber-Domain-Ontology/CDO-Shapes-gufo.git + branch = main [submodule "dependencies/UCO"] path = dependencies/UCO url = https://github.com/ucoProject/UCO.git diff --git a/Makefile b/Makefile index fd0fcbd..5088e4c 100644 --- a/Makefile +++ b/Makefile @@ -20,17 +20,14 @@ PYTHON3 ?= python3 all: \ .venv-pre-commit/var/.pre-commit-built.log \ - all-ontology \ - all-shapes + all-ontology .PHONY: \ all-dependencies \ all-ontology \ - all-shapes \ check-dependencies \ check-mypy \ check-ontology \ - check-shapes \ check-supply-chain \ check-supply-chain-cdo-profile \ check-supply-chain-pre-commit \ @@ -41,7 +38,9 @@ all: \ # dependency on other profiles. .git_submodule_init_imports.done.log: \ .gitmodules - # TODO - Initialize non-CDO submodule here. + git submodule update \ + --init \ + dependencies/CDO-Shapes-gufo touch $@ .git_submodule_init.done.log: \ @@ -104,17 +103,11 @@ all-ontology: \ $(MAKE) \ --directory ontology -all-shapes: \ - all-dependencies - $(MAKE) \ - --directory shapes - check: \ .venv-pre-commit/var/.pre-commit-built.log \ check-mypy \ check-dependencies \ - check-ontology \ - check-shapes + check-ontology $(MAKE) \ --directory tests \ check @@ -140,12 +133,6 @@ check-ontology: \ --directory ontology \ check -check-shapes: \ - all-shapes - $(MAKE) \ - --directory shapes \ - check - # This target's dependencies potentially modify the working directory's # Git state, so it is intentionally not a dependency of check. check-supply-chain: \ @@ -192,9 +179,6 @@ clean: @$(MAKE) \ --directory tests \ clean - @$(MAKE) \ - --directory shapes \ - clean @$(MAKE) \ --directory ontology \ clean diff --git a/dependencies/CDO-Shapes-gufo b/dependencies/CDO-Shapes-gufo new file mode 160000 index 0000000..0981d4b --- /dev/null +++ b/dependencies/CDO-Shapes-gufo @@ -0,0 +1 @@ +Subproject commit 0981d4b1c0bbfd85995a2bbcd6c95e79d3976ae9 diff --git a/dependencies/Makefile b/dependencies/Makefile index 5b8603a..fda705d 100644 --- a/dependencies/Makefile +++ b/dependencies/Makefile @@ -20,16 +20,9 @@ top_srcdir := $(shell cd .. ; pwd) uco_srcdir := $(top_srcdir)/dependencies/UCO -RDF_TOOLKIT_JAR := $(uco_srcdir)/lib/rdf-toolkit.jar - all: \ catalog-v001.xml -$(RDF_TOOLKIT_JAR): - @echo "DEBUG:dependencies/Makefile:top_srcdir=$(top_srcdir)" >&2 - @echo "ERROR:dependencies/Makefile:rdf-toolkit.jar not found. Did you run `make` from the top source directory?" >&2 - @test -r $@ - catalog-v001.xml: \ $(top_srcdir)/.venv.done.log \ $(top_srcdir)/etc/domain_directories.tsv \ @@ -49,51 +42,14 @@ catalog-v001.xml: \ check: \ catalog-v001.xml -# TODO: This recipe deletes files generated by Make. The line deleting -# example.ttl should be adapted. clean: @rm -f \ catalog-v001.xml \ - example.ttl \ imports-transitive.ttl -# TODO: Adapt this recipe to normalize a submodule's file, or downloaded -# file, in the same manner as CDO ontologies are normalized. -example.ttl: \ - example/example.owl \ - $(RDF_TOOLKIT_JAR) \ - $(top_srcdir)/.venv.done.log - source $(top_srcdir)/venv/bin/activate \ - && pyshacl \ - --shacl UCO/ontology/owl/owl.ttl \ - $< - java -jar $(RDF_TOOLKIT_JAR) \ - --inline-blank-nodes \ - --source $< \ - --source-format rdf-xml \ - --target _$@ \ - --target-format turtle - mv _$@ $@ - # This recipe intentionally does not incorporate CDO ontologies (UCO, # CASE, etc.), to avoid redundant imports between multiple profiles. -# TODO: Adapt this recipe to depend instead on the normalized file, as -# well as any profile submodules' imports-transitive files. -# Note that the piping command, analagous to the concatenate ('cat') -# command but for RDF graph files, will combine all recipe dependencies -# into one file, using the $^ ("all dependencies") Make variable. imports-transitive.ttl: \ - example.ttl - source $(top_srcdir)/venv/bin/activate \ - && rdfpipe \ - --output-format turtle \ - $^ \ - > __$@ - java -jar $(RDF_TOOLKIT_JAR) \ - --inline-blank-nodes \ - --source __$@ \ - --source-format turtle \ - --target _$@ \ - --target-format turtle - rm __$@ + $(top_srcdir)/dependencies/CDO-Shapes-gufo/dependencies/imports-transitive.ttl + cp $< _$@ mv _$@ $@ diff --git a/dependencies/example.ttl b/dependencies/example.ttl deleted file mode 100644 index ab1da1c..0000000 --- a/dependencies/example.ttl +++ /dev/null @@ -1,16 +0,0 @@ -@prefix ex: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix xsd: . - - - a owl:Ontology ; - owl:versionIRI ex:0.0.1 ; - . - -ex:Object - a owl:Class ; - rdfs:subClassOf owl:Thing ; - . - diff --git a/dependencies/example/README.md b/dependencies/example/README.md deleted file mode 100644 index fc3f5d5..0000000 --- a/dependencies/example/README.md +++ /dev/null @@ -1,3 +0,0 @@ -This directory is a placeholder for an ontology tracked by Git submodule. - -When adapting the UCO-Profile-Example repository, this directory should be removed. diff --git a/dependencies/example/example.owl b/dependencies/example/example.owl deleted file mode 100644 index 70e6c0d..0000000 --- a/dependencies/example/example.owl +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - diff --git a/etc/dependency_files.tsv b/etc/dependency_files.tsv index c59120d..27890d1 100644 --- a/etc/dependency_files.tsv +++ b/etc/dependency_files.tsv @@ -1,2 +1,3 @@ -http://example.org/ontology/example/0.0.1 ${top_srcdir}/dependencies/example.ttl -http://example.org/shapes/example ${top_srcdir}/shapes/sh-example.ttl +http://example.org/shapes/gufo ${top_srcdir}/dependencies/CDO-Shapes-gufo/shapes/sh-gufo.ttl +http://example.org/ontology/uco-gufo ${top_srcdir}/ontology/uco-gufo.ttl +http://purl.org/nemo/gufo#/1.0.0 ${top_srcdir}/dependencies/CDO-Shapes-gufo/dependencies/gufo.ttl diff --git a/etc/domain_directories.tsv b/etc/domain_directories.tsv index c0330cd..3a9bcd0 100644 --- a/etc/domain_directories.tsv +++ b/etc/domain_directories.tsv @@ -1,2 +1 @@ -https://example.org/ ${top_srcdir}/ontology/ https://ontology.unifiedcyberontology.org/ ${top_srcdir}/dependencies/UCO/ontology/ diff --git a/ontology/uco-example.ttl b/ontology/uco-example.ttl deleted file mode 100644 index da9c57e..0000000 --- a/ontology/uco-example.ttl +++ /dev/null @@ -1,23 +0,0 @@ -# imports: http://example.org/ontology/example/0.0.1 -# imports: https://ontology.unifiedcyberontology.org/uco/uco/1.3.0 - -@prefix drafting: . -@prefix ex: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix uco-core: . -@prefix xsd: . - - - a owl:Ontology ; - owl:imports - ex:0.0.1 , - - ; - . - -uco-core:UcoObject - rdfs:subClassOf ex:Object ; - . - diff --git a/ontology/uco-gufo.ttl b/ontology/uco-gufo.ttl new file mode 100644 index 0000000..4b16e41 --- /dev/null +++ b/ontology/uco-gufo.ttl @@ -0,0 +1,37 @@ +# imports: http://purl.org/nemo/gufo#/1.0.0 +# imports: https://ontology.unifiedcyberontology.org/uco/uco/1.3.0 + +@prefix drafting: . +@prefix gufo: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix uco-action: . +@prefix uco-core: . +@prefix uco-identity: . +@prefix xsd: . + + + a owl:Ontology ; + owl:imports + , + + ; + . + +uco-action:Action + rdfs:subClassOf gufo:Event ; + . + +uco-core:Event + rdfs:subClassOf gufo:Event ; + . + +uco-identity:Organization + rdfs:subClassOf gufo:Object ; + . + +uco-identity:Person + rdfs:subClassOf gufo:Object ; + . + diff --git a/shapes/Makefile b/shapes/Makefile deleted file mode 100644 index e6360e7..0000000 --- a/shapes/Makefile +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/make -f - -# Portions of this file contributed by NIST are governed by the following -# statement: -# -# This software was developed at the National Institute of Standards -# and Technology by employees of the Federal Government in the course -# of their official duties. Pursuant to title 17 Section 105 of the -# United States Code this software is not subject to copyright -# protection and is in the public domain. NIST assumes no -# responsibility whatsoever for its use by other parties, and makes -# no guarantees, expressed or implied, about its quality, -# reliability, or any other characteristic. -# -# We would appreciate acknowledgement if the software is used. - -SHELL := /bin/bash - -top_srcdir := $(shell cd .. ; pwd) - -uco_srcdir := $(top_srcdir)/dependencies/UCO - -RDF_TOOLKIT_JAR := $(uco_srcdir)/lib/rdf-toolkit.jar - -ttl_basenames := $(wildcard sh-*.ttl) - -check_ttl_targets := $(foreach ttl_basename,$(ttl_basenames),check-$(ttl_basename)) - -all: \ - catalog-v001.xml - -.PHONY: \ - check-%.ttl - -.PRECIOUS: \ - .check-%.ttl - -$(RDF_TOOLKIT_JAR): - @echo "DEBUG:shapes/Makefile:top_srcdir=$(top_srcdir)" >&2 - @echo "ERROR:shapes/Makefile:rdf-toolkit.jar not found. Did you run `make` from the top source directory?" >&2 - @test -r $@ - -.check-%.ttl: \ - %.ttl \ - $(RDF_TOOLKIT_JAR) - java -jar $(RDF_TOOLKIT_JAR) \ - --inline-blank-nodes \ - --source $< \ - --source-format turtle \ - --target _$@ \ - --target-format turtle - mv _$@ $@ - -catalog-v001.xml: \ - $(top_srcdir)/.venv.done.log \ - $(top_srcdir)/etc/domain_directories.tsv \ - $(top_srcdir)/etc/dependency_files.tsv \ - $(uco_srcdir)/ontology/uco/master/catalog-v001.xml \ - $(uco_srcdir)/src/create-catalog-v001.xml.py - rm -f _$@ - source $(top_srcdir)/venv/bin/activate \ - && python3 $(uco_srcdir)/src/create-catalog-v001.xml.py \ - --catalog-xml $(uco_srcdir)/ontology/uco/master/catalog-v001.xml \ - _$@ \ - $(top_srcdir)/etc/domain_directories.tsv \ - $(top_srcdir)/etc/dependency_files.tsv \ - "$(top_srcdir)" \ - $(ttl_basenames) - mv _$@ $@ - -check: \ - $(check_ttl_targets) \ - catalog-v001.xml - -check-%.ttl: \ - %.ttl \ - .check-%.ttl - diff $^ \ - || (echo "ERROR:shapes/Makefile:The local $< does not match the normalized version. If the above reported changes look fine, run 'cp .check-$< $<' while in the sub-folder shapes/ to get a file ready to commit to Git." >&2 ; exit 1) - -clean: - @rm -f \ - _* \ - catalog-v001.xml diff --git a/shapes/catalog-v001.xml b/shapes/catalog-v001.xml deleted file mode 100644 index 6936bc2..0000000 --- a/shapes/catalog-v001.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/shapes/sh-example.ttl b/shapes/sh-example.ttl deleted file mode 100644 index 609af39..0000000 --- a/shapes/sh-example.ttl +++ /dev/null @@ -1,62 +0,0 @@ -# imports: http://example.org/ontology/uco-example - -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix sh: . -@prefix sh-example: . -@prefix sh-owl-abox: . -@prefix xsd: . - - - a owl:Ontology ; - rdfs:comment "This shapes file should be filled in for at least mapped classes and properties when the upstream ontology does not provide SHACL shapes."@en ; - owl:imports ; - . - -sh-owl-abox:disjoint-constraint - a sh:SPARQLConstraint ; - rdfs:comment - "This constraint is given an IRI for the cosmetic benefit of compacting SHACL validation results."@en , - "This constraint was intentionally not written to review subclass hierarchies (e.g. by querying for 'nClassA' being a subclass, possibly transitively, of 'nClassNotA,' using 'a/rdfs:subClassOf*'. RDFS inferencing may be required to have this shape fully review a graph. RDFS inferencing is not encoded as a requirement, though it is possible to do so with 'sh:entailment' (see SHACL Specification Section 1.5)."@en - ; - rdfs:seeAlso - , - sh:entailment , - - ; - sh:message "Focus node is a member of two classes that are disjoint with one another: the value node, and {?nNotValue}."@en ; - sh:select """ - PREFIX owl: - PREFIX rdf: - SELECT $this ?value ?nNotValue - WHERE { - $this - a - ?value , - ?nNotValue - ; - . - { - ?nNotValue owl:disjointWith ?value . - } - UNION - { - ?nDisjointedness - a owl:AllDisjointClasses ; - owl:members/rdf:rest*/rdf:first ?value ; - owl:members/rdf:rest+/rdf:first ?nNotValue ; - . - FILTER ( ?value != ?nNotValue ) - } - } - """ ; - . - -sh-owl-abox:disjoint-shape - a sh:NodeShape ; - rdfs:comment "This shape is planned to migrate to another repository."@en ; - sh:sparql sh-owl-abox:disjoint-constraint ; - sh:targetClass owl:Thing ; - . - diff --git a/tests/exemplars.ttl b/tests/exemplars.ttl index 2299bc2..2556576 100644 --- a/tests/exemplars.ttl +++ b/tests/exemplars.ttl @@ -1,20 +1,34 @@ -# imports: http://example.org/ontology/uco-example +# imports: http://example.org/ontology/uco-gufo @prefix drafting: . @prefix kb: . @prefix owl: . @prefix rdf: . @prefix rdfs: . +@prefix uco-action: . @prefix uco-core: . +@prefix uco-identity: . @prefix xsd: . a owl:Ontology ; rdfs:comment "This knowledge base instantiates each of the mapped classes and properties, so SHACL shapes can perform a review for inconsistencies in the mapping between UCO and the mapped ontology."@en ; - owl:imports ; + owl:imports ; . -kb:UcoObject-24cf6699-3cb6-47fa-9f62-c972b0971752 - a uco-core:UcoObject ; +kb:Action-13c91d40-9ca0-4558-81a1-4f7db888c371 + a uco-action:Action ; + . + +kb:Event-03a1a1db-0579-4427-9a51-448c32281146 + a uco-core:Event ; + . + +kb:Organization-3b542161-47e1-40cd-a1b1-e1b9d07af81f + a uco-identity:Organization ; + . + +kb:Person-0c9728af-7f52-400e-9861-72cd11f6966a + a uco-identity:Person ; .