diff --git a/.gitmodules b/.gitmodules index 6551eca..e9e4677 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,7 @@ -[submodule "deps/case"] - path = deps/case - url = https://github.com/ajnelson-nist/case.git -[submodule "deps/case-api-python"] - path = deps/case-api-python - url = https://github.com/casework/case-api-python.git +[submodule "deps/CASE-Examples"] + path = deps/CASE-Examples + url = https://github.com/casework/CASE-Examples.git + branch = master [submodule "deps/case-implementation-plaso"] path = deps/case-implementation-plaso url = https://github.com/casework/case-implementation-plaso.git diff --git a/case_to_dfxml.py b/case_to_dfxml.py index aaae713..5c1cbf0 100644 --- a/case_to_dfxml.py +++ b/case_to_dfxml.py @@ -174,7 +174,7 @@ def _n_file_to_file_object(n_file: URIRef) -> Objects.FileObject: for filesystem_result in graph.query(filesystem_query): assert isinstance(filesystem_result, ResultRow) assert isinstance(filesystem_result[0], URIRef) - assert isinstance(filesystem_result[1], Literal) + assert filesystem_result[1] is None or isinstance(filesystem_result[1], Literal) n_file_system = filesystem_result[0] l_ftype_str = filesystem_result[1] diff --git a/deps/CASE-Examples b/deps/CASE-Examples new file mode 160000 index 0000000..ff586cf --- /dev/null +++ b/deps/CASE-Examples @@ -0,0 +1 @@ +Subproject commit ff586cfd54b5fe41efcc092c4de68f05e04ea996 diff --git a/deps/case b/deps/case deleted file mode 160000 index c469f02..0000000 --- a/deps/case +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c469f02055d1714c93bb5d5169e520bf16dafdbd diff --git a/deps/case-api-python b/deps/case-api-python deleted file mode 160000 index a2d9f5e..0000000 --- a/deps/case-api-python +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a2d9f5ea8f333d46c49dd62da7421531f91782a8 diff --git a/tests/Makefile b/tests/Makefile index ae5a447..8b15f9e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -59,7 +59,6 @@ all: .venv.done.log: \ $(dfxml_top_srcdir)/setup.cfg \ $(top_srcdir)/.git_submodule_init.done.log \ - $(top_srcdir)/deps/case-api-python/setup.py \ $(top_srcdir)/setup.cfg \ $(top_srcdir)/setup.py rm -rf venv @@ -71,9 +70,6 @@ all: pip \ setuptools \ wheel - source venv/bin/activate \ - && pip install \ - $(top_srcdir)/deps/case-api-python source venv/bin/activate \ && pip install \ --editable \ diff --git a/tests/case_examples/Makefile b/tests/case_examples/Makefile index 5b27584..81578ce 100644 --- a/tests/case_examples/Makefile +++ b/tests/case_examples/Makefile @@ -18,6 +18,7 @@ SHELL = /bin/bash top_srcdir := ../.. +#BOOKMARK^ dfxml_xsd := $(top_srcdir)/deps/dfxml_schema/dfxml.xsd dfxml_top_srcdir := $(top_srcdir)/deps/dfxml @@ -30,34 +31,93 @@ case_to_dfxml_dependencies := \ $(objects_py_dependencies) \ $(top_srcdir)/case_to_dfxml.py +#BOOKMARKv + all: -# Retain inferred .dfxml files. -# C/o: https://www.gnu.org/software/make/manual/html_node/Chained-Rules.html -.PRECIOUS: \ - %.dfxml - -%.dfxml: \ - ../../deps/case/examples/%.json \ - $(dfxml_xsd) \ - $(case_to_dfxml_dependencies) \ - ../.venv.done.log - rm -f __$@ _$@ - source ../venv/bin/activate \ - && python ../../case_to_dfxml.py \ - $< \ - __$@ - xmllint \ - --format \ - --schema $(dfxml_xsd) \ - __$@ \ - > _$@ - rm __$@ - mv _$@ $@ - -# NOTE: Some example files are purposefully omitted because they include design comments that Python's JSON library cannot parse. These files are: -# reconstructed_file.json -# sms_and_contacts.json +Oresteia.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/Oresteia/Oresteia.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +accounts.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/accounts/accounts.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +bulk_extractor_forensic_path.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/bulk_extractor_forensic_path/bulk_extractor_forensic_path.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +call_log.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/call_log/call_log.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +device.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/device/device.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +exif_data.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/exif_data/exif_data.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +file.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/file/file.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +forensic_lifecycle.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/forensic_lifecycle/forensic_lifecycle.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +location.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/location/location.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +message.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/message/message.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +multipart_file.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/multipart_file/multipart_file.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +raw_data.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/raw_data/raw_data.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +reconstructed_file.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/reconstructed_file/reconstructed_file.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk + +sms_and_contacts.dfxml: \ + ../../deps/CASE-Examples/examples/illustrations/sms_and_contacts/sms_and_contacts.json + $(MAKE) \ + subject_jsonld=$< \ + --file example.mk check: \ Oresteia.dfxml \ @@ -71,7 +131,9 @@ check: \ location.dfxml \ message.dfxml \ multipart_file.dfxml \ - raw_data.dfxml + raw_data.dfxml \ + reconstructed_file.dfxml \ + sms_and_contacts.dfxml clean: @rm -f \ diff --git a/tests/case_examples/example.mk b/tests/case_examples/example.mk new file mode 100644 index 0000000..2eb569e --- /dev/null +++ b/tests/case_examples/example.mk @@ -0,0 +1,62 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +SHELL = /bin/bash + +subject_jsonld ?= +ifeq ($(subject_jsonld),) +$(error subject_jsonld must be specified) +endif + +subject_dfxml := $(subst .json,.dfxml,$(shell basename $(subject_jsonld))) +ifeq ($(subject_dfxml),) +$(error subject_dfxml could not be computed from subject_jsonld=$(subject_jsonld)) +endif + +top_srcdir := ../.. + +dfxml_xsd := $(top_srcdir)/deps/dfxml_schema/dfxml.xsd + +dfxml_top_srcdir := $(top_srcdir)/deps/dfxml + +objects_py_dependencies := \ + $(dfxml_top_srcdir)/dfxml/__init__.py \ + $(dfxml_top_srcdir)/dfxml/objects.py + +case_to_dfxml_dependencies := \ + $(objects_py_dependencies) \ + $(top_srcdir)/case_to_dfxml.py + +all: \ + $(subject_dfxml) + +$(subject_dfxml): \ + $(subject_jsonld) \ + $(dfxml_xsd) \ + $(case_to_dfxml_dependencies) \ + ../.venv.done.log + rm -f __$@ _$@ + source ../venv/bin/activate \ + && python ../../case_to_dfxml.py \ + $< \ + __$@ + xmllint \ + --format \ + --schema $(dfxml_xsd) \ + __$@ \ + > _$@ + rm __$@ + mv _$@ $@ diff --git a/tests/empty_json.py b/tests/empty_json.py index ea3a1fb..e8aebec 100644 --- a/tests/empty_json.py +++ b/tests/empty_json.py @@ -14,15 +14,15 @@ # # We would appreciate acknowledgement if the software is used. -__version__ = "1.0.1" +__version__ = "1.1.0" -import case # type: ignore +from rdflib import Graph def main() -> None: - document = case.Document() + graph = Graph() - document.serialize(format="json-ld", destination=args.output_json) + graph.serialize(format="json-ld", destination=args.output_json) if __name__ == "__main__":