
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
An example of a package developed with pyenv, built with build using setuptools, uploaded to PyPI using twine, and distributed via pip.
This package was created by generally following the Packaging Python Projects with the addition of some pipenv setup to manage virtual environments.
examplepackagefb1258
is replaced with your package's name. This name must be uniquely yours when uploaded to PyPI. Better to avoid hyphens or underline characters (-
or _
) in the package name, as these can create problems when importing. The parent directory name (the repository name) - python-package-example
in this case - is not relevant to the package name.python-package-example/
|____README.md
|____LICENSE
|____pyproject.toml
|____tests
|____src
|____examplepackagefb1258
|______init__.py
|______main__.py
|____wisdom.py
__init__.py
an empty file.LICENSE
.pyproject.toml
suitable for a setuptools
-based build and add metadata fields to this file - see the example in this repository.src
/examplepackagefb1258
/wisdom.py
or whatever filename(s) you choose for the module(s) that live within your package.__main__.py
file to the package directory, if you want to be able to run the package as a script from the command line, e.g. python -m examplepackagefb1258
.python -m build
from the same directory where the pyproject.toml
file is located..tar
archive has the files you expect your package to have (including any important non-code files) by running the command: tar --list -f dist/examplepackagefb1258-0.0.7.tar.gz
, where examplepackagefb1258-0.0.7
is replaced with your own package name and version.twine upload -r testpypi dist/*
README.md
file looks nice on the web site.Every time you change the code in your package, you will need to rebuild and reupload it to PyPI. You will need to build from a clean slate and update the version number to achieve this:
dist
directorysrc/*.egg-info
directorypyproject.toml
and anywhere else it is mentioned (do a find/replace)python -m build
twine upload -r testpypi dist/*
Repeat as many times as necessary until the package works as expected. Once complete, upload to the real PyPI instead of the TestPyPI repository.
If updating version numbers is tedious, you may consider using bumpver - a tool that can automate some parts of updating version numbers.
Try installing and using your package in a separate Python project:
pipenv
-managed virtual environment and install the latest version of your package installed: pipenv install -i https://test.pypi.org/simple/ examplepackagefb1258==0.0.7
. (Note that if you've previously created a pipenv
virtual environment in the same directory, you may have to delete the old one first. Find out where it is located with the pipenv --venv
command.)pipenv shell
.from examplepackagefb1258 import wisdom
and then print(wisdom.get())
(replace wisdom
and get()
with any module name and function that exists in your package) .python3 my_program_filename.py
.exit
.Try running the package directly:
pipenv
virtual environment as before.python3 -m examplepackagefb1258
. This should run the code in the __main__.py
file.Simple example unit tests are included within the tests
directory. To run these tests...
python3 -m pytest
.While working on the package code, and verifying it behaves as expected, it can be helpful to install the package in "editable" mode so that changes to the package are immediately updated in the virtual environment.
pipenv install -e .
from the main project directory.This project has a continuous integration workflow that builds and runs unit tests automatically with every push of the code to GitHub.
FAQs
An example of a package developed with pyenv, built with build using setuptools, uploaded to PyPI using twine, and distributed via pip.
We found that easyckpt 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
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.