Flask Application¶
- File location
Bundled implementation:
source/server/python/daemon.py
Cluster implementation:
cluster/daemon/python/daemon.py
URL Routing¶
-
daemon.
list_
()¶ - Route
/api/v1.0/list
- Methods
GET
List of detection process information.
Information of running processes from
RUNNING
:
{ "id": "...", "initied": null, "scanned": true, "reported: null, "deleted": false }
Information of finished processes from
SCANNED
:If the process exited on success:
{ "id": "...", "initied": null, "scanned": true, "reported: true, "deleted": false }
If the process exited on failure:
{ "id": "...", "initied": null, "scanned": true, "reported: false, "deleted": false }
-
get_none
()¶ - Route
/api/v1.0/report
- Methods
GET
Display help message:
ID Required: /api/v1.0/report/<id>
-
get
(id_: str)¶ - Route
/api/v1.0/report/<id>
- Methods
GET
Fetch detection status of
id_
.If
id_
inRUNNING
:{ "id": "...", "initied": null, "scanned": false, "reported: null, "deleted": false }
If
id_
inSCANNED
:If the process exited on success:
{ "id": "...", "initied": null, "scanned": true, "reported: true, "deleted": false }
If the process exited on failure:
{ "id": "...", "initied": null, "scanned": true, "reported: false, "deleted": false }
If
id_
not found, raises404 Not Found
withid_not_found()
.
-
daemon.
scan
()¶ - Route
/api/v1.0/scan
- Methods
POST
Perform remote detection on target file.
The
POST
data should be a JSON object with following fields:- Parameters
name (string) – path to the extracted file
mime (string) – MIME type
uuid (string) – unique identifier
report (string | string[]) – report generation commands
shared (string) – shared detection API identifier
inited (boolean) – API initialised
workdir (string) – working directory
environ (object) – environment variables
install (string | string[]) – initialisation commands
scripts (string | string[]) – detection commands
If NO JSON data provided, raises
400 Bad Request
withinvalid_info()
.After performing detection
process.process()
on the target file, returns a JSON object containing detection report:If detection exits on success:
{ "id": "...", "initied": true, "scanned": true, "reported: true, "deleted": false }
If detection exists on failure:
If detection fails when initialising:
{ "id": "...", "initied": false, "scanned": true, "reported: false, "deleted": false }
If detection fails when processing:
{ "id": "...", "initied": true, "scanned": true, "reported: false, "deleted": false }
-
delete_none
()¶ - Route
/api/v1.0/delete
- Methods
DELETE
Display help message:
ID Required: /api/v1.0/delete/<id>
-
delete
(id_: str)¶ - Route
/api/v1.0/delete/<id>
- Methods
DELETE
Delete detection status of
id_
.If
id_
inRUNNING
:{ "id": "...", "initied": null, "scanned": false, "reported: null, "deleted": true }
If
id_
inSCANNED
:If the process exited on success:
{ "id": "...", "initied": null, "scanned": true, "reported: true, "deleted": true }
If the process exited on failure:
{ "id": "...", "initied": null, "scanned": true, "reported: false, "deleted": true }
If
id_
not found:{ "id": "...", "initied": null, "scanned": null, "reported: null, "deleted": true }
Error Handlers¶
-
daemon.
invalid_id
(error: Exception)¶ Handler of
ValueError
.{ "status": 400, "error": "...", "message": "invalid ID format" }
Dataclasses¶
-
class
daemon.
INFO
¶ A dataclass for requested detection API information.
-
inited
: manager.Value¶ Initied flag.
-
locked
: multiprocessing.Lock¶ Multiprocessing runtime lock.
-
Constants¶
-
daemon.
HELP_v1_0
: str¶ BroAPT Daemon APIv1.0 Usage: - GET /api/v1.0/list - GET /api/v1.0/report/<id> - POST /api/v1.0/scan data={"key": "value"} - DELETE /api/v1.0/delete/<id>
-
daemon.
__help__
: str¶ BroAPT Daemon API Usage: # v1.0 - GET /api/v1.0/list - GET /api/v1.0/report/<id> - POST /api/v1.0/scan data={"key": "value"} - DELETE /api/v1.0/delete/<id>
-
daemon.
manager
= multiprocessing.Manager()¶ Multiprocessing manager instanace.
-
daemon.
RUNNING
= manager.list()¶ - Type
List[uuid.UUID]
List of running detection processes.
-
daemon.
SCANNED
= manager.dict()¶ - Type
Dict[uuid.UUID, bool]
Record of finished detection processes and exit on success.
-
daemon.
APILOCK
= manager.dict()¶ - Type
Dict[str, multiprocessing.Lock]
Record of API multiprocessing locks.
-
daemon.
APIINIT
= manager.dict()¶ - Type
Dict[str, multiprocessing.Value]
Record of API initialised flags.