def test_targetinfo_empty(self): ti = TargetInfo() ti.file_path = "file404" ti.set_task({ "category": "file", "target": "file404", }) obj = ti.run() assert obj["category"] == "file" assert obj["file"] == { "name": "file404", "path": None, "yara": [], } ti = TargetInfo() ti.file_path = "file404" ti.set_task({ "category": "archive", "target": "file404", "options": { "filename": "files/pdf0.pdf", }, }) obj = ti.run() assert obj["category"] == "archive" assert obj["filename"] == "files/pdf0.pdf" assert obj["human"] == "files/pdf0.pdf @ file404" assert obj["archive"] == { "name": "file404", } assert obj["file"] == { "name": "pdf0.pdf", }
def test_targetinfo(self): ti = TargetInfo() ti.file_path = __file__ ti.set_task({ "category": "file", "target": __file__, }) obj = ti.run() assert obj["category"] == "file" assert os.path.basename(obj["file"]["name"]) == "test_processing.py" ti = TargetInfo() ti.file_path = "tests/files/pdf0.zip" ti.set_task({ "category": "archive", "target": "tests/files/pdf0.zip", "options": { "filename": "files/pdf0.pdf", }, }) obj = ti.run() assert obj["category"] == "archive" assert os.path.basename(obj["archive"]["name"]) == "pdf0.zip" assert obj["filename"] == "files/pdf0.pdf" assert obj["human"] == "files/pdf0.pdf @ pdf0.zip" assert obj["file"]["name"] == "pdf0.pdf" assert obj["file"]["size"] == 680 ti = TargetInfo() ti.file_path = __file__ ti.set_task({ "category": "url", "target": "http://google.com", }) assert ti.run() == { "category": "url", "url": "http://google.com", }