Retrieve the data of a scan
(taskid)
| 578 | |
| 579 | @get("/scan/<taskid>/data") |
| 580 | def scan_data(taskid): |
| 581 | """ |
| 582 | Retrieve the data of a scan |
| 583 | """ |
| 584 | |
| 585 | json_data_message = list() |
| 586 | json_errors_message = list() |
| 587 | |
| 588 | if taskid not in DataStore.tasks: |
| 589 | logger.warning("[%s] Invalid task ID provided to scan_data()" % taskid) |
| 590 | return jsonize({"success": False, "message": "Invalid task ID"}) |
| 591 | |
| 592 | # Read all data from the IPC database for the taskid |
| 593 | for status, content_type, value in DataStore.current_db.execute("SELECT status, content_type, value FROM data WHERE taskid = ? ORDER BY id ASC", (taskid,)): |
| 594 | json_data_message.append({"status": status, "type": content_type, "value": dejsonize(value)}) |
| 595 | |
| 596 | # Read all error messages from the IPC database |
| 597 | for error in DataStore.current_db.execute("SELECT error FROM errors WHERE taskid = ? ORDER BY id ASC", (taskid,)): |
| 598 | json_errors_message.append(error) |
| 599 | |
| 600 | logger.debug("(%s) Retrieved scan data and error messages" % taskid) |
| 601 | return jsonize({"success": True, "data": json_data_message, "error": json_errors_message}) |
| 602 | |
| 603 | # Functions to handle scans' logs |
| 604 | @get("/scan/<taskid>/log/<start>/<end>") |