Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Overview of Techniques

A secure test environment protects your system, your data, and ensures your Python programs behave reliably, while allowing safe experimentation and testing unknown Python programs.

Common options for creating a secure test environment:

Comparison:

MethodPurposeSecurity Level
venv / CondaDependency managementNone (System access is open)
PyPy / RestrictedPythonSoftware-level restrictionLow (Hard to close all escape vectors)
Docker /Podman / ContainersOS-level virtualisationMedium (Better, but shares a kernel)
BSDjailOS-level virtualisationHigh
gVisor / FirecrackerMicro-VM / SandboxingHigh (Strongest isolation)

Practical Tip

If baseline system security hygiene is in place — for example, using separate user privileges for Python installations and avoiding system-wide package installation — then a Python virtual environment (such as venv or conda) is sufficient for routine security validation of Python libraries.

It should be noted, however, that a virtual environment provides dependency isolation rather than a security boundary. Any malicious code executed within the environment will still run with the privileges of the invoking user. For the analysis of untrusted or potentially malicious code, stronger isolation mechanisms — such as containerisation (e.g. Docker) or full virtual machines — are recommended.