cuckoosandbox / cuckoo

Cuckoo Sandbox is an automated dynamic malware analysis system
http://www.cuckoosandbox.org
Other
5.52k stars 1.7k forks source link

rest api - get report #3190

Open jnow677 opened 3 years ago

jnow677 commented 3 years ago

Hello wonderful cuckoo team,

please is it possible to get a zip file containing the JSON report when using theses endpoint GET /tasks/report

because when dealing with a large report "bigger than 300 mega in the report" curl will be interrupted.

thanks

jnow677 commented 3 years ago

thanks in advance

vinceplayer commented 3 years ago

you edit source code of cuckoo/apps/api.py @app.route("/tasks/report/<int:task_id>") @app.route("/v1/tasks/report/<int:task_id>") @app.route("/tasks/report/<int:task_id>/<report_format>") @app.route("/v1/tasks/report/<int:task_id>/<report_format>") def tasks_report(task_id, report_format="json"):

jnow677 commented 3 years ago

thanks a lot , but I want to receive the analysis report as a JSON format but in zipped file when requesting this endpoint GET /tasks/report the report in JSON format may be 300 mega but if it is zipped it maybe just 2 mega

jnow677 commented 3 years ago

I found these endpoints `@app.route("/tasks/report/") @app.route("/v1/tasks/report/") @app.route("/tasks/report//") @app.route("/v1/tasks/report//")

but I still stuck in zipping the json report and adding new format as "zip" : "report.zip" def tasks_report(task_id, report_format="json"): formats = { "json": "report.json", "html": "report.html", }

bz_formats = {
    "all": {"type": "-", "files": ["memory.dmp"]},
    "dropped": {"type": "+", "files": ["files"]},
    "package_files": {"type": "+", "files": ["package_files"]},
}

tar_formats = {
    "bz2": "w:bz2",
    "gz": "w:gz",
    "tar": "w",
}

if report_format.lower() in formats:
    report_path = cwd(
        "storage", "analyses", "%d" % task_id, "reports",
        formats[report_format.lower()]
    )
elif report_format.lower() in bz_formats:
    bzf = bz_formats[report_format.lower()]
    srcdir = cwd("storage", "analyses", "%d" % task_id)
    s = io.BytesIO()`