Skip to content

Commit

Permalink
Update testing to review current CASE Examples repository; remove out…
Browse files Browse the repository at this point in the history
…-of-date submodules

No effects were observed on Make-managed files.

Signed-off-by: Alex Nelson <[email protected]>
  • Loading branch information
ajnelson-nist committed Jun 27, 2024
1 parent 4c86247 commit 4c9400d
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 44 deletions.
10 changes: 4 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion case_to_dfxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
1 change: 1 addition & 0 deletions deps/CASE-Examples
Submodule CASE-Examples added at ff586c
1 change: 0 additions & 1 deletion deps/case
Submodule case deleted from c469f0
1 change: 0 additions & 1 deletion deps/case-api-python
Submodule case-api-python deleted from a2d9f5
4 changes: 0 additions & 4 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand Down
116 changes: 89 additions & 27 deletions tests/case_examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down
62 changes: 62 additions & 0 deletions tests/case_examples/example.mk
Original file line number Diff line number Diff line change
@@ -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 _$@ $@
8 changes: 4 additions & 4 deletions tests/empty_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down

0 comments on commit 4c9400d

Please sign in to comment.