collaboration.project module

binaryninja.collaboration.project.Project(handle)

Class representing a remote project

class Project(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

create_file(filename: str, contents: bytes, name: str, description: str, parent_folder: ~typing.Optional[~binaryninja.collaboration.folder.Folder] = None, progress: ~typing.Callable[[int, int], bool] = <function nop>) File[source]

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

Parameters:
  • filename (str) – File name

  • contents (bytes) – File contents

  • name (str) – Displayed file name

  • description (str) – File description

  • parent_folder (Optional[Folder]) – Folder that will contain the file

  • 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:

File

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

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

Parameters:
  • name (str) – Displayed folder name

  • description (str) – Folder description

  • parent (Optional[Folder]) – 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:

Folder

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: File)[source]

Delete a file from the remote

Parameters:

file (File) – File to delete

Raises:

RuntimeError if there was an error

delete_folder(folder: Folder)[source]

Delete a folder from the remote

Parameters:

folder (Folder) – 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) Optional[File][source]

Get a specific File in the Project by its id

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:

Optional[File]

get_file_by_name(name: str) Optional[File][source]

Get a specific File in the Project by its name

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:

Optional[File]

get_folder_by_id(id: str) Optional[Folder][source]

Get a specific Folder in the Project by its id

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:

Optional[Folder]

static get_for_bv(bv: BinaryView) Optional[Project][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:

Optional[Project]

static get_for_local_database(database: Database) Optional[Project][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:

Optional[Project]

get_permission_by_id(id: str) Optional[Permission][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:

Optional[Permission]

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

Pull the list of files from the Remote.

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.

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: File, extra_fields: Optional[Dict[str, str]] = None)[source]

Push an updated File object to the Remote

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

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

Raises:

RuntimeError if there was an error

push_folder(folder: Folder, extra_fields: Optional[Dict[str, str]] = None)[source]

Push an updated Folder object to the Remote

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

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

Raises:

RuntimeError if there was an error

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

Push project permissions to the remote

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

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

Raises:

RuntimeError if there was an error

upload_new_file(metadata_or_path: ~typing.Union[str, ~os.PathLike, ~binaryninja.filemetadata.FileMetadata], parent_folder: ~typing.Optional[~binaryninja.collaboration.folder.Folder] = None, progress: ~typing.Callable[[int, int], bool] = <function nop>) File[source]

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

Parameters:
Returns:

Created File object

Raises:

RuntimeError if there was an error

Return type:

File

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[File]

Get the list of files in this project.

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[Folder]

Get the list of folders in this project.

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 last_modified: datetime

Last modified date of the project

Returns:

Date object

property name

Displayed name of project

Returns:

Name string

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]