Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Implementation of the fsspec
protocol for Box content management, enabling you to
interface with files stored on Box using a file-system-like navigation.
You can install boxfs
from PyPI. Use the following
command:
pip install boxfs
To use install the optional upath
dependency, use the following command
pip install boxfs[upath]
import fsspec
from boxsdk import JWTAuth
oauth = JWTAuth.from_settings_file("PATH/TO/JWT_CONFIGURATION.json")
root_id = "<ID-of-file-system-root>"
### For simple file access, you can use `fsspec.open`
with fsspec.open("box://Documents/test_file.txt", "wb", oauth=oauth, root_id=root_id) as f:
f.write("This file was produced using boxfs")
### For more control, you can use `fsspec.filesystem`
fs = fsspec.filesystem('box', oauth=oauth, root_id=root_id)
# List directory contents
fs.ls("Documents")
# Make new directory
fs.mkdir("Documents/Test Folder")
# Remove a directory
fs.rmdir("Documents/Test Folder")
# Open and write file
with fs.open("Documents/test_file.txt", "wb") as f:
f.write("This file was updated using boxfs")
# Print file contents
fs.cat("Documents/test_file.txt")
# Delete file
fs.rm("Documents/test_file.txt")
# If you installed with the `upath` extra, you can also use the universal-pathlib UPath
# class.
from upath import UPath
path = UPath("Documents", fs=fs) / "test_file.txt"
path.read_text()
The following storage options are accepted by fsspec
when creating a BoxFileSystem
object:
JWTAuth.from_settings_file
, by default NoneClient
objectClient
class to use when connecting to boxIf client
is provided, it is used for handling API calls. Otherwise, the file
system to instantiate a new client connection, of type client_type
, using the
provided oauth
configuration.
str
) of folder where file system root is placed, by default
Nonestr
) to Box root folder, must be relative to user's root
(e.g. "All Files"). The client must have access to the application user's root
folder (i.e., it cannot be downscoped to a subfolder)If only root_id
is provided, the root_path
is determined from API calls. If
only root_path
is provided, the root_id
is determined from API calls. If
neither is provided, the application user's root folder is used.
Before you can use boxfs
, you will need a Box application through which you can route
your API calls. To do so, you can follow the steps for
"Setup with JWT"
in the Box Developer documentation. The JWT configuration .json
file that
you generate will have to be stored locally and loaded using
JWTAuth.from_settings_file
. You also have to add your application's
Service Account as a collaborator on the root folder of your choosing, or
you will only have access to the Box application's files.
FAQs
Implementation of fsspec for Box file storage
We found that boxfs 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.