
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).
Pytest plugin for managing environment variables with interpolation and .env file support.
pytest-envx is a powerful and user-friendly plugin for pytest, allowing you to easily manage environment variables from configuration files like pyproject.toml
and pytest.ini
.
.env
filespyproject.toml
and pytest.ini
pip install pytest-envx
Create a configuration file — either pyproject.toml
⚙️ or pytest.ini
⚙️
By default, pytest
prioritizes pytest.ini
⚙️
pyproject.toml ⚙️ | pytest.ini ⚙️ |
---|---|
|
|
test_example.py
🐍:
import os
def test_env_var():
assert os.getenv("HELLO") == "WORLD"
.env
🔐 files with override.env-template 🔐 | .env 🔐 |
---|---|
NAME=ALICE LASTNAME=BAILER |
NAME=BOB |
pyproject.toml ⚙️ | pytest.ini ⚙️ |
---|---|
[tool.pytest.ini_options] envx_metadata = { paths_to_load = [".env-template", ".env"], override_load = true } env = [ "GREETING='Hello'" ] |
[pytest] envx_metadata = {"paths_to_load": [".env-template", ".env"], "override_load": True} env = GREETING="Hello" |
test_env_load.py
🐍:
import os
def test_env_loading():
assert os.getenv("NAME") == "BOB"
assert os.getenv("LASTNAME") == "BAILER"
assert os.getenv("GREETING") == "Hello"
.env
🔐 files without override.env.default 🔐 | .env.dev 🔐 |
---|---|
MODE=default |
MODE=development LEVEL=DEV |
pyproject.toml ⚙️ | pytest.ini ⚙️ |
---|---|
[tool.pytest.ini_options] envx_metadata = { paths_to_load = [".env.default", ".env.dev"], override_load = false } |
[pytest] envx_metadata = {"paths_to_load": [".env.default", ".env.dev"], "override_load": False} |
test_priority.py
🐍:
import os
def test_env_priority():
assert os.getenv("MODE") == "default"
assert os.getenv("LEVEL") == "DEV"
.env 🔐 |
---|
USER=john PASS=secret HOST=db.local PORT=5432 |
pyproject.toml ⚙️ | pytest.ini ⚙️ |
---|---|
[tool.pytest.ini_options] envx_metadata = { paths_to_interpolate = [".env"] } env = [ "DB_URL_WITH_INTERPOLATION='postgresql://{%USER%}:{%PASS%}@{%HOST%}:{%PORT%}/app'", "WITHOUT_INTERPOLATION={'value': '{%USER%}', 'interpolate': False}", "NOT_FOUND='{%NOT_FOUND%}'" ] |
[pytest] envx_metadata = {"paths_to_interpolate": [".env"]} env = DB_URL_WITH_INTERPOLATION="postgresql://{%USER%}:{%PASS%}@{%HOST%}:{%PORT%}/app" WITHOUT_INTERPOLATION={"value": "{%USER%}", "interpolate": False} NOT_FOUND = "{%NOT_FOUND%}" |
test_interpolation.py
🐍:
import os
def test_interpolated_value():
assert os.getenv("DB_URL_WITH_INTERPOLATION") == "postgresql://john:secret@db.local:5432/app"
assert os.getenv("WITHOUT_INTERPOLATION") == "{%USER%}"
assert os.getenv("NOT_FOUND") == "{%NOT_FOUND%}"
assert os.getenv("USER") != "john"
assert os.getenv("PASS") != "secret"
assert os.getenv("HOST") != "db.local"
assert os.getenv("PORT") != "5432"
Parameter | Type | Description |
---|---|---|
paths_to_load | list | Paths to .env files to load environment variables from (loaded in order) |
override_load | (bool, default=True) | Whether to override existing environment variables during load |
paths_to_interpolate | list | Paths to files for value interpolation |
override_interpolate | (bool, default=True) | Whether to override variables during interpolation |
FAQs
Pytest plugin for managing environment variables with interpolation and .env file support.
We found that pytest-envx 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.