Frontend API Reference
restapi
Public REST API for SightHouse clients
Classes:
-
FrontendRestAPI–REST API server for SightHouse public API
Functions:
-
get_current_user–Wrapper function so mypy stop yelling at me
FrontendRestAPI
FrontendRestAPI(database: FrontendDatabase, celery_url: str, ghidra_dir: Path, bsims: Optional[List[str]], fidbs: Optional[List[str]], logger: Logger, host: str = '0.0.0.0', port: int = 6671)
Bases: ServerThread
REST API server for SightHouse public API
Parameters:
-
(appFlask) –The Flask application instance that this server will host.
-
(hoststr) –The host address (e.g., '127.0.0.1' or '0.0.0.0') on which the server will listen for incoming requests.
-
(portint) –The port number (typically between 1024 and 65535) on which the server will accept connections.
Methods:
-
is_program_under_analysis–Return whether the given program is under analysis or not
-
run–Starts the HTTP server, listening for incoming requests
-
shutdown–Shuts down the running server gracefully.
Source code in venv/lib/python3.12/site-packages/sighthouse/frontend/restapi.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
is_program_under_analysis
is_program_under_analysis(program_id: int) -> bool
Return whether the given program is under analysis or not
Parameters:
-
(program_idint) –The ID of the program
Returns:
-
bool(bool) –True if the program is currently being analyzed, False otherwise
Source code in venv/lib/python3.12/site-packages/sighthouse/frontend/restapi.py
1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 | |
run
run() -> None
Starts the HTTP server, listening for incoming requests and serving the Flask application.
Source code in venv/lib/python3.12/site-packages/sighthouse/core/utils/api.py
37 38 39 40 | |
shutdown
shutdown() -> None
Shuts down the running server gracefully.
Source code in venv/lib/python3.12/site-packages/sighthouse/core/utils/api.py
42 43 44 | |
get_current_user
get_current_user() -> User
Wrapper function so mypy stop yelling at me
Source code in venv/lib/python3.12/site-packages/sighthouse/frontend/restapi.py
46 47 48 49 | |
Public REST API
Here is the documentation for the REST API of the frontend.
Health check endpoint
Responses
| Code | Description |
|---|---|
| 200 | successful operation {
"success": "Pong !"
} |
Login endpoint
Parameters
| Name | Type | Description |
|---|---|---|
| user | str | The username for the login |
| password | str | The password for the login |
Responses
| Code | Description |
|---|---|
| 200 | Successful operation {
"success": "Login successful"
} |
| 400 | Invalid user/password value {
"error": "Missing user or password"
} |
| 401 | Invalid credentials {
"error": "Invalid credentials"
} |
Logout endpoint
Responses
| Code | Description |
|---|---|
| 200 | Successful operation {
"success": "Login successful"
} |
List languages supported by the analyzer
Responses
| Code | Description |
|---|---|
| 200 | Successful operation {
"languages": ["ARM", ...]
} |
Endpoint for upload files into the server
Parameters
| Name | Type | Description |
|---|---|---|
| filename | str, bytes | Multipart encoded file to upload |
Responses
| Code | Description |
|---|---|
| 200 | Successful operation {
"success": "File uploaded",
"file: 1234
} |
| 400 | Invalid parameters {
"error": "Missing 'filename' field in upload data"
} |
| 500 | Internal server error {
"error": "Fail to add file to database"
} |
List the files uploaded on the server
Responses
| Code | Description |
|---|---|
| 200 | Successful operation {
"files: [{
"id": 1234,
"name": "ls.bin",
"user": 5678,
"hash": "9fed8..."
}, {...}]
} |
Endpoint for deleting files from the upload server
Parameters
| Name | Type | Description |
|---|---|---|
| hash | str | hash of the file to delete |
Responses
| Code | Description |
|---|---|
| 200 | Successful operation {
"success": "File deleted"
} |
| 404 | Invalid parameters {
"error": "The given file does not exists"
} |
| 500 | Internal server error {
"error": "Fail to delete file from database"
} |
Endpoint for creating new programs in the system.
Parameters
| Name | Type | Description |
|---|---|---|
| programs | list[program] | A list of JSON program to create |
Responses
| Code | Description |
|---|---|
| 201 | Successful operation {
"programs": [<list of created program>]
} |
| 400 | Bad request for missing or invalid parameters {
"error": "Invalid program data in program list"
} |
Endpoint for retrieving all programs associated with the current user.
Responses
| Code | Description |
|---|---|
| 200 | Successfully retrieved user programs {
"programs": [{"id": 1234, "name": "ls.bin", ...}, {...}]
} |
Endpoint for retrieving a specific program by its ID.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the requested program |
| recursive | str | A string corresponding to a boolean (either 'true' or 'false') that tell the server to return the program sub elements such as functions. |
Responses
| Code | Description |
|---|---|
| 200 | Successfully retrieved the program {
"id": 1234,
"name": "ls.bin",
"user": 4567,
"language": "x86_64",
"file": 2468,
} |
| 404 | Program not found {
"error": "Program not found"
} |
Endpoint for deleting a specific program by its ID.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program to delete |
Responses
| Code | Description |
|---|---|
| 200 | Successful operation {
"success": "Program deleted"
} |
| 403 | Forbidden if the program is under analysis {
"error": "Cannot modify program while it is being analyzed"
} |
| 404 | Program not found {
"error": "Program not found"
} |
| 500 | Internal server error if deletion fails {
"error": "Fail to delete program"
} |
Endpoint for retrieving the analysis data of a specific program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program to analyze |
Responses
| Code | Description |
|---|---|
| 200 | Successfully retrieved analysis data {
"analysis": {
"program": 1234,
"user": 5678,
"info": <analysis data>
}
} |
| 404 | No analysis found for the program {
"error": "No analysis found"
} |
Endpoint for initiating the analysis of a specific program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program to analyze. |
Responses
| Code | Description |
|---|---|
| 200 | Analysis is successfully initiated {
"message": "We are currently analyzing your program"
} |
| 404 | The specified program does not exist {
"error": "Program not found"
} |
| 500 | Internal server error when analysis is not finished {
"error": "Analyzed not finished"
} |
Endpoint for creating sections within a specific program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program to which sections are being added. |
Responses
| Code | Description |
|---|---|
| 201 | Successfully created sections {
"sections": [<list of created section data>]
} |
| 400 | Bad request for missing or invalid parameters {
"error": "Invalid section data in section list"
} |
| 403 | Forbidden if the program is currently under analysis {
"error": "Cannot modify program while it is being analyzed"
} |
| 404 | Program not found {
"error": "Program not found"
} |
Endpoint for retrieving all sections associated with a specific program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program whose sections are to be retrieved. |
Responses
| Code | Description |
|---|---|
| 200 | Successfully retrieved sections {
"sections": [<list of sections data>]
} |
| 404 | Program not found {
"error": "Program not found"
} |
Endpoint for retrieving a specific section by its ID within a program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program the section belongs to. |
| section_id | int | ID of the section to retrieve. |
Responses
| Code | Description |
|---|---|
| 200 | Successfully retrieved the section ``` |
| 404 | Program or section not found {
"error": "Section not found"
} |
Endpoint for deleting a specific section from a program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program the section belongs to. |
| section_id | int | ID of the section to delete. |
Responses
| Code | Description |
|---|---|
| 200 | Successfully deleted the section {
"success": "Section deleted"
} |
| 403 | Forbidden if the program is currently under analysis {
"error": "Cannot modify program while it is being analyzed"
} |
| 404 | Program or section not found {
"error": "Section not found"
} |
Endpoint for deleting all sections associated with a specific program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program whose sections are to be deleted. |
Responses
| Code | Description |
|---|---|
| 200 | Successfully deleted all sections {
"success": "All sections deleted"
} |
| 403 | Forbidden if the program is currently under analysis {
"error": "Cannot modify program while it is being analyzed"
} |
| 404 | Program not found {
"error": "Program not found"
} |
Endpoint for creating functions within a specific section of a program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program containing the section. |
| section_id | int | ID of the section where functions are being added. |
Responses
| Code | Description |
|---|---|
| 201 | Successfully created functions {
"functions": [<list of created function data>]
} |
| 400 | Bad request for missing or invalid parameters {
"error": "Invalid function data in list"
} |
| 403 | Forbidden if the program is currently under analysis {
"error": "Cannot modify program while it is being analyzed"
} |
| 404 | Program or section not found {
"error": "Program not found"
} |
Endpoint for retrieving all functions within a specific section of a program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program containing the section. |
| section_id | int | ID of the section whose functions are to be retrieved. |
Responses
| Code | Description |
|---|---|
| 200 | Successfully retrieved functions {
"functions": [<list of function data>]
} |
| 404 | Program or section not found {
"error": "Program not found"
} |
Endpoint for retrieving a specific function by its ID within a section of a program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program containing the section. |
| section_id | int | ID of the section where the function resides. |
| function_id | int | ID of the function to retrieve. |
Responses
| Code | Description |
|---|---|
| 200 | Successfully retrieved the function <function data> |
| 404 | Program, section, or function not found {
"error": "Function not found"
} |
Endpoint for deleting a specific function from a section of a program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program containing the section. |
| section_id | int | ID of the section where the function resides. |
| function_id | int | ID of the function to delete. |
Responses
| Code | Description |
|---|---|
| 200 | Successfully deleted the function {
"success": "Function deleted"
} |
| 403 | Forbidden if the program is currently under analysis {
"error": "Cannot modify program while it is being analyzed"
} |
| 404 | Program, section, or function not found {
"error": "Function not found"
} |
Endpoint for retrieving all matches related to a specific function within a section of a program.
Parameters
| Name | Type | Description |
|---|---|---|
| program_id | int | ID of the program containing the section. |
| section_id | int | ID of the section where the function resides. |
| function_id | int | ID of the function whose matches are to be retrieved. |
Responses
| Code | Description |
|---|---|
| 200 | Successfully retrieved function matches {
"matches": [<list of match data>]
} |
| 404 | Program, section, or function not found {
"error": "Function not found"
} |