diff --git a/Makefile b/Makefile index 16bd8c4..111169a 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ SHELL := /bin/bash all: \ check-examples source venv/bin/activate \ - && python3 case_viewer/case_viewer.py \ + && case_viewer \ examples/WirelessNetworkConnection.json .PHONY: \ @@ -28,19 +28,23 @@ all: \ .dry_run.done.log: \ .pytest.done.log source venv/bin/activate \ - && python3 case_viewer/case_viewer.py \ + && case_viewer \ --dry-run \ examples/WirelessNetworkConnection.json touch $@ -.mypy.done.log: \ +.mypy_strict.done.log: \ .venv.done.log \ - case_viewer/case_viewer.py \ case_viewer/lib.py source venv/bin/activate \ && poetry run mypy \ --strict \ case_viewer/lib.py + touch $@ + +.mypy.done.log: \ + .mypy_strict.done.log \ + case_viewer/case_viewer.py source venv/bin/activate \ && poetry run mypy \ case_viewer/case_viewer.py diff --git a/README.md b/README.md index 8ec36b9..71c7808 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,11 @@ The application relies on Poetry as dependency manager, and all dependencies are ## Usage -> *CASEviewer.py JSON_INPUT* +> `case_viewer JSON_INPUT` where: -* JSON_INPUT is the file to be processed. +* `JSON_INPUT` is the file to be processed. For those with `make` available (e.g. in a POSIX command line environment), `make` will run enough from a fresh `git clone` to set up a demonstration call of the viewer against an [example JSON-LD file](examples/WirelessNetworkConnection.json). diff --git a/case_viewer/case_viewer.py b/case_viewer/case_viewer.py index 1f13aaf..20a5645 100644 --- a/case_viewer/case_viewer.py +++ b/case_viewer/case_viewer.py @@ -294,6 +294,7 @@ def buildDataCellSites(self, idObject): def buildDataWirelessNet(self, idObject: str) -> list[list[str]]: + global wireless_net tData = [] if idObject == ':WirelessNet': self.headers = ["SSID", "BSID"] @@ -1874,52 +1875,55 @@ def number_with_dots(n: Union[int, str]) -> str: else: raise TypeError('Parameter must be either integer or string') -if __name__ == '__main__': #--- Gobal variables +chatMessages: list[dict[str, str]] = [] +chatThreads: list[dict[str, str]] = [] +#chatMessageAttachments = [] +cookies: list[dict[str, str]] = [] +geo_coordinates: list[dict[str, str]] = [] +cell_sites: list[dict[str, str]] = [] +bluetooths: list[dict[str, str]] = [] +searched_items: list[dict[str, str]] = [] +social_media_activities: list[dict[str, str]] = [] +events: list[dict[str, str]] = [] +relationAttachmentsTo: list[dict[str, str]] = [] +relationMappedBy: list[dict[str, str]] = [] +relationConnectedTo: list[dict[str, str]] = [] +smsMessages: list[dict[str, str]] = [] +accounts: list[dict[str, str]] = [] +emailAddresses: list[dict[str, str]] = [] +emailAccounts: list[dict[str, str]] = [] +applications: list[dict[str, str]] = [] +phoneCalls: list[dict[str, str]] = [] +calendars: list[dict[str, str]] = [] +emailMessages: list[dict[str, str]] = [] +filesUncategorized: list[dict[str, str]] = [] +filesImage: list[dict[str, str]] = [] +filesAudio: list[dict[str, str]] = [] +filesText: list[dict[str, str]] = [] +filesPDF: list[dict[str, str]] = [] +filesWord: list[dict[str, str]] = [] +filesRTF: list[dict[str, str]] = [] +filesVideo: list[dict[str, str]] = [] +filesArchive: list[dict[str, str]] = [] +filesDatabase: list[dict[str, str]] = [] +filesApplication: list[dict[str, str]] = [] +webURLs: list[dict[str, str]] = [] +webURLHistory: list[dict[str, str]] = [] +webSearchTerm: list[dict[str, str]] = [] +webBookmark: list[dict[str, str]] = [] +wireless_net: list[dict[str, str]] = [] + +tableData: list[list[str]] = [[]] +treeData: list[dict[str,str]] = [] + +def main(): C_GREEN = '\033[32m' C_RED = '\033[31m' C_BLACK = '\033[0m' C_CYAN = '\033[36m' EMPTY_DATA = "1900-01-01T00:00:00" - chatThreads: list[dict[str, str]] = [] - chatMessages: list[dict[str, str]] = [] - #chatMessageAttachments = [] - cookies: list[dict[str, str]] = [] - geo_coordinates: list[dict[str, str]] = [] - cell_sites: list[dict[str, str]] = [] - bluetooths: list[dict[str, str]] = [] - searched_items: list[dict[str, str]] = [] - social_media_activities: list[dict[str, str]] = [] - events: list[dict[str, str]] = [] - wireless_net: list[dict[str, str]] = [] - relationAttachmentsTo: list[dict[str, str]] = [] - relationMappedBy: list[dict[str, str]] = [] - relationConnectedTo: list[dict[str, str]] = [] - smsMessages: list[dict[str, str]] = [] - accounts: list[dict[str, str]] = [] - emailAddresses: list[dict[str, str]] = [] - emailAccounts: list[dict[str, str]] = [] - applications: list[dict[str, str]] = [] - phoneCalls: list[dict[str, str]] = [] - calendars: list[dict[str, str]] = [] - emailMessages: list[dict[str, str]] = [] - filesUncategorized: list[dict[str, str]] = [] - filesImage: list[dict[str, str]] = [] - filesAudio: list[dict[str, str]] = [] - filesText: list[dict[str, str]] = [] - filesPDF: list[dict[str, str]] = [] - filesWord: list[dict[str, str]] = [] - filesRTF: list[dict[str, str]] = [] - filesVideo: list[dict[str, str]] = [] - filesArchive: list[dict[str, str]] = [] - filesDatabase: list[dict[str, str]] = [] - filesApplication: list[dict[str, str]] = [] - webURLs: list[dict[str, str]] = [] - webURLHistory: list[dict[str, str]] = [] - webSearchTerm: list[dict[str, str]] = [] - webBookmark: list[dict[str, str]] = [] - parser = argparse.ArgumentParser() parser.add_argument("--debug", action="store_true") parser.add_argument("--dry-run", action="store_true", help="Run application, exiting without initiating GUI.") @@ -1940,7 +1944,7 @@ def number_with_dots(n: Union[int, str]) -> str: json_obj = json.load(f) if args.dry_run: logging.info("Exiting dry run.") - sys.exit("Exit dry run.") + sys.exit(0) app = QApplication([]) _widget=QWidget() msgBox = QMessageBox() @@ -2057,8 +2061,6 @@ def number_with_dots(n: Union[int, str]) -> str: f.close() print(C_CYAN + "\n\nEnd Observables processing!" + C_BLACK + "\n\n") - tableData: list[list[str]] = [[]] - treeData: list[dict[str,str]] = [] i = 1 totMessages = 0 @@ -2227,3 +2229,7 @@ def number_with_dots(n: Union[int, str]) -> str: _view.setWindowTitle('Cyber items view - ' + args.input_jsonld + ' (n. Observables: ' + number_with_dots(nObjects) + ')') _view.show() sys.exit(app.exec_()) + + +if __name__ == '__main__': + main() diff --git a/pyproject.toml b/pyproject.toml index 73d1098..8cfce7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,9 @@ argparse = "^1.4.0" mypy = "^1" pytest = "^8" +[tool.poetry.scripts] +case_viewer = "case_viewer.case_viewer:main" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"