collaboration.project module

binaryninja.collaboration.project.RemoteProject(handle)

Class representing a remote project

class RemoteProject(handle)[source]

Bases: object

Class representing a remote project

can_user_admin(username: str) bool[source]

Determine if a user is in the admin group

Parameters:

username (str) – Username of user to check

Returns:

True if they are in any of those groups

Raises:

RuntimeError if there was an error

Return type:

bool

can_user_edit(username: str) bool[source]

Determine if a user is in any of the edit/admin groups

Parameters:

username (str) – Username of user to check

Returns:

True if they are in any of those groups

Raises:

RuntimeError if there was an error

Return type:

bool

can_user_view(username: str) bool[source]

Determine if a user is in any of the view/edit/admin groups

Parameters:

username (str) – Username of user to check

Returns:

True if they are in any of those groups

Raises:

RuntimeError if there was an error

Return type:

bool

close()[source]

Close the project and stop all background operations (e.g. file uploads)

create_file(filename: str, contents: bytes, name: str, description: str, parent_folder: ~binaryninja.collaboration.folder.RemoteFolder | None = None, file_type: ~binaryninja.collaboration.enums.FileType = FileType.BNCollaborationFileTypeBinaryViewAnalysis, progress: ~typing.Callable[[int, int], bool] = <function nop>) RemoteFile[source]

Create a new file on the remote (and pull it)

Note

If the project has not been opened, it will be opened upon calling this.

Parameters:
  • filename (str) – File name

  • contents (bytes) – File contents

  • name (str) – Displayed file name

  • description (str) – File description

  • parent_folder (RemoteFolder | None) – Folder that will contain the file

  • file_type (FileType) – Type of File to create

  • progress (Callable[[int, int], bool]) – Function to call on upload progress updates

Returns:

Reference to the created file

Raises:

RuntimeError if there was an error

Return type:

RemoteFile

create_folder(name: str, description: str, parent: ~binaryninja.collaboration.folder.RemoteFolder | None = None, progress: ~typing.Callable[[int, int], bool] = <function nop>) RemoteFolder[source]

Create a new folder on the remote (and pull it)

Note

If the project has not been opened, it will be opened upon calling this.

Parameters:
  • name (str) – Displayed folder name

  • description (str) – Folder description

  • parent (RemoteFolder | None) – Parent folder (optional)

  • progress (Callable[[int, int], bool]) – Function to call on upload progress updates

Returns:

Reference to the created folder

Raises:

RuntimeError if there was an error pulling folders

Return type:

RemoteFolder

create_group_permission(group_id: int, level: ~binaryninja.collaboration.enums.PermissionLevel, progress: ~typing.Callable[[int, int], bool] = <function nop>) Permission[source]

Create a new group permission on the remote (and pull it)

Parameters:
Returns:

Reference to the created permission

Raises:

RuntimeError if there was an error pulling permissions

Return type:

Permission

create_user_permission(user_id: str, level: ~binaryninja.collaboration.enums.PermissionLevel, progress: ~typing.Callable[[int, int], bool] = <function nop>) Permission[source]

Create a new user permission on the remote (and pull it)

Parameters:
Returns:

Reference to the created permission

Raises:

RuntimeError if there was an error pulling permissions

Return type:

Permission

delete_file(file: RemoteFile)[source]

Delete a file from the remote

Note

If the project has not been opened, it will be opened upon calling this.

Parameters:

file (RemoteFile) – File to delete

Raises:

RuntimeError if there was an error

delete_folder(folder: RemoteFolder)[source]

Delete a folder from the remote

Note

If the project has not been opened, it will be opened upon calling this.

Parameters:

folder (RemoteFolder) – Folder to delete

Raises:

RuntimeError if there was an error

delete_permission(permission: Permission)[source]

Delete a permission from the remote

Parameters:

permission (Permission) – Permission to delete

Raises:

RuntimeError if there was an error

get_file_by_id(id: str) RemoteFile | None[source]

Get a specific File in the Project by its id

Note

If the project has not been opened, it will be opened upon calling this.

Note

If files have not been pulled, they will be pulled upon calling this.

Parameters:

id (str) – Id of File

Returns:

File object, if one with that id exists. Else, None

Raises:

RuntimeError if there was an error pulling files

Return type:

RemoteFile | None

get_file_by_name(name: str) RemoteFile | None[source]

Get a specific File in the Project by its name

Note

If the project has not been opened, it will be opened upon calling this.

Note

If files have not been pulled, they will be pulled upon calling this.

Parameters:

name (str) – Name of File

Returns:

File object, if one with that name exists. Else, None

Raises:

RuntimeError if there was an error pulling files

Return type:

RemoteFile | None

get_folder_by_id(id: str) RemoteFolder | None[source]

Get a specific Folder in the Project by its id

Note

If the project has not been opened, it will be opened upon calling this.

Note

If folders have not been pulled, they will be pulled upon calling this.

Parameters:

id (str) – Id of Folder

Returns:

Folder object, if one with that id exists. Else, None

Raises:

RuntimeError if there was an error pulling folders

Return type:

RemoteFolder | None

static get_for_bv(bv: BinaryView) RemoteProject | None[source]

Get the Remote Project for a BinaryView

Parameters:

bv (BinaryView) – BinaryView, potentially with collaboration metadata

Returns:

Remote project from one of the connected remotes, or None if not found or if projects are not pulled

Raises:

RuntimeError – If there was an error

Return type:

RemoteProject | None

static get_for_local_database(database: Database) RemoteProject | None[source]

Get the Remote Project for a Database

Parameters:

database (Database) – BN database, potentially with collaboration metadata

Returns:

Remote project from one of the connected remotes, or None if not found or if projects are not pulled

Raises:

RuntimeError – If there was an error

Return type:

RemoteProject | None

get_permission_by_id(id: str) Permission | None[source]

Get a specific permission in the Project by its id

Note

If group or user permissions have not been pulled, they will be pulled upon calling this.

Parameters:

id (str) – Id of Permission

Returns:

Permission object, if one with that id exists. Else, None

Raises:

RuntimeError if there was an error pulling permissions

Return type:

Permission | None

open(progress: ~typing.Callable[[int, int], bool] = <function nop>)[source]

Open the project, allowing various file and folder based apis to work, as well as connecting a core Project (see core_project).

Parameters:

progress (Callable[[int, int], bool]) – Function to call for progress updates

Raises:

RuntimeError if there was an error opening the Project

pull_files(progress: ~typing.Callable[[int, int], bool] = <function nop>)[source]

Pull the list of files from the Remote.

Note

If the project has not been opened, it will be opened upon calling this.

Note

If folders have not been pulled, they will be pulled upon calling this.

Parameters:

progress (Callable[[int, int], bool]) – Function to call for progress updates

Raises:

RuntimeError if there was an error pulling files

pull_folders(progress: ~typing.Callable[[int, int], bool] = <function nop>)[source]

Pull the list of folders from the Remote.

Note

If the project has not been opened, it will be opened upon calling this.

Parameters:

progress (Callable[[int, int], bool]) – Function to call for progress updates

Raises:

RuntimeError if there was an error pulling folders

pull_group_permissions(progress: ~typing.Callable[[int, int], bool] = <function nop>)[source]

Pull the list of group permissions from the Remote.

Parameters:

progress (Callable[[int, int], bool]) – Function to call for progress updates

Raises:

RuntimeError if there was an error pulling permissions

pull_user_permissions(progress: ~typing.Callable[[int, int], bool] = <function nop>)[source]

Pull the list of user permissions from the Remote.

Parameters:

progress (Callable[[int, int], bool]) – Function to call for progress updates

Raises:

RuntimeError if there was an error pulling permissions

push_file(file: RemoteFile, extra_fields: Dict[str, str] | None = None)[source]

Push an updated File object to the Remote

Note

If the project has not been opened, it will be opened upon calling this.

Parameters:
  • file (RemoteFile) – File object which has been updated

  • extra_fields (Dict[str, str] | None) – Extra HTTP fields to send with the update

Raises:

RuntimeError if there was an error

push_folder(folder: RemoteFolder, extra_fields: Dict[str, str] | None = None)[source]

Push an updated Folder object to the Remote

Note

If the project has not been opened, it will be opened upon calling this.

Parameters:
  • folder (RemoteFolder) – Folder object which has been updated

  • extra_fields (Dict[str, str] | None) – Extra HTTP fields to send with the update

Raises:

RuntimeError if there was an error

push_permission(permission: Permission, extra_fields: Dict[str, str] | None = None)[source]

Push project permissions to the remote

Parameters:
  • permission (Permission) – Permission object which has been updated

  • extra_fields (Dict[str, str] | None) – Extra HTTP fields to send with the update

Raises:

RuntimeError if there was an error

upload_new_file(target: str | ~os.PathLike | ~binaryninja.binaryview.BinaryView | ~binaryninja.filemetadata.FileMetadata, parent_folder: ~binaryninja.collaboration.folder.RemoteFolder | None = None, progress: ~typing.Callable[[int, int], bool] = <function nop>, open_view_options=None) RemoteFile[source]

Upload a file to the project, creating a new File and pulling it

Note

If the project has not been opened, it will be opened upon calling this.

Parameters:
Returns:

Created File object

Raises:

RuntimeError if there was an error

Return type:

RemoteFile

property core_project: Project

Get the core binaryninja.Project object for this Remote Project.

Note

If the project has not been opened, it will be opened upon calling this.

Returns:

Project instance

property created: datetime

Created date of the project

Returns:

Date object

property default_path: str

Get the default directory path for a remote Project. This is based off the Setting for collaboration.directory, the project’s id, and the project’s remote’s id.

Returns:

Default project path

Return type:

str

property description

Description of the project

Returns:

Description string

property files: List[RemoteFile]

Get the list of files in this project.

Note

If the project has not been opened, it will be opened upon calling this.

Note

If folders have not been pulled, they will be pulled upon calling this.

Note

If files have not been pulled, they will be pulled upon calling this.

Returns:

List of File objects

Raises:

RuntimeError if there was an error pulling files

property folders: List[RemoteFolder]

Get the list of folders in this project.

Note

If the project has not been opened, it will be opened upon calling this.

Note

If folders have not been pulled, they will be pulled upon calling this.

Returns:

List of Folder objects

Raises:

RuntimeError if there was an error pulling folders

property group_permissions: List[Permission]

Get the list of group permissions in this project.

Note

If group permissions have not been pulled, they will be pulled upon calling this.

Returns:

List of Permission objects

Raises:

RuntimeError if there was an error pulling group permissions

property has_pulled_files

If the project has pulled the files yet

Returns:

True if they have been pulled

property has_pulled_folders

If the project has pulled the folders yet

Returns:

True if they have been pulled

property has_pulled_group_permissions

If the project has pulled the group permissions yet

Returns:

True if they have been pulled

property has_pulled_user_permissions

If the project has pulled the user permissions yet

Returns:

True if they have been pulled

property id

Unique id

Returns:

Id string

property is_admin

If the currently logged in user is an administrator of the project (and can edit permissions and such for the project).

Returns:

True if the user is an admin

property is_open: bool

Determine if the project is open (it needs to be opened before you can access its files)

Returns:

True if open

property last_modified: datetime

Last modified date of the project

Returns:

Date object

property name

Displayed name of project

Returns:

Name string

property received_file_count: int

Get the number of files in a project (without needing to pull them first)

Returns:

Number of files

property received_folder_count: int

Get the number of folders in a project (without needing to pull them first)

Returns:

Number of folders

property remote: Remote

Owning Remote

Returns:

Remote object

property url

Web api endpoint URL

Returns:

URL string

property user_permissions: List[Permission]

Get the list of user permissions in this project.

Note

If user permissions have not been pulled, they will be pulled upon calling this.

Returns:

List of Permission objects

Raises:

RuntimeError if there was an error pulling user permissions

nop(*args, **kwargs)[source]