
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
envsub is a text preprocessing tool that performs environment variable substitution in files, with support for default values. Written in Rust and callable from Python, it provides a fast and reliable way to inject environment variables into text files during runtime.
pip install envsub
envsub comes with a sub
method that text a io.TextIO
and return
a io.TextIO
containing the replaced variable.
Basic usage:
from envsub import sub
with open("/path/to/file", "r") as downstream:
with sub(downstream) as upstream:
upstream.read()
When it is usefull.
envsub
is made for replacing a set of variable inside a configuration
file from envisonment variable, its feet well with confifuration file format.
Example with json:
import json
from envsub import sub
with open("/path/to/file.json", "r") as downstream:
with sub(downstream) as upstream:
data = json.load(upstream)
envsubst subsitute variable format that are curly-braced, like in bash.
{"hello": "${NAME}"}
⚠️ Warning:
The variable stay in the same line, no
\n
are permitted.**This will not work: {"hello": "${ NAME }" }
If the environment variable is not present, no substitution will be made,
it means than in the previous example, ${NAME}
will stay in the read value.
Alternatively, a default value can be set in the variable, using a -
value.
{"hello": "${NAME-world}"}
In this case the final result will be {"hello": "world"}
.
Similar tools exists, but did not find any good one in python.
The envsub lib has been created to replace non existing tool like a8m/envsubst a Go binary that update the GNU envsubst that do not support default values.
FAQs
A text preprocessing tool with environment variable substitution.
We found that envsub 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.