Skip to content

Commit

Permalink
fix: filtering option filter_db_results
Browse files Browse the repository at this point in the history
  • Loading branch information
lxndrblz authored Jul 7, 2024
1 parent ab2ce6d commit bd7e926
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/forensicsim/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
def parse_db(
filepath: Path,
blobpath: Optional[Path] = None,
do_not_filter: Optional[bool] = False,
filter_db_results: Optional[bool] = True,
) -> list[dict[str, Any]]:
# Open raw access to a LevelDB and deserialize the records.

Expand All @@ -59,7 +59,7 @@ def parse_db(
# Skip empty object stores
if obj_store_name is None:
continue
if obj_store_name in TEAMS_DB_OBJECT_STORES or do_not_filter is False:
if obj_store_name in TEAMS_DB_OBJECT_STORES or filter_db_results is False:
obj_store = db[obj_store_name]
records_per_object_store = 0
for record in obj_store.iterate_records():
Expand Down
4 changes: 2 additions & 2 deletions src/forensicsim/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,14 @@ def process_db(
input_path: Path,
output_path: Path,
blob_path: Optional[Path] = None,
do_not_filter: Optional[bool] = True,
filter_db_results: Optional[bool] = True,
) -> None:
if not input_path.parts[-1].endswith(".leveldb"):
raise ValueError(f"Expected a leveldb folder. Path: {input_path}")

if blob_path is not None and not blob_path.parts[-1].endswith(".blob"):
raise ValueError(f"Expected a .blob folder. Path: {blob_path}")

extracted_values = parse_db(input_path, blob_path, do_not_filter)
extracted_values = parse_db(input_path, blob_path, filter_db_results)
parsed_records = parse_records(extracted_values)
write_results_to_json(parsed_records, output_path)
2 changes: 1 addition & 1 deletion tools/dump_leveldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def process_level_db(
input_path: Path, output_path: Path, blob_path: Optional[Path] = None
) -> None:
# convert the database to a python list with nested dictionaries
extracted_values = parse_db(input_path, blob_path, do_not_filter=False)
extracted_values = parse_db(input_path, blob_path, filter_db_results=False)

# write the output to a json file
write_results_to_json(extracted_values, output_path)
Expand Down
2 changes: 1 addition & 1 deletion tools/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
)
def process_cmd(filepath: Path, outputpath: Path, blobpath: Path) -> None:
click.echo(XTRACT_HEADER)
process_db(filepath, outputpath, blobpath, True)
process_db(filepath, outputpath, blobpath, filter_db_results=True)


if __name__ == "__main__":
Expand Down

0 comments on commit bd7e926

Please sign in to comment.