diff --git a/case_utils/__init__.py b/case_utils/__init__.py index 9d281a0..a9456fb 100644 --- a/case_utils/__init__.py +++ b/case_utils/__init__.py @@ -11,6 +11,6 @@ # # We would appreciate acknowledgement if the software is used. -__version__ = "0.10.0" +__version__ = "0.11.0" from . import local_uuid # noqa: F401 diff --git a/case_utils/case_file/__init__.py b/case_utils/case_file/__init__.py index 9a4095f..051e07d 100644 --- a/case_utils/case_file/__init__.py +++ b/case_utils/case_file/__init__.py @@ -15,7 +15,7 @@ This module creates a graph object that provides a basic UCO characterization of a single file. The gathered metadata is among the more "durable" file characteristics, i.e. characteristics that would remain consistent when transferring a file between locations. """ -__version__ = "0.4.0" +__version__ = "0.5.0" import argparse import datetime @@ -27,7 +27,7 @@ import rdflib -import case_utils +import case_utils.inherent_uuid from case_utils.namespace import ( NS_RDF, NS_UCO_CORE, @@ -49,6 +49,8 @@ class HashDict(typing.NamedTuple): sha1: str sha256: str sha512: str + sha3_256: str + sha3_512: str def create_file_node( @@ -58,6 +60,9 @@ def create_file_node( node_prefix: str = DEFAULT_PREFIX, disable_hashes: bool = False, disable_mtime: bool = False, + *args: typing.Any, + use_deterministic_uuids: bool = False, + **kwargs: typing.Any, ) -> rdflib.URIRef: r""" This function characterizes the file at filepath. @@ -68,7 +73,7 @@ def create_file_node( :param filepath: The path to the file to characterize. Can be relative or absolute. :type filepath: str - :param node_iri: The desired full IRI for the node. If absent, will make an IRI of the pattern ``ns_base + 'file-' + uuid4`` + :param node_iri: The desired full IRI for the node. If absent, will make an IRI of the pattern ``ns_base + 'File-' + uuid`` :type node_iri: str :param node_prefix: The base prefix to use if node_iri is not supplied. @@ -86,7 +91,7 @@ def create_file_node( node_namespace = rdflib.Namespace(node_prefix) if node_iri is None: - node_slug = "file-" + case_utils.local_uuid.local_uuid() + node_slug = "File-" + case_utils.local_uuid.local_uuid() node_iri = node_namespace[node_slug] n_file = rdflib.URIRef(node_iri) graph.add((n_file, NS_RDF.type, NS_UCO_OBSERVABLE.File)) @@ -95,7 +100,15 @@ def create_file_node( literal_basename = rdflib.Literal(basename) file_stat = os.stat(filepath) - n_file_facet = node_namespace["file-facet-" + case_utils.local_uuid.local_uuid()] + + n_file_facet: rdflib.URIRef + if use_deterministic_uuids: + n_file_facet = case_utils.inherent_uuid.get_facet_uriref( + n_file, NS_UCO_OBSERVABLE.FileFacet, namespace=node_namespace + ) + else: + n_file_facet = node_namespace["FileFacet-" + case_utils.local_uuid.local_uuid()] + graph.add( ( n_file_facet, @@ -122,9 +135,16 @@ def create_file_node( graph.add((n_file_facet, NS_UCO_OBSERVABLE.modifiedTime, literal_mtime)) if not disable_hashes: - n_contentdata_facet = node_namespace[ - "content-data-facet-" + case_utils.local_uuid.local_uuid() - ] + n_contentdata_facet: rdflib.URIRef + if use_deterministic_uuids: + n_contentdata_facet = case_utils.inherent_uuid.get_facet_uriref( + n_file, NS_UCO_OBSERVABLE.ContentDataFacet, namespace=node_namespace + ) + else: + n_contentdata_facet = node_namespace[ + "ContentDataFacet-" + case_utils.local_uuid.local_uuid() + ] + graph.add((n_file, NS_UCO_CORE.hasFacet, n_contentdata_facet)) graph.add( (n_contentdata_facet, NS_RDF.type, NS_UCO_OBSERVABLE.ContentDataFacet) @@ -141,6 +161,8 @@ def create_file_node( sha1obj = hashlib.sha1() sha256obj = hashlib.sha256() sha512obj = hashlib.sha512() + sha3_256obj = hashlib.sha3_256() + sha3_512obj = hashlib.sha3_512() stashed_error = None byte_tally = 0 with open(filepath, "rb") as in_fh: @@ -159,6 +181,8 @@ def create_file_node( sha1obj.update(buf) sha256obj.update(buf) sha512obj.update(buf) + sha3_256obj.update(buf) + sha3_512obj.update(buf) if stashed_error is not None: raise stashed_error current_hashdict = HashDict( @@ -167,6 +191,8 @@ def create_file_node( sha1obj.hexdigest(), sha256obj.hexdigest(), sha512obj.hexdigest(), + sha3_256obj.hexdigest(), + sha3_512obj.hexdigest(), ) if last_hashdict == current_hashdict: successful_hashdict = current_hashdict @@ -194,26 +220,48 @@ def create_file_node( # Add confirmed hashes into graph. for key in successful_hashdict._fields: - if key not in ("md5", "sha1", "sha256", "sha512"): + if key not in ("md5", "sha1", "sha256", "sha512", "sha3_256", "sha3_512"): continue - n_hash = node_namespace["hash-" + case_utils.local_uuid.local_uuid()] + + l_hash_method: rdflib.Literal + if key in ("sha3_256", "sha3_512"): + l_hash_method = rdflib.Literal( + key.replace("_", "-").upper(), + datatype=NS_UCO_VOCABULARY.HashNameVocab, + ) + else: + l_hash_method = rdflib.Literal( + key.upper(), datatype=NS_UCO_VOCABULARY.HashNameVocab + ) + + hash_value: str = getattr(successful_hashdict, key) + l_hash_value = rdflib.Literal(hash_value.upper(), datatype=NS_XSD.hexBinary) + + hash_uuid: str + if use_deterministic_uuids: + hash_uuid = str( + case_utils.inherent_uuid.hash_method_value_uuid( + l_hash_method, l_hash_value + ) + ) + else: + hash_uuid = case_utils.local_uuid.local_uuid() + n_hash = node_namespace["Hash-" + hash_uuid] + graph.add((n_contentdata_facet, NS_UCO_OBSERVABLE.hash, n_hash)) graph.add((n_hash, NS_RDF.type, NS_UCO_TYPES.Hash)) graph.add( ( n_hash, NS_UCO_TYPES.hashMethod, - rdflib.Literal( - key.upper(), datatype=NS_UCO_VOCABULARY.HashNameVocab - ), + l_hash_method, ) ) - hash_value = getattr(successful_hashdict, key) graph.add( ( n_hash, NS_UCO_TYPES.hashValue, - rdflib.Literal(hash_value.upper(), datatype=NS_XSD.hexBinary), + l_hash_value, ) ) @@ -226,6 +274,11 @@ def main() -> None: parser.add_argument("--debug", action="store_true") parser.add_argument("--disable-hashes", action="store_true") parser.add_argument("--disable-mtime", action="store_true") + parser.add_argument( + "--use-deterministic-uuids", + action="store_true", + help="Use UUIDs computed using the case_utils.inherent_uuid module.", + ) parser.add_argument( "--output-format", help="Override extension-based format guesser." ) @@ -258,7 +311,7 @@ def main() -> None: context_dictionary = {k: v for (k, v) in graph.namespace_manager.namespaces()} serialize_kwargs["context"] = context_dictionary - node_iri = NS_BASE["file-" + case_utils.local_uuid.local_uuid()] + node_iri = NS_BASE["File-" + case_utils.local_uuid.local_uuid()] create_file_node( graph, args.in_file, @@ -266,6 +319,7 @@ def main() -> None: node_prefix=args.base_prefix, disable_hashes=args.disable_hashes, disable_mtime=args.disable_mtime, + use_deterministic_uuids=args.use_deterministic_uuids, ) graph.serialize(args.out_graph, **serialize_kwargs) diff --git a/case_utils/inherent_uuid.py b/case_utils/inherent_uuid.py new file mode 100644 index 0000000..667a8d1 --- /dev/null +++ b/case_utils/inherent_uuid.py @@ -0,0 +1,205 @@ +#!/usr/bin/env python3 + +# 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. + +""" +This library provides supporting constants and functions for generating deterministic UUIDs (version 5) for UCO Hash and Facet nodes. + +There are two general patterns implemented: + +1. Some objects are "wholly specified" by their properties. The leading example of this is uco-types:Hash, which has only the properties hashMethod and hashValue, and both are required to be provided in order to be conformant with UCO. The function `hash_method_value_uuid` implements a scheme to generate UUIDs for uco-types:Hash nodes based on this pattern. +2. A pattern based on inherence generates UUIDv5s based on how an inherent object (a.k.a. UcoInherentCharacterizationThing) structurally relates to the object in which it inheres. For instance, a Facet is understood to only relate to its UcoObject by linking with the uco-core:hasFacet property. So, a Facet's UUID is determined uniquely by (1) the "UUID namespace" of its corresponding UcoObject, and (2) its OWL Class. + A. The term "UUID namespace" is described in RFC 4122 Section 4.3 [#rfc4122s43]_ , and is not intended be confused with `rdflib.term.Namespace`. For any uco-core:UcoThing (or even owl:Thing), the function `inherence_uuid` defines the procedure for either extracting or generating a UUID for use as a namespace. + +This module is independent of, and complements, `case_utils.local_uuid`, which provides deterministic UUIDs based on calling process's environment. + +References +========== + +.. [#rfc4122s43] https://datatracker.ietf.org/doc/html/rfc4122#section-4.3 + + +Examples +======== + +A knowledge base ontology currently uses a prefix 'kb:', expanding to 'http://example.org/kb/'. This knowledge base has a node kb:File-ac6b44cf-dc6b-4f2c-a09d-c9beb0a345a9. What is the IRI of its FileFacet? + +>>> from case_utils.namespace import NS_UCO_OBSERVABLE +>>> ns_kb = Namespace("http://example.org/kb/") +>>> n_file = ns_kb["File-ac6b44cf-dc6b-4f2c-a09d-c9beb0a345a9"] +>>> n_file_facet = get_facet_uriref(n_file, NS_UCO_OBSERVABLE.FileFacet, namespace=ns_kb) +>>> n_file_facet +rdflib.term.URIRef('http://example.org/kb/FileFacet-01d292e3-0f38-5974-868d-006ef07f5186') + +A documentation policy change has been enacted, and now all knowledge base individuals need to use the URN example form. What is the FileFacet IRI now? + +>>> ns_kb_2 = Namespace("urn:example:kb:") +>>> file_iri_2: str = "urn:example:kb:File-ac6b44cf-dc6b-4f2c-a09d-c9beb0a345a9" +>>> n_file_2 = URIRef(file_iri_2) +>>> n_file_facet_2 = get_facet_uriref(n_file_2, NS_UCO_OBSERVABLE.FileFacet, namespace=ns_kb_2) +>>> n_file_facet_2 +rdflib.term.URIRef('urn:example:kb:FileFacet-01d292e3-0f38-5974-868d-006ef07f5186') + +The two IRIs end with the same UUID. + +>>> assert str(n_file_facet)[-36:] == str(n_file_facet_2)[-36:] +""" + +__version__ = "0.1.0" + +import binascii +import re +import uuid +from typing import Any, Dict, Optional, Tuple + +from rdflib import Literal, Namespace, URIRef + +from case_utils.namespace import NS_UCO_CORE, NS_UCO_VOCABULARY, NS_XSD + +L_MD5 = Literal("MD5", datatype=NS_UCO_VOCABULARY.HashNameVocab) +L_SHA1 = Literal("SHA1", datatype=NS_UCO_VOCABULARY.HashNameVocab) +L_SHA256 = Literal("SHA256", datatype=NS_UCO_VOCABULARY.HashNameVocab) +L_SHA3_256 = Literal("SHA3-256", datatype=NS_UCO_VOCABULARY.HashNameVocab) +L_SHA3_512 = Literal("SHA3-512", datatype=NS_UCO_VOCABULARY.HashNameVocab) +L_SHA384 = Literal("SHA384", datatype=NS_UCO_VOCABULARY.HashNameVocab) +L_SHA512 = Literal("SHA512", datatype=NS_UCO_VOCABULARY.HashNameVocab) +L_SSDEEP = Literal("SSDEEP", datatype=NS_UCO_VOCABULARY.HashNameVocab) + +# Key: hashMethod literal. +# Value: Tuple. +# * Lowercase spelling +HASH_METHOD_CASTINGS: Dict[Literal, Tuple[str, Optional[int]]] = { + L_MD5: ("md5", 32), + L_SHA1: ("sha1", 40), + L_SHA256: ("sha256", 64), + L_SHA3_256: ("sha3-256", 64), + L_SHA3_512: ("sha3-512", 128), + L_SHA384: ("sha384", 96), + L_SHA512: ("sha512", 128), + L_SSDEEP: ("ssdeep", None), +} + +RX_UUID = re.compile( + "[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$", re.IGNORECASE +) + + +def inherence_uuid(n_thing: URIRef, *args: Any, **kwargs: Any) -> uuid.UUID: + """ + This function returns a UUIDv5 for any OWL Thing, that can be used as a UUID Namespace in further `uuid.uuidv5` calls. + + In the case that the Thing is a UcoThing that ends with a UUID, that UUID string will be returned wrapped in a UUID object. In all other cases, a UUID version 5 object will be returned for the Thing as a name under the URL namespace [#rfc4122ac]_. + + References + ========== + + .. [#rfc4122ac] https://datatracker.ietf.org/doc/html/rfc4122#appendix-C + + Examples + ======== + + A File node will need its FileFacet IRI determined. What will be the base UUID namespace for determining this IRI as well as other inherent graph objects? + + >>> file_iri: str = "http://example.org/kb/File-ac6b44cf-dc6b-4f2c-a09d-c9beb0a345a9" + >>> n_file = URIRef(file_iri) + >>> file_uuid_namespace: uuid.UUID = inherence_uuid(n_file) + >>> file_uuid_namespace + UUID('ac6b44cf-dc6b-4f2c-a09d-c9beb0a345a9') + + The CASE homepage is being treated as an OWL NamedIndividual in this knowledge base, with its URL as its IRI. What is its base UUID namespace? + + >>> case_homepage_url: str = "https://caseontology.org/" + >>> n_case_homepage = URIRef(case_homepage_url) + >>> case_homepage_uuid_namespace = inherence_uuid(n_case_homepage) + >>> case_homepage_uuid_namespace + UUID('2c6406b7-3396-5fdd-b9bf-c6e21273e40a') + """ + node_iri = str(n_thing) + if len(node_iri) < 40 or RX_UUID.search(node_iri) is None: + # <40 -> Too short to have a UUID and scheme. + return uuid.uuid5(uuid.NAMESPACE_URL, node_iri) + else: + return uuid.UUID(node_iri[-36:]) + + +def facet_inherence_uuid( + uco_object_inherence_uuid: uuid.UUID, + n_facet_class: URIRef, + *args: Any, + **kwargs: Any +) -> uuid.UUID: + """ + :param n_facet_class: This node is expected to be the `rdflib.term.URIRef` for an OWL Class that is either in UCO or extends a class in UCO, such as `case_utils.namespace.NS_UCO_OBSERVABLE.FileFacet`. The Facet class SHOULD be a 'leaf' class - that is, it should have no OWL subclasses. (This 'SHOULD' might become a more stringent requirement in the future. uco-core:Facet MUST not be used. There is some question on how this rule should apply for uco-observable:WifiAddressFacet and its parent class uco-observable:MACAddressFacet.) + :type n_facet_class: rdflib.term.URIRef + """ + + if n_facet_class == NS_UCO_CORE.Facet: + raise ValueError("Requested Facet class is not a leaf Facet class.") + # NOTE: Further reviewing whether n_facet_class pertains to a Facet subclass is not done in this library. Both a set of all such known classes, as well as an extension mechanism for non-standard Facet subclasses (probably either a Set or Graph as an extra parameter), would need to be implemented. + + return uuid.uuid5(uco_object_inherence_uuid, str(n_facet_class)) + + +def get_facet_uriref( + n_uco_object: URIRef, + n_facet_class: URIRef, + *args: Any, + namespace: Namespace, + **kwargs: Any +) -> URIRef: + """ + :param namespace: An RDFLib Namespace object to use for prefixing the Facet IRI with a knowledge base prefix IRI. + :type namespace rdflib.Namespace: + + Examples + ======== + + What is the URLFacet pertaining to the Nitroba University Scenario's PCAP file, when being interpreted as a Simple Storage Service (S3) object? + + >>> from case_utils.namespace import NS_UCO_OBSERVABLE + >>> pcap_url: str = "s3://digitalcorpora/corpora/scenarios/2008-nitroba/nitroba.pcap" + >>> n_pcap = URIRef(pcap_url) + >>> ns_kb = Namespace("http://example.org/kb/") + >>> n_pcap_url_facet = get_facet_uriref(n_pcap, NS_UCO_OBSERVABLE.URLFacet, namespace=ns_kb) + >>> n_pcap_url_facet + rdflib.term.URIRef('http://example.org/kb/URLFacet-4b6023da-dbc4-5e1e-9a2f-aca2a6f6405c') + """ + uco_object_uuid_namespace: uuid.UUID = inherence_uuid(n_uco_object) + facet_uuid = facet_inherence_uuid(uco_object_uuid_namespace, n_facet_class) + + # NOTE: This encodes an assumption that Facets (including extension Facets) use the "Slash" IRI style. + facet_class_local_name = str(n_facet_class).rsplit("/")[-1] + + return namespace[facet_class_local_name + "-" + str(facet_uuid)] + + +def hash_method_value_uuid(l_hash_method: Literal, l_hash_value: Literal) -> uuid.UUID: + """ + This function generates a UUID for a UCO Hash object, solely based on its two required properties: uco-types:hashMethod and uco-types:hashValue. + + The UUIDv5 seed data for Hash nodes is a URN following the scheme in this draft IETF memo: + + https://datatracker.ietf.org/doc/html/draft-thiemann-hash-urn-01 + + Note that at the time of this writing, that memo was expired (expiration date 2004-03-04) and did not have a linked superseding document. + """ + + if l_hash_value.datatype != NS_XSD.hexBinary: + raise ValueError("Expected hexBinary datatype for l_hash_value.") + hash_value_str: str = binascii.hexlify(l_hash_value.toPython()).decode().lower() + + hash_method_str = HASH_METHOD_CASTINGS[l_hash_method][0] + + urn_template = "urn:hash::%s:%s" + urn_populated = urn_template % (hash_method_str, hash_value_str) + + return uuid.uuid5(uuid.NAMESPACE_URL, urn_populated) diff --git a/case_utils/ontology/src/ontology_and_version_iris.py b/case_utils/ontology/src/ontology_and_version_iris.py index 7ac429d..f0139ed 100644 --- a/case_utils/ontology/src/ontology_and_version_iris.py +++ b/case_utils/ontology/src/ontology_and_version_iris.py @@ -15,7 +15,7 @@ This script creates a list of all ontology and version IRIs that have ever existed in a CDO ontology to describe a CDO ontology. I.e. the subject of triples with owl:Ontology as predicate are included, as are the objects of version-referencing triples (owl:versionIRI, owl:incompatibleWith, etc.). """ -__version__ = "0.1.0" +__version__ = "0.1.1" import argparse import typing @@ -29,6 +29,11 @@ def concept_is_cdo_concept(n_concept: rdflib.URIRef) -> bool: """ This function is purposefully distinct from the function used in case_validate. Within this script, the publishing history of CASE and UCO is reviewed. + + >>> concept_is_cdo_concept(rdflib.URIRef("http://example.org/ontology/Thing")) + False + >>> concept_is_cdo_concept(rdflib.URIRef("https://ontology.unifiedcyberontology.org/uco/core/UcoThing")) + True """ concept_iri = str(n_concept) return ( diff --git a/setup.cfg b/setup.cfg index 7c0b0d9..e5ffda7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,6 +34,14 @@ console_scripts = case_sparql_select = case_utils.case_sparql_select:main case_validate = case_utils.case_validate:main +[options.extras_require] +testing = + PyLD + mypy + pytest + python-dateutil + types-python-dateutil + [options.package_data] case_utils = py.typed case_utils.ontology = diff --git a/tests/Makefile b/tests/Makefile index 0716d1a..f38243d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -31,8 +31,7 @@ all: \ $(top_srcdir)/.git_submodule_init.done.log \ $(top_srcdir)/case_utils/__init__.py \ $(top_srcdir)/setup.cfg \ - $(top_srcdir)/setup.py \ - requirements.txt + $(top_srcdir)/setup.py rm -rf venv $(PYTHON3) -m venv \ venv @@ -42,14 +41,11 @@ all: \ pip \ setuptools \ wheel - source venv/bin/activate \ - && pip install \ - --requirement requirements.txt source venv/bin/activate \ && cd $(top_srcdir) \ && pip install \ --editable \ - . + .[testing] touch $@ all-case_utils: \ @@ -63,6 +59,11 @@ check: \ check-mypy \ check-isomorphic_diff \ check-case_utils + source venv/bin/activate \ + && pytest \ + --doctest-modules \ + --log-level=DEBUG \ + $(top_srcdir)/case_utils source venv/bin/activate \ && pytest \ --ignore case_utils \ diff --git a/tests/case_utils/case_file/Makefile b/tests/case_utils/case_file/Makefile index 254a27d..91bf6d6 100644 --- a/tests/case_utils/case_file/Makefile +++ b/tests/case_utils/case_file/Makefile @@ -110,6 +110,7 @@ sample.txt.json: \ $(tests_srcdir)/src/compact.py \ $(tests_srcdir)/src/isomorphic_diff.py \ $(top_srcdir)/case_utils/case_file/__init__.py \ + $(top_srcdir)/case_utils/inherent_uuid.py \ $(top_srcdir)/case_utils/local_uuid.py \ $(top_srcdir)/case_utils/namespace.py \ sample.txt-nocompact.json @@ -118,6 +119,7 @@ sample.txt.json: \ && source $(tests_srcdir)/venv/bin/activate \ && case_file \ --debug \ + --use-deterministic-uuids \ __$@ \ sample.txt source $(tests_srcdir)/venv/bin/activate \ @@ -143,6 +145,7 @@ sample.txt.ttl: \ $(RDF_TOOLKIT_JAR) \ $(tests_srcdir)/.venv.done.log \ $(top_srcdir)/case_utils/case_file/__init__.py \ + $(top_srcdir)/case_utils/inherent_uuid.py \ $(top_srcdir)/case_utils/local_uuid.py \ $(top_srcdir)/case_utils/namespace.py \ sample.txt.done.log @@ -151,6 +154,7 @@ sample.txt.ttl: \ && source $(tests_srcdir)/venv/bin/activate \ && case_file \ --debug \ + --use-deterministic-uuids \ __$@ \ sample.txt java -jar $(RDF_TOOLKIT_JAR) \ @@ -167,6 +171,7 @@ sample.txt-disable_hashes.ttl: \ $(RDF_TOOLKIT_JAR) \ $(tests_srcdir)/.venv.done.log \ $(top_srcdir)/case_utils/case_file/__init__.py \ + $(top_srcdir)/case_utils/inherent_uuid.py \ $(top_srcdir)/case_utils/local_uuid.py \ $(top_srcdir)/case_utils/namespace.py \ sample.txt.done.log @@ -176,6 +181,7 @@ sample.txt-disable_hashes.ttl: \ && case_file \ --debug \ --disable-hashes \ + --use-deterministic-uuids \ __$@ \ sample.txt java -jar $(RDF_TOOLKIT_JAR) \ @@ -193,6 +199,7 @@ sample.txt-nocompact.json: \ $(tests_srcdir)/.venv.done.log \ $(tests_srcdir)/src/isomorphic_diff.py \ $(top_srcdir)/case_utils/case_file/__init__.py \ + $(top_srcdir)/case_utils/inherent_uuid.py \ $(top_srcdir)/case_utils/local_uuid.py \ $(top_srcdir)/case_utils/namespace.py \ sample.txt.done.log @@ -201,6 +208,7 @@ sample.txt-nocompact.json: \ && source $(tests_srcdir)/venv/bin/activate \ && case_file \ --debug \ + --use-deterministic-uuids \ _$@ \ sample.txt # To avoid making noisy, uninformative updates from blank node identifiers, only move the new file into place if it is not isomorphic with the Git-tracked version of the target. diff --git a/tests/case_utils/case_file/kb.json b/tests/case_utils/case_file/kb.json index 771a30b..57549e7 100644 --- a/tests/case_utils/case_file/kb.json +++ b/tests/case_utils/case_file/kb.json @@ -9,20 +9,26 @@ }, "@graph": [ { - "@id": "kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169", + "@id": "kb:ContentDataFacet-e154c2c4-bbf7-54f5-b7a0-837a3bbbeac8", "@type": "uco-observable:ContentDataFacet", "uco-observable:hash": [ { - "@id": "kb:hash-24644904-83ea-5911-aea8-be687a9f3caf" + "@id": "kb:Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337" }, { - "@id": "kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21" + "@id": "kb:Hash-7395c349-e7ab-59b4-acdd-9d857c32413a" }, { - "@id": "kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f" + "@id": "kb:Hash-9527b473-6268-5385-9a74-4eb1a98fef93" }, { - "@id": "kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932" + "@id": "kb:Hash-acdba760-7dc3-5601-8d5f-480c1def8492" + }, + { + "@id": "kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72" + }, + { + "@id": "kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af" } ], "uco-observable:sizeInBytes": { @@ -31,26 +37,26 @@ } }, { - "@id": "kb:file-800784de-5c9e-5eb2-b843-0ac51a1bd4b9", + "@id": "kb:File-23016945-cf7c-5c9c-9fe0-8cefc221ccb2", "@type": "uco-observable:File", "uco-core:hasFacet": { - "@id": "kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d" + "@id": "kb:FileFacet-d086baca-c585-5b5e-b34d-4592bcddb659" } }, { - "@id": "kb:file-ace6460a-92a9-58b9-83ea-a18ae87f6e04", + "@id": "kb:File-fd45a350-f052-5558-b8f1-b4d7d82482a9", "@type": "uco-observable:File", "uco-core:hasFacet": [ { - "@id": "kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169" + "@id": "kb:ContentDataFacet-e154c2c4-bbf7-54f5-b7a0-837a3bbbeac8" }, { - "@id": "kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10" + "@id": "kb:FileFacet-c36436e1-734c-53e5-9e0f-adecdb5e3ab5" } ] }, { - "@id": "kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10", + "@id": "kb:FileFacet-c36436e1-734c-53e5-9e0f-adecdb5e3ab5", "@type": "uco-observable:FileFacet", "uco-observable:fileName": "sample.txt", "uco-observable:modifiedTime": { @@ -63,7 +69,7 @@ } }, { - "@id": "kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d", + "@id": "kb:FileFacet-d086baca-c585-5b5e-b34d-4592bcddb659", "@type": "uco-observable:FileFacet", "uco-observable:fileName": "sample.txt", "uco-observable:modifiedTime": { @@ -76,7 +82,7 @@ } }, { - "@id": "kb:hash-24644904-83ea-5911-aea8-be687a9f3caf", + "@id": "kb:Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", @@ -88,19 +94,19 @@ } }, { - "@id": "kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21", + "@id": "kb:Hash-7395c349-e7ab-59b4-acdd-9d857c32413a", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", - "@value": "SHA1" + "@value": "SHA3-512" }, "uco-types:hashValue": { "@type": "xsd:hexBinary", - "@value": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" + "@value": "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14" } }, { - "@id": "kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f", + "@id": "kb:Hash-9527b473-6268-5385-9a74-4eb1a98fef93", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", @@ -112,7 +118,7 @@ } }, { - "@id": "kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932", + "@id": "kb:Hash-acdba760-7dc3-5601-8d5f-480c1def8492", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", @@ -122,6 +128,30 @@ "@type": "xsd:hexBinary", "@value": "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff" } + }, + { + "@id": "kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72", + "@type": "uco-types:Hash", + "uco-types:hashMethod": { + "@type": "uco-vocabulary:HashNameVocab", + "@value": "SHA3-256" + }, + "uco-types:hashValue": { + "@type": "xsd:hexBinary", + "@value": "36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80" + } + }, + { + "@id": "kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af", + "@type": "uco-types:Hash", + "uco-types:hashMethod": { + "@type": "uco-vocabulary:HashNameVocab", + "@value": "SHA1" + }, + "uco-types:hashValue": { + "@type": "xsd:hexBinary", + "@value": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" + } } ] } \ No newline at end of file diff --git a/tests/case_utils/case_file/kb.ttl b/tests/case_utils/case_file/kb.ttl index 0de60e3..eaf4727 100644 --- a/tests/case_utils/case_file/kb.ttl +++ b/tests/case_utils/case_file/kb.ttl @@ -8,65 +8,79 @@ @prefix uco-vocabulary: . @prefix xsd: . -kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169 +kb:ContentDataFacet-e154c2c4-bbf7-54f5-b7a0-837a3bbbeac8 a uco-observable:ContentDataFacet ; uco-observable:hash - kb:hash-24644904-83ea-5911-aea8-be687a9f3caf , - kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21 , - kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f , - kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932 + kb:Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337 , + kb:Hash-7395c349-e7ab-59b4-acdd-9d857c32413a , + kb:Hash-9527b473-6268-5385-9a74-4eb1a98fef93 , + kb:Hash-acdba760-7dc3-5601-8d5f-480c1def8492 , + kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72 , + kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af ; uco-observable:sizeInBytes "4"^^xsd:integer ; . -kb:file-800784de-5c9e-5eb2-b843-0ac51a1bd4b9 +kb:File-23016945-cf7c-5c9c-9fe0-8cefc221ccb2 a uco-observable:File ; - uco-core:hasFacet kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d ; + uco-core:hasFacet kb:FileFacet-d086baca-c585-5b5e-b34d-4592bcddb659 ; . -kb:file-ace6460a-92a9-58b9-83ea-a18ae87f6e04 +kb:File-fd45a350-f052-5558-b8f1-b4d7d82482a9 a uco-observable:File ; uco-core:hasFacet - kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169 , - kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10 + kb:ContentDataFacet-e154c2c4-bbf7-54f5-b7a0-837a3bbbeac8 , + kb:FileFacet-c36436e1-734c-53e5-9e0f-adecdb5e3ab5 ; . -kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10 +kb:FileFacet-c36436e1-734c-53e5-9e0f-adecdb5e3ab5 a uco-observable:FileFacet ; uco-observable:fileName "sample.txt" ; uco-observable:modifiedTime "2010-01-02T03:04:56+00:00"^^xsd:dateTime ; uco-observable:sizeInBytes "4"^^xsd:integer ; . -kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d +kb:FileFacet-d086baca-c585-5b5e-b34d-4592bcddb659 a uco-observable:FileFacet ; uco-observable:fileName "sample.txt" ; uco-observable:modifiedTime "2010-01-02T03:04:56+00:00"^^xsd:dateTime ; uco-observable:sizeInBytes "4"^^xsd:integer ; . -kb:hash-24644904-83ea-5911-aea8-be687a9f3caf +kb:Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337 a uco-types:Hash ; uco-types:hashMethod "MD5"^^uco-vocabulary:HashNameVocab ; uco-types:hashValue "098f6bcd4621d373cade4e832627b4f6"^^xsd:hexBinary ; . -kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21 +kb:Hash-7395c349-e7ab-59b4-acdd-9d857c32413a a uco-types:Hash ; - uco-types:hashMethod "SHA1"^^uco-vocabulary:HashNameVocab ; - uco-types:hashValue "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"^^xsd:hexBinary ; + uco-types:hashMethod "SHA3-512"^^uco-vocabulary:HashNameVocab ; + uco-types:hashValue "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14"^^xsd:hexBinary ; . -kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f +kb:Hash-9527b473-6268-5385-9a74-4eb1a98fef93 a uco-types:Hash ; uco-types:hashMethod "SHA256"^^uco-vocabulary:HashNameVocab ; uco-types:hashValue "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"^^xsd:hexBinary ; . -kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932 +kb:Hash-acdba760-7dc3-5601-8d5f-480c1def8492 a uco-types:Hash ; uco-types:hashMethod "SHA512"^^uco-vocabulary:HashNameVocab ; uco-types:hashValue "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff"^^xsd:hexBinary ; . +kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72 + a uco-types:Hash ; + uco-types:hashMethod "SHA3-256"^^uco-vocabulary:HashNameVocab ; + uco-types:hashValue "36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80"^^xsd:hexBinary ; + . + +kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af + a uco-types:Hash ; + uco-types:hashMethod "SHA1"^^uco-vocabulary:HashNameVocab ; + uco-types:hashValue "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"^^xsd:hexBinary ; + . + diff --git a/tests/case_utils/case_file/sample.txt-disable_hashes.ttl b/tests/case_utils/case_file/sample.txt-disable_hashes.ttl index d9bc216..904ad82 100644 --- a/tests/case_utils/case_file/sample.txt-disable_hashes.ttl +++ b/tests/case_utils/case_file/sample.txt-disable_hashes.ttl @@ -6,12 +6,12 @@ @prefix uco-observable: . @prefix xsd: . -kb:file-800784de-5c9e-5eb2-b843-0ac51a1bd4b9 +kb:File-23016945-cf7c-5c9c-9fe0-8cefc221ccb2 a uco-observable:File ; - uco-core:hasFacet kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d ; + uco-core:hasFacet kb:FileFacet-d086baca-c585-5b5e-b34d-4592bcddb659 ; . -kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d +kb:FileFacet-d086baca-c585-5b5e-b34d-4592bcddb659 a uco-observable:FileFacet ; uco-observable:fileName "sample.txt" ; uco-observable:modifiedTime "2010-01-02T03:04:56+00:00"^^xsd:dateTime ; diff --git a/tests/case_utils/case_file/sample.txt-nocompact.json b/tests/case_utils/case_file/sample.txt-nocompact.json index 8c59f44..d863fcb 100644 --- a/tests/case_utils/case_file/sample.txt-nocompact.json +++ b/tests/case_utils/case_file/sample.txt-nocompact.json @@ -1,19 +1,55 @@ { "@context": { + "brick": "https://brickschema.org/schema/Brick#", + "csvw": "http://www.w3.org/ns/csvw#", + "dc": "http://purl.org/dc/elements/1.1/", + "dcam": "http://purl.org/dc/dcam/", + "dcat": "http://www.w3.org/ns/dcat#", + "dcmitype": "http://purl.org/dc/dcmitype/", + "dcterms": "http://purl.org/dc/terms/", + "doap": "http://usefulinc.com/ns/doap#", + "foaf": "http://xmlns.com/foaf/0.1/", + "geo": "http://www.opengis.net/ont/geosparql#", "kb": "http://example.org/kb/", + "odrl": "http://www.w3.org/ns/odrl/2/", + "org": "http://www.w3.org/ns/org#", "owl": "http://www.w3.org/2002/07/owl#", + "prof": "http://www.w3.org/ns/dx/prof/", + "prov": "http://www.w3.org/ns/prov#", + "qb": "http://purl.org/linked-data/cube#", "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "schema": "https://schema.org/", + "sh": "http://www.w3.org/ns/shacl#", + "skos": "http://www.w3.org/2004/02/skos/core#", + "sosa": "http://www.w3.org/ns/sosa/", + "ssn": "http://www.w3.org/ns/ssn/", + "time": "http://www.w3.org/2006/time#", "uco-core": "https://ontology.unifiedcyberontology.org/uco/core/", "uco-observable": "https://ontology.unifiedcyberontology.org/uco/observable/", "uco-types": "https://ontology.unifiedcyberontology.org/uco/types/", "uco-vocabulary": "https://ontology.unifiedcyberontology.org/uco/vocabulary/", + "vann": "http://purl.org/vocab/vann/", + "void": "http://rdfs.org/ns/void#", + "wgs": "https://www.w3.org/2003/01/geo/wgs84_pos#", "xml": "http://www.w3.org/XML/1998/namespace", "xsd": "http://www.w3.org/2001/XMLSchema#" }, "@graph": [ { - "@id": "http://example.org/kb/hash-c77cb4f1-ac2a-52c7-b67e-016e209515cb", + "@id": "http://example.org/kb/Hash-7395c349-e7ab-59b4-acdd-9d857c32413a", + "@type": "https://ontology.unifiedcyberontology.org/uco/types/Hash", + "https://ontology.unifiedcyberontology.org/uco/types/hashMethod": { + "@type": "https://ontology.unifiedcyberontology.org/uco/vocabulary/HashNameVocab", + "@value": "SHA3-512" + }, + "https://ontology.unifiedcyberontology.org/uco/types/hashValue": { + "@type": "http://www.w3.org/2001/XMLSchema#hexBinary", + "@value": "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14" + } + }, + { + "@id": "http://example.org/kb/Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af", "@type": "https://ontology.unifiedcyberontology.org/uco/types/Hash", "https://ontology.unifiedcyberontology.org/uco/types/hashMethod": { "@type": "https://ontology.unifiedcyberontology.org/uco/vocabulary/HashNameVocab", @@ -25,19 +61,19 @@ } }, { - "@id": "http://example.org/kb/file-23f45d80-7b16-5e7f-ba34-40392fa4f8fc", - "@type": "https://ontology.unifiedcyberontology.org/uco/observable/File", - "https://ontology.unifiedcyberontology.org/uco/core/hasFacet": [ - { - "@id": "http://example.org/kb/file-facet-a5d9606e-a5cf-5531-9462-5bed0ac4219c" - }, - { - "@id": "http://example.org/kb/content-data-facet-bda9b72d-2753-54ab-9292-e1e260be4f6d" - } - ] + "@id": "http://example.org/kb/Hash-acdba760-7dc3-5601-8d5f-480c1def8492", + "@type": "https://ontology.unifiedcyberontology.org/uco/types/Hash", + "https://ontology.unifiedcyberontology.org/uco/types/hashMethod": { + "@type": "https://ontology.unifiedcyberontology.org/uco/vocabulary/HashNameVocab", + "@value": "SHA512" + }, + "https://ontology.unifiedcyberontology.org/uco/types/hashValue": { + "@type": "http://www.w3.org/2001/XMLSchema#hexBinary", + "@value": "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff" + } }, { - "@id": "http://example.org/kb/hash-bdb2ba7d-8cb2-5591-a051-0c20d134e894", + "@id": "http://example.org/kb/Hash-9527b473-6268-5385-9a74-4eb1a98fef93", "@type": "https://ontology.unifiedcyberontology.org/uco/types/Hash", "https://ontology.unifiedcyberontology.org/uco/types/hashMethod": { "@type": "https://ontology.unifiedcyberontology.org/uco/vocabulary/HashNameVocab", @@ -49,38 +85,44 @@ } }, { - "@id": "http://example.org/kb/hash-bf689e82-1cc4-507f-a6fb-7fc01b9289c6", + "@id": "http://example.org/kb/Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72", "@type": "https://ontology.unifiedcyberontology.org/uco/types/Hash", "https://ontology.unifiedcyberontology.org/uco/types/hashMethod": { "@type": "https://ontology.unifiedcyberontology.org/uco/vocabulary/HashNameVocab", - "@value": "SHA512" + "@value": "SHA3-256" }, "https://ontology.unifiedcyberontology.org/uco/types/hashValue": { "@type": "http://www.w3.org/2001/XMLSchema#hexBinary", - "@value": "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff" + "@value": "36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80" } }, { - "@id": "http://example.org/kb/content-data-facet-bda9b72d-2753-54ab-9292-e1e260be4f6d", + "@id": "http://example.org/kb/ContentDataFacet-3258a70d-6307-5a70-b796-b6ffd530700a", "@type": "https://ontology.unifiedcyberontology.org/uco/observable/ContentDataFacet", "https://ontology.unifiedcyberontology.org/uco/observable/hash": [ { - "@id": "http://example.org/kb/hash-8ebb651a-314b-554a-b63e-78b9e69111d8" + "@id": "http://example.org/kb/Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337" + }, + { + "@id": "http://example.org/kb/Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af" + }, + { + "@id": "http://example.org/kb/Hash-9527b473-6268-5385-9a74-4eb1a98fef93" }, { - "@id": "http://example.org/kb/hash-c77cb4f1-ac2a-52c7-b67e-016e209515cb" + "@id": "http://example.org/kb/Hash-acdba760-7dc3-5601-8d5f-480c1def8492" }, { - "@id": "http://example.org/kb/hash-bdb2ba7d-8cb2-5591-a051-0c20d134e894" + "@id": "http://example.org/kb/Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72" }, { - "@id": "http://example.org/kb/hash-bf689e82-1cc4-507f-a6fb-7fc01b9289c6" + "@id": "http://example.org/kb/Hash-7395c349-e7ab-59b4-acdd-9d857c32413a" } ], "https://ontology.unifiedcyberontology.org/uco/observable/sizeInBytes": 4 }, { - "@id": "http://example.org/kb/file-facet-a5d9606e-a5cf-5531-9462-5bed0ac4219c", + "@id": "http://example.org/kb/FileFacet-3e49a502-dc39-5ff2-9148-2601e1929e2b", "@type": "https://ontology.unifiedcyberontology.org/uco/observable/FileFacet", "https://ontology.unifiedcyberontology.org/uco/observable/fileName": "sample.txt", "https://ontology.unifiedcyberontology.org/uco/observable/modifiedTime": { @@ -90,7 +132,19 @@ "https://ontology.unifiedcyberontology.org/uco/observable/sizeInBytes": 4 }, { - "@id": "http://example.org/kb/hash-8ebb651a-314b-554a-b63e-78b9e69111d8", + "@id": "http://example.org/kb/File-a28858e3-5087-5c84-a2b6-710b00b15605", + "@type": "https://ontology.unifiedcyberontology.org/uco/observable/File", + "https://ontology.unifiedcyberontology.org/uco/core/hasFacet": [ + { + "@id": "http://example.org/kb/FileFacet-3e49a502-dc39-5ff2-9148-2601e1929e2b" + }, + { + "@id": "http://example.org/kb/ContentDataFacet-3258a70d-6307-5a70-b796-b6ffd530700a" + } + ] + }, + { + "@id": "http://example.org/kb/Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337", "@type": "https://ontology.unifiedcyberontology.org/uco/types/Hash", "https://ontology.unifiedcyberontology.org/uco/types/hashMethod": { "@type": "https://ontology.unifiedcyberontology.org/uco/vocabulary/HashNameVocab", diff --git a/tests/case_utils/case_file/sample.txt.json b/tests/case_utils/case_file/sample.txt.json index a4a97c8..ddd6f39 100644 --- a/tests/case_utils/case_file/sample.txt.json +++ b/tests/case_utils/case_file/sample.txt.json @@ -1,84 +1,114 @@ { "@context": { + "brick": "https://brickschema.org/schema/Brick#", + "csvw": "http://www.w3.org/ns/csvw#", + "dc": "http://purl.org/dc/elements/1.1/", + "dcam": "http://purl.org/dc/dcam/", + "dcat": "http://www.w3.org/ns/dcat#", + "dcmitype": "http://purl.org/dc/dcmitype/", + "dcterms": "http://purl.org/dc/terms/", + "doap": "http://usefulinc.com/ns/doap#", + "foaf": "http://xmlns.com/foaf/0.1/", + "geo": "http://www.opengis.net/ont/geosparql#", "kb": "http://example.org/kb/", + "odrl": "http://www.w3.org/ns/odrl/2/", + "org": "http://www.w3.org/ns/org#", "owl": "http://www.w3.org/2002/07/owl#", + "prof": "http://www.w3.org/ns/dx/prof/", + "prov": "http://www.w3.org/ns/prov#", + "qb": "http://purl.org/linked-data/cube#", "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "schema": "https://schema.org/", + "sh": "http://www.w3.org/ns/shacl#", + "skos": "http://www.w3.org/2004/02/skos/core#", + "sosa": "http://www.w3.org/ns/sosa/", + "ssn": "http://www.w3.org/ns/ssn/", + "time": "http://www.w3.org/2006/time#", "uco-core": "https://ontology.unifiedcyberontology.org/uco/core/", "uco-observable": "https://ontology.unifiedcyberontology.org/uco/observable/", "uco-types": "https://ontology.unifiedcyberontology.org/uco/types/", "uco-vocabulary": "https://ontology.unifiedcyberontology.org/uco/vocabulary/", + "vann": "http://purl.org/vocab/vann/", + "void": "http://rdfs.org/ns/void#", + "wgs": "https://www.w3.org/2003/01/geo/wgs84_pos#", "xml": "http://www.w3.org/XML/1998/namespace", "xsd": "http://www.w3.org/2001/XMLSchema#" }, "@graph": [ { - "@id": "kb:hash-2cae4ae2-d773-5ea2-ba3e-2c4092574959", + "@id": "kb:Hash-9527b473-6268-5385-9a74-4eb1a98fef93", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", - "@value": "SHA1" + "@value": "SHA256" }, "uco-types:hashValue": { "@type": "xsd:hexBinary", - "@value": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" + "@value": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" } }, { - "@id": "kb:hash-f067246c-a31a-597d-a84b-7b70ce4c8795", + "@id": "kb:FileFacet-0f05ce89-c779-5bc7-a7f1-3521c895946b", + "@type": "uco-observable:FileFacet", + "uco-observable:fileName": "sample.txt", + "uco-observable:modifiedTime": { + "@type": "xsd:dateTime", + "@value": "2010-01-02T03:04:56+00:00" + }, + "uco-observable:sizeInBytes": 4 + }, + { + "@id": "kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", - "@value": "MD5" + "@value": "SHA1" }, "uco-types:hashValue": { "@type": "xsd:hexBinary", - "@value": "098f6bcd4621d373cade4e832627b4f6" + "@value": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" } }, { - "@id": "kb:file-facet-e6bb7192-3a63-561b-87c2-9aea090b49e4", - "@type": "uco-observable:FileFacet", - "uco-observable:fileName": "sample.txt", - "uco-observable:modifiedTime": { - "@type": "xsd:dateTime", - "@value": "2010-01-02T03:04:56+00:00" + "@id": "kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72", + "@type": "uco-types:Hash", + "uco-types:hashMethod": { + "@type": "uco-vocabulary:HashNameVocab", + "@value": "SHA3-256" }, - "uco-observable:sizeInBytes": 4 + "uco-types:hashValue": { + "@type": "xsd:hexBinary", + "@value": "36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80" + } }, { - "@id": "kb:file-789a91ef-6446-548c-9911-dcc5168f25ea", - "@type": "uco-observable:File", - "uco-core:hasFacet": [ + "@id": "kb:ContentDataFacet-bb169f87-b3b7-55b5-96a5-dec7738c441b", + "@type": "uco-observable:ContentDataFacet", + "uco-observable:hash": [ { - "@id": "kb:file-facet-e6bb7192-3a63-561b-87c2-9aea090b49e4" + "@id": "kb:Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337" }, { - "@id": "kb:content-data-facet-f48466e4-5394-584d-84ad-c46a7b9680bf" - } - ] - }, - { - "@id": "kb:content-data-facet-f48466e4-5394-584d-84ad-c46a7b9680bf", - "@type": "uco-observable:ContentDataFacet", - "uco-observable:hash": [ + "@id": "kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af" + }, { - "@id": "kb:hash-f067246c-a31a-597d-a84b-7b70ce4c8795" + "@id": "kb:Hash-9527b473-6268-5385-9a74-4eb1a98fef93" }, { - "@id": "kb:hash-2cae4ae2-d773-5ea2-ba3e-2c4092574959" + "@id": "kb:Hash-acdba760-7dc3-5601-8d5f-480c1def8492" }, { - "@id": "kb:hash-2b723e8c-6125-5867-83c3-a46753e41a07" + "@id": "kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72" }, { - "@id": "kb:hash-9652135a-b58d-592d-b0f4-ac684ecdf6ed" + "@id": "kb:Hash-7395c349-e7ab-59b4-acdd-9d857c32413a" } ], "uco-observable:sizeInBytes": 4 }, { - "@id": "kb:hash-9652135a-b58d-592d-b0f4-ac684ecdf6ed", + "@id": "kb:Hash-acdba760-7dc3-5601-8d5f-480c1def8492", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", @@ -90,16 +120,40 @@ } }, { - "@id": "kb:hash-2b723e8c-6125-5867-83c3-a46753e41a07", + "@id": "kb:Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", - "@value": "SHA256" + "@value": "MD5" }, "uco-types:hashValue": { "@type": "xsd:hexBinary", - "@value": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" + "@value": "098f6bcd4621d373cade4e832627b4f6" } + }, + { + "@id": "kb:Hash-7395c349-e7ab-59b4-acdd-9d857c32413a", + "@type": "uco-types:Hash", + "uco-types:hashMethod": { + "@type": "uco-vocabulary:HashNameVocab", + "@value": "SHA3-512" + }, + "uco-types:hashValue": { + "@type": "xsd:hexBinary", + "@value": "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14" + } + }, + { + "@id": "kb:File-d15507da-29e5-5575-bce6-f59dc788dcc9", + "@type": "uco-observable:File", + "uco-core:hasFacet": [ + { + "@id": "kb:FileFacet-0f05ce89-c779-5bc7-a7f1-3521c895946b" + }, + { + "@id": "kb:ContentDataFacet-bb169f87-b3b7-55b5-96a5-dec7738c441b" + } + ] } ] } \ No newline at end of file diff --git a/tests/case_utils/case_file/sample.txt.ttl b/tests/case_utils/case_file/sample.txt.ttl index 8f20b60..d84275d 100644 --- a/tests/case_utils/case_file/sample.txt.ttl +++ b/tests/case_utils/case_file/sample.txt.ttl @@ -8,53 +8,67 @@ @prefix uco-vocabulary: . @prefix xsd: . -kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169 +kb:ContentDataFacet-e154c2c4-bbf7-54f5-b7a0-837a3bbbeac8 a uco-observable:ContentDataFacet ; uco-observable:hash - kb:hash-24644904-83ea-5911-aea8-be687a9f3caf , - kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21 , - kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f , - kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932 + kb:Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337 , + kb:Hash-7395c349-e7ab-59b4-acdd-9d857c32413a , + kb:Hash-9527b473-6268-5385-9a74-4eb1a98fef93 , + kb:Hash-acdba760-7dc3-5601-8d5f-480c1def8492 , + kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72 , + kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af ; uco-observable:sizeInBytes "4"^^xsd:integer ; . -kb:file-ace6460a-92a9-58b9-83ea-a18ae87f6e04 +kb:File-fd45a350-f052-5558-b8f1-b4d7d82482a9 a uco-observable:File ; uco-core:hasFacet - kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169 , - kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10 + kb:ContentDataFacet-e154c2c4-bbf7-54f5-b7a0-837a3bbbeac8 , + kb:FileFacet-c36436e1-734c-53e5-9e0f-adecdb5e3ab5 ; . -kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10 +kb:FileFacet-c36436e1-734c-53e5-9e0f-adecdb5e3ab5 a uco-observable:FileFacet ; uco-observable:fileName "sample.txt" ; uco-observable:modifiedTime "2010-01-02T03:04:56+00:00"^^xsd:dateTime ; uco-observable:sizeInBytes "4"^^xsd:integer ; . -kb:hash-24644904-83ea-5911-aea8-be687a9f3caf +kb:Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337 a uco-types:Hash ; uco-types:hashMethod "MD5"^^uco-vocabulary:HashNameVocab ; uco-types:hashValue "098f6bcd4621d373cade4e832627b4f6"^^xsd:hexBinary ; . -kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21 +kb:Hash-7395c349-e7ab-59b4-acdd-9d857c32413a a uco-types:Hash ; - uco-types:hashMethod "SHA1"^^uco-vocabulary:HashNameVocab ; - uco-types:hashValue "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"^^xsd:hexBinary ; + uco-types:hashMethod "SHA3-512"^^uco-vocabulary:HashNameVocab ; + uco-types:hashValue "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14"^^xsd:hexBinary ; . -kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f +kb:Hash-9527b473-6268-5385-9a74-4eb1a98fef93 a uco-types:Hash ; uco-types:hashMethod "SHA256"^^uco-vocabulary:HashNameVocab ; uco-types:hashValue "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"^^xsd:hexBinary ; . -kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932 +kb:Hash-acdba760-7dc3-5601-8d5f-480c1def8492 a uco-types:Hash ; uco-types:hashMethod "SHA512"^^uco-vocabulary:HashNameVocab ; uco-types:hashValue "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff"^^xsd:hexBinary ; . +kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72 + a uco-types:Hash ; + uco-types:hashMethod "SHA3-256"^^uco-vocabulary:HashNameVocab ; + uco-types:hashValue "36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80"^^xsd:hexBinary ; + . + +kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af + a uco-types:Hash ; + uco-types:hashMethod "SHA1"^^uco-vocabulary:HashNameVocab ; + uco-types:hashValue "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"^^xsd:hexBinary ; + . + diff --git a/tests/case_utils/case_file/test_case_file.py b/tests/case_utils/case_file/test_case_file.py index 75c9123..9194f7d 100644 --- a/tests/case_utils/case_file/test_case_file.py +++ b/tests/case_utils/case_file/test_case_file.py @@ -56,6 +56,8 @@ def test_confirm_hashes(graph_case_file: rdflib.Graph) -> None: "SHA1": "A94A8FE5CCB19BA61C4C0873D391E987982FBBD3", "SHA256": "9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08", "SHA512": "EE26B0DD4AF7E749AA1A8EE3C10AE9923F618980772E473F8819A5D4940E0DB27AC185F8A0E1D5F84F88BC887FD67B143732C304CC5FA9AD8E6F57F50028A8FF", + "SHA3-256": "36F028580BB02CC8272A9A020F4200E346E276AE664E45EE80745574E2F5AB80", + "SHA3-512": "9ECE086E9BAC491FAC5C1D1046CA11D737B92A2B2EBD93F005D7B710110C0A678288166E7FBE796883A4F2E9B3CA9F484F521D0CE464345CC1AEC96779149C14", } computed = dict() diff --git a/tests/requirements.txt b/tests/requirements.txt deleted file mode 100644 index f913d96..0000000 --- a/tests/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -PyLD -mypy -pytest -python-dateutil -types-python-dateutil