UI API client
Access this client through sandbox.ui after configuring SandboxKey.UI and
calling await sandbox.ui.authorize(). The UI client is created when first used.
ptsandbox.sandbox.ui.SandboxUI
Bases: SystemMixin, EntryPointsMixin, TasksMixin, ArtifactsMixin, TokensMixin
Using raw queries to sandbox UI API
authorize
async
Authorization in the UI using the passed parameters in the key
Raises:
-
SandboxException–if the authorization location cannot be retrieved or login fails
-
ClientResponseError–if the server returns an error status during login
-
ClientError–on connection or transport errors
get_api_tokens
async
Get listing of current Public API tokens
Returns:
-
SandboxTokensResponse–A model with information about all tokens
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
create_api_token
async
create_api_token(name: str, permissions: list[TokenPermissions], comment: str = '') -> SandboxCreateTokenResponse
Create a new Public API token
Parameters:
-
name(str) –token name
-
permissions(list[TokenPermissions]) –permissions for the token
-
comment(str, default:'') –additional information about the token
Returns:
-
SandboxCreateTokenResponse–A model with information about the created token
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
delete_api_token
async
Delete the Public API token
Parameters:
-
token_id(int) –id of the PublicAPI token in the database
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
get_files
async
Download file via UI API
Parameters:
-
items(list[StorageItem]) –the list of files to download
Returns:
-
AsyncIterator[bytes]–ZIP archive with "infected" password
-
AsyncIterator[bytes]–Please note that if one of the hashes doesn't exist, and the others do,
-
AsyncIterator[bytes]–then the archive will be only with existing hashes.
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status (404 if none of the files are found)
-
ClientError–on connection or transport errors
get_artifacts_csv
async
get_artifacts_csv(query: str = '', columns: list[Literal['behavioralAnalysis', 'bwListStatus', 'createProcess', 'detects.avast', 'detects.clamav', 'detects.drweb', 'detects.eset', 'detects.kaspersky', 'detects.nano', 'detects.ptesc', 'detects.ptav', 'detects.vba', 'detects.yara', 'detects.yara.test', 'emlBcc', 'emlCC', 'emlFrom', 'emlTo', 'fileExtensionTypeGroup', 'fileLabels', 'fileMd5', 'fileName', 'fileSha1', 'fileSha256', 'fileSize', 'fileType', 'fromTo', 'imageDuration', 'imageName', 'mimeType', 'nodeType', 'priority', 'receivedFrom', 'ruleEngineDetects', 'ruleEngineVerdict', 'sandboxBehavioral', 'sandboxBootkitmon', 'sandboxDetects', 'sandboxVerdict', 'smtpFrom', 'smtpTo', 'source', 'ssdeep', 'status', 'subject', 'taskId', 'time', 'verdict', 'verdict.avast', 'verdict.clamav', 'verdict.drweb', 'verdict.eset', 'verdict.kaspersky', 'verdict.nano', 'verdict.ptesc', 'verdict.ptav', 'verdict.vba', 'verdict.yara', 'verdict.yara.test', 'verdictPriority', 'verdictReason']] | None = None, utc_offset_seconds: int = 0) -> AsyncIterator[bytes]
Export an artifacts listing to CSV
Parameters:
-
query(str, default:'') –filtering using the query language. For the syntax, see the user documentation.
-
columns(list[Literal['behavioralAnalysis', 'bwListStatus', 'createProcess', 'detects.avast', 'detects.clamav', 'detects.drweb', 'detects.eset', 'detects.kaspersky', 'detects.nano', 'detects.ptesc', 'detects.ptav', 'detects.vba', 'detects.yara', 'detects.yara.test', 'emlBcc', 'emlCC', 'emlFrom', 'emlTo', 'fileExtensionTypeGroup', 'fileLabels', 'fileMd5', 'fileName', 'fileSha1', 'fileSha256', 'fileSize', 'fileType', 'fromTo', 'imageDuration', 'imageName', 'mimeType', 'nodeType', 'priority', 'receivedFrom', 'ruleEngineDetects', 'ruleEngineVerdict', 'sandboxBehavioral', 'sandboxBootkitmon', 'sandboxDetects', 'sandboxVerdict', 'smtpFrom', 'smtpTo', 'source', 'ssdeep', 'status', 'subject', 'taskId', 'time', 'verdict', 'verdict.avast', 'verdict.clamav', 'verdict.drweb', 'verdict.eset', 'verdict.kaspersky', 'verdict.nano', 'verdict.ptesc', 'verdict.ptav', 'verdict.vba', 'verdict.yara', 'verdict.yara.test', 'verdictPriority', 'verdictReason']] | None, default:None) –the list of csv columns to be exported.
-
utc_offset_seconds(int, default:0) –the offset of the user's time from UTC, which will be used for the time in QL queries
Returns:
-
AsyncIterator[bytes]–AsyncIterator with chunks of CSV file
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
get_artifacts_filter_values
async
get_artifacts_filter_values(from_: str = '', to: str = '', scan_id: UUID | None = None) -> SandboxArtifactsFilterValuesResponse
Get possible values for filters based on sources and validation results
Parameters:
-
from_(str, default:'') –for which period possible values are being searched: minimum time
-
to(str, default:'') –for which period possible values are being searched: maximum time
-
scan_id(UUID | None, default:None) –filter by task ID
Returns:
-
SandboxArtifactsFilterValuesResponse–Possible filter values
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_task_tree
async
get_task_tree(scan_id: UUID, *, parent_path: list[int] | None = None, filtered_by_ids: list[int] | None = None, limit: int = 1000, offset: int = 0, max_tree_level: int = 3, sort_mode: Literal['DANGEROUS', 'ALPHABETICAL'] = 'DANGEROUS') -> SandboxTreeResponse
Get a tree of artifacts for a specific task
Parameters:
-
scan_id(UUID) –...
-
parent_path(list[int] | None, default:None) –the full path to the parent to start loading the tree from. For example: [0, 2, 10]
-
filtered_by_ids(list[int] | None, default:None) –a list of IDs of specific nodes to be returned, for example: [0, 2, 10, 11]
-
limit(int, default:1000) –limit on the number of records to be returned
-
offset(int, default:0) –the indentation from which the records are returned, used for pagination
-
max_tree_level(int, default:3) –the maximum depth (relative to the parent) to be returned
-
sort_mode(Literal['DANGEROUS', 'ALPHABETICAL'], default:'DANGEROUS') –the sorting method. First, the dangerous ones are 'DANGEROUS' or just alphabetically 'ALPHABETIC'
Returns:
-
SandboxTreeResponse–The Artifact Tree
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_task_artifacts
async
get_task_artifacts(scan_id: UUID, *, query: str = '', include_sandbox_logs: Literal['true', 'false'] = 'true', skip_data_files: Literal['true', 'false'] = 'false') -> AsyncIterator[bytes]
Download all the artifacts of the task
Parameters:
-
scan_id(UUID) –...
-
query(str, default:'') –filtering using the query language. For the syntax, see the user documentation.
-
include_sandbox_logs(Literal['true', 'false'], default:'true') –whether to include BA logs as a result
-
skip_data_files(Literal['true', 'false'], default:'false') –whether to include data files in the result
Returns:
-
AsyncIterator[bytes]–Sandbox returns an encrypted zip archive (password - infected), so we just export a set of bytes.
-
AsyncIterator[bytes]–If necessary, you can use pyzipper to unpack
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
get_task_artifact_scans
async
Getting scan results for a specific artifact
Parameters:
-
scan_id(UUID) –...
-
node_id(int) –...
Returns:
-
SandboxScansResponse–The model with the scan results
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_tasks
async
get_tasks(query: str = '', limit: int = 20, offset: int = 0, utc_offset_seconds: int = 0, next_cursor: str | None = None) -> SandboxUITasksResponse
Get tasks listing
Parameters:
-
query(str, default:'') – -
limit(int, default:20) –limit on the number of records to be returned
-
offset(int, default:0) –the offset of the returned records. If the next cursor is specified, the offset is counted from the cursor.
-
utc_offset_seconds(int, default:0) –the offset of the user's time from UTC, which will be used for the time in QL queries
-
next_cursor(str | None, default:None) –the value from the previous request
Returns:
-
SandboxUITasksResponse–Information about requested tasks
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_tasks_csv
async
get_tasks_csv(query: str = '', columns: list[Literal['action', 'behavioralAnalysis', 'fromTo', 'priority', 'processedTime', 'quarantine', 'source', 'status', 'taskName', 'time', 'verdict', 'verdictTime']] | None = None, utc_offset_seconds: int = 0) -> AsyncIterator[bytes]
Export a tasks listing to CSV
Parameters:
-
query(str, default:'') –filtering using the query language. For the syntax, see the user documentation.
-
columns(list[Literal['action', 'behavioralAnalysis', 'fromTo', 'priority', 'processedTime', 'quarantine', 'source', 'status', 'taskName', 'time', 'verdict', 'verdictTime']] | None, default:None) –the list of csv columns to be exported.
-
utc_offset_seconds(int, default:0) –the offset of the user's time from UTC, which will be used for the time in QL queries
Returns:
-
AsyncIterator[bytes]–AsyncIterator with chunks of CSV file
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
get_tasks_filter_values
async
get_tasks_filter_values(from_: str = '', to: str = '', scan_id: UUID | None = None) -> SandboxTasksFilterValuesResponse
Get possible values for filters based on sources and validation results
Parameters:
-
from_(str, default:'') –for which period possible values are being searched: minimum time
-
to(str, default:'') –for which period possible values are being searched: maximum time
-
scan_id(UUID | None, default:None) –filter by task ID
Returns:
-
SandboxTasksFilterValuesResponse–Possible filter values
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_task_summary
async
Get information about a specific task
Parameters:
-
scan_id(UUID) –task id
Returns:
-
SandboxTasksSummaryResponse–Full information about a specific task
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_baqueue_tasks
async
get_baqueue_tasks(query: str = 'age < 7d AND state IN (CREATED, STARTING, STARTED, DEDUPLICATION, READY, READY_WITH_ERROR) ORDER BY state DESC, priority.value DESC, ts.created', limit: int = 50, offset: int = 0, utc_offset_seconds: int = 0) -> SandboxBaqueueTasksResponse
Listing of tasks in the Behavioral Analysis queue
Parameters:
-
query(str, default:'age < 7d AND state IN (CREATED, STARTING, STARTED, DEDUPLICATION, READY, READY_WITH_ERROR) ORDER BY state DESC, priority.value DESC, ts.created') –QL search query (by default, all tasks that are currently running are requested)
-
limit(int, default:50) –limit on the number of records to be returned
-
offset(int, default:0) –offset of returned records
-
utc_offset_seconds(int, default:0) –the offset of the user's time from UTC, which will be used for the time in QL queries
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_entry_points_types
async
Get a list of possible sources to check with their parameters
Returns:
-
SandboxEntryPointsTypesResponse–List of possible sources
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_entry_points
async
Get a list of added sources for analysis
Returns:
-
SandboxEntryPointsResponse–EntryPoints model
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
create_entry_point
async
Add a new analysis source
Parameters:
-
parameters(SandboxCreateEntryPointRequest) –Parameters for the request
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
get_entry_point
async
Get information about the analysis source
Parameters:
-
entry_point_id(str) –ID of entry point
Returns:
-
SandboxEntryPointResponse–EntryPoint model
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
delete_entry_point
async
Delete the analysis source
Parameters:
-
entry_point_id(str) –ID of entry point
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
get_entry_point_tasks
async
get_entry_point_tasks(entry_point_id: str, query: str = '', limit: int = 20, offset: int = 0, utc_offset_seconds: int = 0, next_cursor: str | None = None) -> SandboxUITasksResponse
Listing tasks from the source
Parameters:
-
entry_point_id(str) –ID of entry point
-
query(str, default:'') – -
limit(int, default:20) –Limit on the number of records to be returned
-
offset(int, default:0) –The offset of the returned records. If the next cursor is specified, the offset is counted from the cursor.
-
utc_offset_seconds(int, default:0) –The offset of the user's time from UTC, which will be used for the time in QL queries
Returns:
-
SandboxUITasksResponse–Information about requested tasks
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_entry_point_logs
async
Download logs of a specific source
Parameters:
-
entry_point_id(str) –ID of entry point
Returns:
-
AsyncIterator[bytes]–Archive with logs
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
get_system_status
async
Get information about the system status
For full information, look at the documentation of the SandboxSystemStatusResponse model.
Returns:
-
SandboxSystemStatusResponse–A model with information about the system
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_system_settings
async
Get information about the system settings
Returns:
-
SandboxSystemSettingsResponse–A model with system settings
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
update_system_settings
async
Update system settings
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
get_system_version
async
Get the version of the installed product
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_system_logs
async
get_system_logs(since: int | None = None, components: list[str] | None = None) -> AsyncIterator[bytes]
Download the archive with system logs
Parameters:
-
since(int | None, default:None) –the time period for uploading logs in seconds
-
components(list[str] | None, default:None) –component names in the format
{namespace}/{component},{namespace}/{component}, ... If the field is empty, all components will be downloaded
Returns:
-
AsyncIterator[bytes]–Archive with logs
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
get_system_cluster_status
async
Get information about the cluster status
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_system_components_status
async
Get information about the components status
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_license
async
Get the license status and details
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
update_license
async
Updating the current license
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_av_engines
async
Get information about antivirus scanners
Returns:
-
SandboxAVEnginesResponse–A model with information about all antiviruses
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_av_engine
async
Get settings of a specific antivirus engine.
Parameters:
-
item_id(str) –antivirus identifier (engine code name, e.g.
"clamav")
Returns:
-
SandboxAVEngineSettingsResponse–A model with the antivirus settings
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_av_distribution_packs
async
Get the list of antivirus distributions available for installation.
Returns:
-
SandboxAVDistributionPacksResponse–A model with the distribution packs
Raises:
-
SandboxException–if not authorized or token refresh fails
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model