
Security News
Opengrep Adds Apex Support and New Rule Controls in Latest Updates
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
A robust Python module to safely source a bash script in a sandboxed environment and collect its variables.
BashVar Sentry is a Python utility module that securely extracts Bash variable declarations from scripts by sourcing them in a sandboxed environment. It supports sandboxing via chroot
, bwrap
, or fakechroot
to reduce risk from untrusted content.
Install from PyPI:
pip install bashvar-sentry
from bashvar_sentry import source_and_get_vars
variables = source_and_get_vars(
"example.sh",
sandbox_method="auto", # "auto", "chroot", "bwrap", "fakechroot", "empty"
jail_dir="/", # Optional: target root dir for sandbox
extra_env={"MYVAR": "from_python"},
additional_args=["one", "two"]
)
print(variables)
Your script must be syntactically valid (bash -n
is run first).
example.sh
#!/bin/bash
ARG1=$1
ARG2=$2
ENV_CAPTURED="$MYVAR"
declare -a FRUITS=("apple" "banana split")
declare -A CONFIG=([host]="localhost" [port]="8080")
{
"ARG1": "one",
"ARG2": "two",
"ENV_CAPTURED": "from_python",
"FRUITS": ["apple", "banana split"],
"CONFIG": {"host": "localhost", "port": "8080"}
}
Method | Isolation | Root Required | Notes |
---|---|---|---|
chroot | Full | Yes | Needs /usr/sbin/chroot |
bwrap | Strong | No | Needs bwrap binary |
fakechroot | Simulated | No | Must have fakechroot |
empty | Minimal | No | Sets PATH="" |
auto | Best fit | No | Picks the first available |
Run tests with:
python -m pytest
To test sandbox fallbacks, install:
/usr/sbin/chroot
and run as root (for chroot) - This auto skips if not rootbwrap
fakechroot
Apache-2.0
FAQs
A robust Python module to safely source a bash script in a sandboxed environment and collect its variables.
We found that bashvar-sentry 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
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.