Skip to content
9 changes: 5 additions & 4 deletions Server/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ def __init__(self, evidence_path):
self.report_data = {}

def run_automated_process(self):
print("Starting Identification...")
sha256 = self.generate_hash("sha256")
md5 = self.generate_hash("md5")

print("Verifying Magic Numbers...")
magic_verified, file_sig = self.verify_file_signature()

print("Collecting Advanced Metadata...")
metadata = self.get_metadata()
metadata["magic_signature"] = file_sig
metadata["signature_match"] = magic_verified
Expand Down Expand Up @@ -47,6 +44,9 @@ def verify_file_signature(self):
b"%PDF": "PDF Document",
b"PK\x03\x04": "ZIP/Office Archive",
b"MZ": "Executable (Warning)",
b"\xd4\xc3\xb2\xa1": "PCAP Network Capture (Little Endian)",
b"\xa1\xb2\xc3\xd4": "PCAP Network Capture (Big Endian)",
b"\x0a\x0d\x0d\x0a": "PCAPNG Network Capture",
}
try:
with open(self.evidence_path, "rb") as f:
Expand All @@ -65,5 +65,6 @@ def get_metadata(self):
"created": datetime.datetime.fromtimestamp(stats.st_ctime, tz=datetime.timezone.utc).isoformat(),
"modified": datetime.datetime.fromtimestamp(stats.st_mtime, tz=datetime.timezone.utc).isoformat(),
"accessed": datetime.datetime.fromtimestamp(stats.st_atime, tz=datetime.timezone.utc).isoformat(),
"permissions": oct(stats.st_mode)[-3:]
"permissions": oct(stats.st_mode)[-3:],
"exif": {}
}
3 changes: 2 additions & 1 deletion Server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
allow_credentials=True,
)


Expand Down Expand Up @@ -180,6 +179,8 @@ async def run_forensic_pipeline(
except Exception as e:
logger.warning(f"Failed to record upload provenance to Supabase: {e}")

write_audit(f"user={current_user['id']} action=analyze file={file.filename} hash={report['hash_sha256']}")

return {
"id": case_id,
"filename": file.filename,
Expand Down
5 changes: 4 additions & 1 deletion Server/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def test_investigator_upload_and_audit(tmp_path):

client = TestClient(app)
files = {"file": ("small.txt", "hello world")}
headers = {"Authorization": "Bearer testtoken123"}
headers = {
"Authorization": "Bearer testtoken123",
"X-Analyze-Key": "forensic-pro-suite-demo-analyze-key"
}
r = client.post("/api/analyze", files=files, headers=headers)
assert r.status_code == 200
data = r.json()
Expand Down
Loading