From a13404732846c00d5218422273c596888e53b354 Mon Sep 17 00:00:00 2001 From: Syed Farhan Ahmed Date: Fri, 17 Jul 2026 19:46:11 +0500 Subject: [PATCH] Fix always-empty timestamp in IOC extraction report generate_ioc_report()'s "generated" field used: datetime.utcnow().isoformat() if "datetime" in dir() else "" "datetime" is never imported anywhere in this file, and dir() with no arguments only inspects local scope names -- so this guard is always False, and every generated report had "generated": "" instead of a real timestamp. Fixed by importing datetime/timezone at the top and calling datetime.now(timezone.utc).isoformat() directly (the non-deprecated replacement for utcnow(), since Python 3.12 deprecates utcnow()). Tested: python3 -m py_compile, --help works, and: python3 agent.py report --file now produces a real ISO 8601 UTC timestamp (e.g. "2026-07-17T14:46:03.178652+00:00") instead of an empty string. --- skills/performing-malware-ioc-extraction/scripts/agent.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skills/performing-malware-ioc-extraction/scripts/agent.py b/skills/performing-malware-ioc-extraction/scripts/agent.py index 4bc53e86..9fcaee07 100644 --- a/skills/performing-malware-ioc-extraction/scripts/agent.py +++ b/skills/performing-malware-ioc-extraction/scripts/agent.py @@ -5,6 +5,7 @@ import json import argparse import re import hashlib +from datetime import datetime, timezone from pathlib import Path @@ -102,7 +103,7 @@ def generate_ioc_report(file_path, output=None): hashes = hash_file(file_path) strings = extract_strings(file_path) report = { - "generated": datetime.utcnow().isoformat() if "datetime" in dir() else "", + "generated": datetime.now(timezone.utc).isoformat(), "file_info": hashes, "strings_analysis": { "total": strings["total_strings"],