Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
PyYaDisk is a wrapper over Yandex Disk Rest API V1. The library is in creation process. You can check realized features with our roadmap below.
Install and update using pip:
pip install -U pyyadisk
Before you start using YandexDisk API, you need to get a token for Oauth authorization. You can get it from Yandex Poligon.
Let's start. At first we need to make an YandexDisk instance:
from pyyadisk import YandexDisk
token = 'ya_oauth_token'
disk = YandexDisk(token=token, proxy=proxy, ssl_verify=True, max_retries=5)
token
: Oauth token (get it at https://yandex.ru/dev/disk/poligon/)
proxy
: (optional) Proxy address for http and https
ssl_verify
: (optional) Flag of connection ssl verification check
max_retries
: (optional) Number of maximum connection retries
Now we ready to make some operations. Let's set the path for operations:
disk.path(path='path/to/directory')
path
: full path to directory or file
Ok. We ready to upload a file from computer.
If file exists it will be overwritten with flag overwrite=True
disk = YandexDisk(token=token)
disk.path(path='path/to/directory')
response = disk.upload(filepath='home/computer/path/to/the/file.pdf', overwrite=True)
filepath
: Path to the file
overwrite
: (optional) Enable overwriting for uploaded item
Or in one line
disk.path('path/to/directory').upload('home/computer/path/to/the/file.pdf', overwrite=True)
disk = YandexDisk(token=token)
disk.path(path='path/to/directory')
operation_id = disk.upload_by_url(filename='file.pdf', url='https://example.com/file_1.pdf', disable_redirects=False)
Uploading file by url working at serverside in async mode. upload_by_url()
returns operation_id
.
filename
: name of the file
url
: url of the file
disable_redirects
: Disable redirects
By operation_id
we can get status of uploading:
status = disk.operations(self, operation_id: str)
Now when file or directory was uploaded we can make some operations with it.
get(limit: int = None, offset: int = None)
: Get stats of file or directory
limit
: The number of items to return
offset
: Offset from the beginning
create(self, subdir: str = None)
: Create directory
subdir
: Name of subdirectory. If 'subdir = None' the directory will be created by path-data
delete(self, force_async: bool = None, md5_hash: str = None, permanently: bool = False)
: Delete file or directory
force_async
: Execute asynchronously (True or False).
md5_hash
: md5 hash of file
permanently
: Flag of permanently delete
copy_to(self, destination: str, force_async: bool = None, overwrite: bool = None)
: Copy file or directory
move_to(self, destination: str, force_async: bool = None, overwrite: bool = None)
: Move file or directory
destination
: Destination path
force_async
: Execute asynchronously (True or False).
overwrite
: Flag of overwrite enable
disk = YandexDisk(token=token)
create_ = disk.path('path/to/directory').create() # Create directory
info = disk.path('path/to/directory').get() # Directory stats
copy_ = disk.path('path/to/directory').copy_to('path/to/new/directory') # Copy from path='path/to/directory'
move_ = disk.path('path/to/directory').move_to('path/to/new/directory') # Move from path='path/to/directory'
disk.path('path/to/directory').delete() # Delete directory or file
share()
: Share file or directory which set by YandexDisk.path('path/to/the/file'). Returns tuple(response_code, public_url)
unshare()
: Unshare file or directory
public_url()
: Get public url of file or directory
public_key()
: Get public key of file or directory
Example:
disk = YandexDisk(token=token)
link = disk.path('path/to/directory').share()
link = disk.path('path/to/directory').public_url()
public_key = disk.path('path/to/directory').public_key()
disk.path('path/to/directory').unshare()
/v1/disk
/v1/disk/resources
/v1/disk/resources/save-to-disk
FAQs
PyYaDisk is a small wrapper over Yandex Disk Rest API V1
We found that pyyadisk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.