Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

rest api - get report #3190

Open
jnow677 opened this issue Mar 24, 2021 · 4 comments
Open

rest api - get report #3190

jnow677 opened this issue Mar 24, 2021 · 4 comments

Comments

@jnow677
Copy link

jnow677 commented Mar 24, 2021

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
Copy link
Author

jnow677 commented Mar 25, 2021

thanks in advance

@vinceplayer
Copy link

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
Copy link
Author

jnow677 commented Mar 25, 2021

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
Copy link
Author

jnow677 commented Mar 25, 2021

I found these endpoints
`@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>")

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()`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants