diff --git a/case_utils/case_file/__init__.py b/case_utils/case_file/__init__.py index e58fa92..536e7fb 100644 --- a/case_utils/case_file/__init__.py +++ b/case_utils/case_file/__init__.py @@ -27,7 +27,7 @@ import rdflib -import case_utils +import case_utils.inherent_uuid from case_utils.namespace import ( NS_RDF, NS_UCO_CORE, @@ -60,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. @@ -70,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. @@ -88,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)) @@ -97,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, @@ -124,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) @@ -204,9 +222,8 @@ def create_file_node( for key in successful_hashdict._fields: if key not in ("md5", "sha1", "sha256", "sha512", "sha3_256", "sha3_512"): continue - n_hash = node_namespace["hash-" + case_utils.local_uuid.local_uuid()] - graph.add((n_contentdata_facet, NS_UCO_OBSERVABLE.hash, n_hash)) - graph.add((n_hash, NS_RDF.type, NS_UCO_TYPES.Hash)) + + l_hash_method: rdflib.Literal if key in ("sha3_256", "sha3_512"): l_hash_method = rdflib.Literal( key.replace("_", "-").upper(), @@ -216,6 +233,23 @@ def create_file_node( 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, @@ -223,12 +257,11 @@ def create_file_node( 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, ) ) @@ -241,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." ) @@ -273,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, @@ -281,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..058de59 --- /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.0.3" + +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_uco_thing: URIRef, *args: Any, **kwargs: Any) -> uuid.UUID: + """ + This function returns a UUIDv5 for any UcoThing, that can be used as a UUID Namespace in further `uuid.uuidv5` calls. + + In the case that the UcoThing 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 node 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_uco_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..e85f0ff 100644 --- a/case_utils/ontology/src/ontology_and_version_iris.py +++ b/case_utils/ontology/src/ontology_and_version_iris.py @@ -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/tests/Makefile b/tests/Makefile index c1c626e..f38243d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -59,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 5aa6bc9..57549e7 100644 --- a/tests/case_utils/case_file/kb.json +++ b/tests/case_utils/case_file/kb.json @@ -9,26 +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-720759b8-9544-5dab-ab12-003372b17a4e" + "@id": "kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72" }, { - "@id": "kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93" + "@id": "kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af" } ], "uco-observable:sizeInBytes": { @@ -37,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": { @@ -69,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": { @@ -82,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", @@ -94,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", @@ -118,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", @@ -130,27 +130,27 @@ } }, { - "@id": "kb:hash-720759b8-9544-5dab-ab12-003372b17a4e", + "@id": "kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", - "@value": "SHA3-512" + "@value": "SHA3-256" }, "uco-types:hashValue": { "@type": "xsd:hexBinary", - "@value": "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14" + "@value": "36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80" } }, { - "@id": "kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93", + "@id": "kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", - "@value": "SHA3-256" + "@value": "SHA1" }, "uco-types:hashValue": { "@type": "xsd:hexBinary", - "@value": "36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80" + "@value": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" } } ] diff --git a/tests/case_utils/case_file/kb.ttl b/tests/case_utils/case_file/kb.ttl index 566013e..eaf4727 100644 --- a/tests/case_utils/case_file/kb.ttl +++ b/tests/case_utils/case_file/kb.ttl @@ -8,79 +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-720759b8-9544-5dab-ab12-003372b17a4e , - kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93 + 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-720759b8-9544-5dab-ab12-003372b17a4e +kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72 a uco-types:Hash ; - uco-types:hashMethod "SHA3-512"^^uco-vocabulary:HashNameVocab ; - uco-types:hashValue "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14"^^xsd:hexBinary ; + uco-types:hashMethod "SHA3-256"^^uco-vocabulary:HashNameVocab ; + uco-types:hashValue "36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80"^^xsd:hexBinary ; . -kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93 +kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af a uco-types:Hash ; - uco-types:hashMethod "SHA3-256"^^uco-vocabulary:HashNameVocab ; - uco-types:hashValue "36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80"^^xsd:hexBinary ; + 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 efdb4b7..d863fcb 100644 --- a/tests/case_utils/case_file/sample.txt-nocompact.json +++ b/tests/case_utils/case_file/sample.txt-nocompact.json @@ -37,102 +37,55 @@ }, "@graph": [ { - "@id": "http://example.org/kb/content-data-facet-bda9b72d-2753-54ab-9292-e1e260be4f6d", - "@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-c77cb4f1-ac2a-52c7-b67e-016e209515cb" - }, - { - "@id": "http://example.org/kb/hash-bdb2ba7d-8cb2-5591-a051-0c20d134e894" - }, - { - "@id": "http://example.org/kb/hash-bf689e82-1cc4-507f-a6fb-7fc01b9289c6" - }, - { - "@id": "http://example.org/kb/hash-dd2161f0-4943-55c0-b08e-a2ad8a85dce8" - }, - { - "@id": "http://example.org/kb/hash-28dd6731-4eda-5ae7-9810-efedc7593912" - } - ], - "https://ontology.unifiedcyberontology.org/uco/observable/sizeInBytes": 4 - }, - { - "@id": "http://example.org/kb/hash-bdb2ba7d-8cb2-5591-a051-0c20d134e894", + "@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": "SHA256" + "@value": "SHA3-512" }, "https://ontology.unifiedcyberontology.org/uco/types/hashValue": { "@type": "http://www.w3.org/2001/XMLSchema#hexBinary", - "@value": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" + "@value": "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14" } }, { - "@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-28dd6731-4eda-5ae7-9810-efedc7593912", + "@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", - "@value": "SHA3-512" + "@value": "SHA1" }, "https://ontology.unifiedcyberontology.org/uco/types/hashValue": { "@type": "http://www.w3.org/2001/XMLSchema#hexBinary", - "@value": "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14" + "@value": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" } }, { - "@id": "http://example.org/kb/file-facet-a5d9606e-a5cf-5531-9462-5bed0ac4219c", - "@type": "https://ontology.unifiedcyberontology.org/uco/observable/FileFacet", - "https://ontology.unifiedcyberontology.org/uco/observable/fileName": "sample.txt", - "https://ontology.unifiedcyberontology.org/uco/observable/modifiedTime": { - "@type": "http://www.w3.org/2001/XMLSchema#dateTime", - "@value": "2010-01-02T03:04:56+00:00" - }, - "https://ontology.unifiedcyberontology.org/uco/observable/sizeInBytes": 4 - }, - { - "@id": "http://example.org/kb/hash-8ebb651a-314b-554a-b63e-78b9e69111d8", + "@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": "MD5" + "@value": "SHA512" }, "https://ontology.unifiedcyberontology.org/uco/types/hashValue": { "@type": "http://www.w3.org/2001/XMLSchema#hexBinary", - "@value": "098f6bcd4621d373cade4e832627b4f6" + "@value": "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff" } }, { - "@id": "http://example.org/kb/hash-bf689e82-1cc4-507f-a6fb-7fc01b9289c6", + "@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", - "@value": "SHA512" + "@value": "SHA256" }, "https://ontology.unifiedcyberontology.org/uco/types/hashValue": { "@type": "http://www.w3.org/2001/XMLSchema#hexBinary", - "@value": "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff" + "@value": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" } }, { - "@id": "http://example.org/kb/hash-dd2161f0-4943-55c0-b08e-a2ad8a85dce8", + "@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", @@ -144,15 +97,62 @@ } }, { - "@id": "http://example.org/kb/hash-c77cb4f1-ac2a-52c7-b67e-016e209515cb", + "@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-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-acdba760-7dc3-5601-8d5f-480c1def8492" + }, + { + "@id": "http://example.org/kb/Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72" + }, + { + "@id": "http://example.org/kb/Hash-7395c349-e7ab-59b4-acdd-9d857c32413a" + } + ], + "https://ontology.unifiedcyberontology.org/uco/observable/sizeInBytes": 4 + }, + { + "@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": { + "@type": "http://www.w3.org/2001/XMLSchema#dateTime", + "@value": "2010-01-02T03:04:56+00:00" + }, + "https://ontology.unifiedcyberontology.org/uco/observable/sizeInBytes": 4 + }, + { + "@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", - "@value": "SHA1" + "@value": "MD5" }, "https://ontology.unifiedcyberontology.org/uco/types/hashValue": { "@type": "http://www.w3.org/2001/XMLSchema#hexBinary", - "@value": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" + "@value": "098f6bcd4621d373cade4e832627b4f6" } } ] diff --git a/tests/case_utils/case_file/sample.txt.json b/tests/case_utils/case_file/sample.txt.json index 7120e96..ddd6f39 100644 --- a/tests/case_utils/case_file/sample.txt.json +++ b/tests/case_utils/case_file/sample.txt.json @@ -37,19 +37,7 @@ }, "@graph": [ { - "@id": "kb:file-789a91ef-6446-548c-9911-dcc5168f25ea", - "@type": "uco-observable:File", - "uco-core:hasFacet": [ - { - "@id": "kb:file-facet-e6bb7192-3a63-561b-87c2-9aea090b49e4" - }, - { - "@id": "kb:content-data-facet-f48466e4-5394-584d-84ad-c46a7b9680bf" - } - ] - }, - { - "@id": "kb:hash-2b723e8c-6125-5867-83c3-a46753e41a07", + "@id": "kb:Hash-9527b473-6268-5385-9a74-4eb1a98fef93", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", @@ -61,7 +49,17 @@ } }, { - "@id": "kb:hash-2cae4ae2-d773-5ea2-ba3e-2c4092574959", + "@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", @@ -73,7 +71,7 @@ } }, { - "@id": "kb:hash-b656d6d4-b99b-58c8-a487-9889713a8efe", + "@id": "kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", @@ -85,7 +83,32 @@ } }, { - "@id": "kb:hash-9652135a-b58d-592d-b0f4-ac684ecdf6ed", + "@id": "kb:ContentDataFacet-bb169f87-b3b7-55b5-96a5-dec7738c441b", + "@type": "uco-observable:ContentDataFacet", + "uco-observable:hash": [ + { + "@id": "kb:Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337" + }, + { + "@id": "kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af" + }, + { + "@id": "kb:Hash-9527b473-6268-5385-9a74-4eb1a98fef93" + }, + { + "@id": "kb:Hash-acdba760-7dc3-5601-8d5f-480c1def8492" + }, + { + "@id": "kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72" + }, + { + "@id": "kb:Hash-7395c349-e7ab-59b4-acdd-9d857c32413a" + } + ], + "uco-observable:sizeInBytes": 4 + }, + { + "@id": "kb:Hash-acdba760-7dc3-5601-8d5f-480c1def8492", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", @@ -97,63 +120,40 @@ } }, { - "@id": "kb:hash-3228c9ed-792d-5603-afc2-8b9a9752606d", + "@id": "kb:Hash-244595b7-3a16-50e3-ab5d-1fc767d4f337", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", - "@value": "SHA3-512" + "@value": "MD5" }, "uco-types:hashValue": { "@type": "xsd:hexBinary", - "@value": "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14" + "@value": "098f6bcd4621d373cade4e832627b4f6" } }, { - "@id": "kb:hash-f067246c-a31a-597d-a84b-7b70ce4c8795", + "@id": "kb:Hash-7395c349-e7ab-59b4-acdd-9d857c32413a", "@type": "uco-types:Hash", "uco-types:hashMethod": { "@type": "uco-vocabulary:HashNameVocab", - "@value": "MD5" + "@value": "SHA3-512" }, "uco-types:hashValue": { "@type": "xsd:hexBinary", - "@value": "098f6bcd4621d373cade4e832627b4f6" + "@value": "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14" } }, { - "@id": "kb:content-data-facet-f48466e4-5394-584d-84ad-c46a7b9680bf", - "@type": "uco-observable:ContentDataFacet", - "uco-observable:hash": [ - { - "@id": "kb:hash-f067246c-a31a-597d-a84b-7b70ce4c8795" - }, - { - "@id": "kb:hash-2cae4ae2-d773-5ea2-ba3e-2c4092574959" - }, - { - "@id": "kb:hash-2b723e8c-6125-5867-83c3-a46753e41a07" - }, - { - "@id": "kb:hash-9652135a-b58d-592d-b0f4-ac684ecdf6ed" - }, + "@id": "kb:File-d15507da-29e5-5575-bce6-f59dc788dcc9", + "@type": "uco-observable:File", + "uco-core:hasFacet": [ { - "@id": "kb:hash-b656d6d4-b99b-58c8-a487-9889713a8efe" + "@id": "kb:FileFacet-0f05ce89-c779-5bc7-a7f1-3521c895946b" }, { - "@id": "kb:hash-3228c9ed-792d-5603-afc2-8b9a9752606d" + "@id": "kb:ContentDataFacet-bb169f87-b3b7-55b5-96a5-dec7738c441b" } - ], - "uco-observable:sizeInBytes": 4 - }, - { - "@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" - }, - "uco-observable:sizeInBytes": 4 + ] } ] } \ 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 ddccd88..d84275d 100644 --- a/tests/case_utils/case_file/sample.txt.ttl +++ b/tests/case_utils/case_file/sample.txt.ttl @@ -8,67 +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-720759b8-9544-5dab-ab12-003372b17a4e , - kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93 + 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-720759b8-9544-5dab-ab12-003372b17a4e +kb:Hash-ae02b896-5a0b-57c0-9441-c90ce6382a72 a uco-types:Hash ; - uco-types:hashMethod "SHA3-512"^^uco-vocabulary:HashNameVocab ; - uco-types:hashValue "9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14"^^xsd:hexBinary ; + uco-types:hashMethod "SHA3-256"^^uco-vocabulary:HashNameVocab ; + uco-types:hashValue "36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80"^^xsd:hexBinary ; . -kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93 +kb:Hash-fe2030ac-2380-520f-8499-5f2a1e5d69af a uco-types:Hash ; - uco-types:hashMethod "SHA3-256"^^uco-vocabulary:HashNameVocab ; - uco-types:hashValue "36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80"^^xsd:hexBinary ; + uco-types:hashMethod "SHA1"^^uco-vocabulary:HashNameVocab ; + uco-types:hashValue "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"^^xsd:hexBinary ; .