Skip to content

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

authorize() -> None

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

close async

close() -> None

Close the underlying aiohttp session.

get_api_tokens async

get_api_tokens() -> SandboxTokensResponse

Get listing of current Public API tokens

Returns:

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:

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_api_token(token_id: int) -> None

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

get_files(items: list[StorageItem]) -> AsyncIterator[bytes]

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:

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:

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

get_task_artifact_scans(scan_id: UUID, node_id: int) -> SandboxScansResponse

Getting scan results for a specific artifact

Parameters:

  • scan_id (UUID) –

    ...

  • node_id (int) –

    ...

Returns:

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: '' ) –

    filtering using the query language. For the syntax, see the user documentation.

    age < 30d AND (task.correlated.state != UNKNOWN ) ORDER BY start desc
    
  • 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:

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:

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_task_summary(scan_id: UUID) -> SandboxTasksSummaryResponse

Get information about a specific task

Parameters:

  • scan_id (UUID) –

    task id

Returns:

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_entry_points_types() -> SandboxEntryPointsTypesResponse

Get a list of possible sources to check with their parameters

Returns:

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_entry_points() -> SandboxEntryPointsResponse

Get a list of added sources for analysis

Returns:

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

create_entry_point(parameters: SandboxCreateEntryPointRequest) -> None

Add a new analysis source

Parameters:

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_entry_point(entry_point_id: str) -> SandboxEntryPointResponse

Get information about the analysis source

Parameters:

  • entry_point_id (str) –

    ID of entry point

Returns:

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_entry_point(entry_point_id: str) -> None

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: '' ) –

    Filtering using the query language. For the syntax, see the user documentation.

    age < 30d AND (task.correlated.state != UNKNOWN ) ORDER BY start desc
    
  • 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:

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

get_entry_point_logs(entry_point_id: str) -> AsyncIterator[bytes]

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_system_status() -> SandboxSystemStatusResponse

Get information about the system status

For full information, look at the documentation of the SandboxSystemStatusResponse model.

Returns:

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_system_settings() -> SandboxSystemSettingsResponse

Get information about the system settings

Returns:

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(settings: SandboxUpdateSystemSettingsRequest) -> None

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_system_version() -> SandboxSystemVersionResponse

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_system_cluster_status() -> SandboxClusterStatusResponse

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_system_components_status() -> SandboxComponentsResponse

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_license() -> SandboxLicenseResponse

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

update_license() -> SandboxLicenseUpdateResponse

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_av_engines() -> SandboxAVEnginesResponse

Get information about antivirus scanners

Returns:

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_av_engine(item_id: str) -> SandboxAVEngineSettingsResponse

Get settings of a specific antivirus engine.

Parameters:

  • item_id (str) –

    antivirus identifier (engine code name, e.g. "clamav")

Returns:

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_av_distribution_packs() -> SandboxAVDistributionPacksResponse

Get the list of antivirus distributions available for installation.

Returns:

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