Skip to content

Change start of NamedIndividuals' suffices to use last path-segment of class's IRI #110

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions case_utils/case_file/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,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-' + uuid4``
:type node_iri: str
:param node_prefix: The base prefix to use if node_iri is not supplied.
Expand All @@ -88,7 +88,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))
Expand All @@ -97,7 +97,7 @@ 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 = node_namespace["FileFacet-" + case_utils.local_uuid.local_uuid()]
graph.add(
(
n_file_facet,
Expand Down Expand Up @@ -273,7 +273,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,
Expand Down
70 changes: 35 additions & 35 deletions tests/case_utils/case_file/kb.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,26 @@
},
"@graph": [
{
"@id": "kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169",
"@type": "uco-observable:ContentDataFacet",
"uco-observable:hash": [
{
"@id": "kb:hash-24644904-83ea-5911-aea8-be687a9f3caf"
},
{
"@id": "kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21"
},
{
"@id": "kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f"
},
{
"@id": "kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932"
},
{
"@id": "kb:hash-720759b8-9544-5dab-ab12-003372b17a4e"
},
{
"@id": "kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93"
}
],
"uco-observable:sizeInBytes": {
"@type": "xsd:integer",
"@value": "4"
}
},
{
"@id": "kb:file-800784de-5c9e-5eb2-b843-0ac51a1bd4b9",
"@id": "kb:File-800784de-5c9e-5eb2-b843-0ac51a1bd4b9",
"@type": "uco-observable:File",
"uco-core:hasFacet": {
"@id": "kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d"
"@id": "kb:FileFacet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d"
}
},
{
"@id": "kb:file-ace6460a-92a9-58b9-83ea-a18ae87f6e04",
"@id": "kb:File-ace6460a-92a9-58b9-83ea-a18ae87f6e04",
"@type": "uco-observable:File",
"uco-core:hasFacet": [
{
"@id": "kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169"
"@id": "kb:FileFacet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10"
},
{
"@id": "kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10"
"@id": "kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169"
}
]
},
{
"@id": "kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10",
"@id": "kb:FileFacet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10",
"@type": "uco-observable:FileFacet",
"uco-observable:fileName": "sample.txt",
"uco-observable:modifiedTime": {
Expand All @@ -69,7 +41,7 @@
}
},
{
"@id": "kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d",
"@id": "kb:FileFacet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d",
"@type": "uco-observable:FileFacet",
"uco-observable:fileName": "sample.txt",
"uco-observable:modifiedTime": {
Expand All @@ -81,6 +53,34 @@
"@value": "4"
}
},
{
"@id": "kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169",
"@type": "uco-observable:ContentDataFacet",
"uco-observable:hash": [
{
"@id": "kb:hash-24644904-83ea-5911-aea8-be687a9f3caf"
},
{
"@id": "kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21"
},
{
"@id": "kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f"
},
{
"@id": "kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932"
},
{
"@id": "kb:hash-720759b8-9544-5dab-ab12-003372b17a4e"
},
{
"@id": "kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93"
}
],
"uco-observable:sizeInBytes": {
"@type": "xsd:integer",
"@value": "4"
}
},
{
"@id": "kb:hash-24644904-83ea-5911-aea8-be687a9f3caf",
"@type": "uco-types:Hash",
Expand Down
40 changes: 20 additions & 20 deletions tests/case_utils/case_file/kb.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,46 @@
@prefix uco-vocabulary: <https://ontology.unifiedcyberontology.org/uco/vocabulary/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169
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
;
uco-observable:sizeInBytes "4"^^xsd:integer ;
.

kb:file-800784de-5c9e-5eb2-b843-0ac51a1bd4b9
kb:File-800784de-5c9e-5eb2-b843-0ac51a1bd4b9
a uco-observable:File ;
uco-core:hasFacet kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d ;
uco-core:hasFacet kb:FileFacet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d ;
.

kb:file-ace6460a-92a9-58b9-83ea-a18ae87f6e04
kb:File-ace6460a-92a9-58b9-83ea-a18ae87f6e04
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:FileFacet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10 ,
kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169
;
.

kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10
kb:FileFacet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10
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-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d
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:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169
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
;
uco-observable:sizeInBytes "4"^^xsd:integer ;
.

kb:hash-24644904-83ea-5911-aea8-be687a9f3caf
a uco-types:Hash ;
uco-types:hashMethod "MD5"^^uco-vocabulary:HashNameVocab ;
Expand Down
6 changes: 3 additions & 3 deletions tests/case_utils/case_file/sample.txt-disable_hashes.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
@prefix uco-observable: <https://ontology.unifiedcyberontology.org/uco/observable/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

kb:file-800784de-5c9e-5eb2-b843-0ac51a1bd4b9
kb:File-800784de-5c9e-5eb2-b843-0ac51a1bd4b9
a uco-observable:File ;
uco-core:hasFacet kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d ;
uco-core:hasFacet kb:FileFacet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d ;
.

kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d
kb:FileFacet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d
a uco-observable:FileFacet ;
uco-observable:fileName "sample.txt" ;
uco-observable:modifiedTime "2010-01-02T03:04:56+00:00"^^xsd:dateTime ;
Expand Down
Loading