codeshield-runtime 0.1.3__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/LICENSE +1 -1
  2. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/PKG-INFO +52 -19
  3. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/README.md +50 -17
  4. codeshield_runtime-0.2.0/SECURITY.md +31 -0
  5. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/pyproject.toml +6 -2
  6. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/src/codeshield/__init__.py +48 -46
  7. codeshield_runtime-0.2.0/src/codeshield/analyzer.py +417 -0
  8. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/src/codeshield/classifier.py +7 -2
  9. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/src/codeshield/cli.py +24 -6
  10. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/src/codeshield/environment.py +73 -9
  11. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/src/codeshield/loop.py +35 -28
  12. codeshield_runtime-0.2.0/src/codeshield/runner.py +376 -0
  13. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/src/codeshield/schemas.py +215 -120
  14. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/src/codeshield/tools.py +27 -6
  15. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/tests/test_coverage.py +4 -2
  16. codeshield_runtime-0.2.0/tests/test_security.py +308 -0
  17. codeshield_runtime-0.1.3/src/codeshield/analyzer.py +0 -151
  18. codeshield_runtime-0.1.3/src/codeshield/runner.py +0 -222
  19. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/.gitignore +0 -0
  20. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/src/codeshield/__main__.py +0 -0
  21. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/tests/__init__.py +0 -0
  22. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/tests/test_cli.py +0 -0
  23. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/tests/test_engine.py +0 -0
  24. {codeshield_runtime-0.1.3 → codeshield_runtime-0.2.0}/tests/test_tools.py +0 -0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Autonomous Code Execution Engine contributors
3
+ Copyright (c) 2026 AlgorithmicMind (CodeShield contributors)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: codeshield-runtime
3
- Version: 0.1.3
3
+ Version: 0.2.0
4
4
  Summary: A secure, isolated, and self-healing Python code execution engine powered by uv and AST analysis.
5
5
  Project-URL: Homepage, https://github.com/AlgorithmicMind/codeshield
6
6
  Project-URL: Repository, https://github.com/AlgorithmicMind/codeshield
7
7
  Project-URL: Issues, https://github.com/AlgorithmicMind/codeshield/issues
8
- Author: Senior Python Core Engineer
8
+ Author: AlgorithmicMind
9
9
  License: MIT
10
10
  License-File: LICENSE
11
11
  Keywords: ast,code,execution,sandbox,self-healing,uv
@@ -37,7 +37,7 @@ Description-Content-Type: text/markdown
37
37
  # CodeShield: Autonomous Code Execution Engine
38
38
 
39
39
  [![CI](https://img.shields.io/github/actions/workflow/status/AlgorithmicMind/codeshield/ci.yml?branch=main&label=CI)](https://github.com/AlgorithmicMind/codeshield/actions)
40
- [![Python](https://img.shields.io/badge/python-3.11%20%7C%203.12-blue)](https://www.python.org/)
40
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/)
41
41
  [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
42
42
  [![Code Style: Ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
43
43
  [![PyPI](https://img.shields.io/pypi/v/codeshield-runtime.svg)](https://pypi.org/project/codeshield-runtime/)
@@ -52,8 +52,8 @@ This open-source engine executes Python code generated by LLMs inside a disposab
52
52
  | Feature | Vanilla `subprocess` | Docker Container | CodeShield (This Engine) |
53
53
  | :--- | :--- | :--- | :--- |
54
54
  | **Startup Overhead** | ~5 – 10 ms | ~1,500 – 3,000 ms | **Sub-second (~30–250 ms via `uv`)** |
55
- | **Isolation Mechanism** | None (Host Process) | Container Namespaces / cgroups | **Ephemeral Virtualenv (`tempfile` + `uv`)** |
56
- | **AST Security Gate** | ❌ None | ❌ None | **✅ Static AST inspection (`os.system`, `eval`)** |
55
+ | **Isolation Mechanism** | None (Host Process) | Container Namespaces / cgroups | **Ephemeral Virtualenv + Env Allowlist + Scoped `cwd` + Tree Kill** |
56
+ | **AST Security Gate** | ❌ None | ❌ None | **✅ Fail-closed AST gate (aliases, dunders, blocked modules, dangerous calls)** |
57
57
  | **Silent Failure Detection** | ❌ None | ❌ None | **✅ Regex scanning for empty DataFrames/NaNs** |
58
58
  | **Self-Healing Loop** | ❌ None | ❌ None | **✅ 3-Tier Traceback Diagnosis + LLM Patch (Any Provider)** |
59
59
 
@@ -79,20 +79,21 @@ This open-source engine executes Python code generated by LLMs inside a disposab
79
79
 
80
80
  ## Key Features
81
81
 
82
- ### 1. Ephemeral Sandboxing with Dual-Mode Backend
82
+ ### 1. Ephemeral Sandboxing with Hardened Subprocess Controls
83
83
 
84
- - **Primary**: `uv venv` for ultra-fast environment creation and package installation.
85
- - **Fallback**: native `python -m venv` + `pip` when `uv` is unavailable, so the engine works out of the box on any machine.
86
- - Each execution lands in its own temporary workspace that is destroyed after use.
84
+ - **Primary**: `uv venv` for ultra-fast environment creation and package installation, with native `python -m venv` + `pip` fallback.
85
+ - **Minimal Environment Allowlist**: host secrets (`GEMINI_API_KEY`, cloud tokens, `.env` values) are **never** inherited by the child process. Pass explicit variables via `CodeExecutionRequest(env={...})` or `SubprocessRunner(env_allowlist=[...])`.
86
+ - **Workspace & Resource Guardrails**: scripts execute with `cwd` and temp directories pinned inside the disposable workspace, strict path-traversal & PEP 508 package validation, bounded `stdout`/`stderr` capture (`max_output_bytes`), redacted host paths in tracebacks, and process-tree termination on timeout.
87
87
 
88
- ### 2. Deterministic AST Security Gates
88
+ ### 2. Fail-Closed AST Security Gates
89
89
 
90
- The engine parses every snippet with the standard `ast` module and rejects:
90
+ The engine parses every snippet (and every LLM-generated patch) with the standard `ast` module and fails closed on:
91
91
 
92
92
  - `SyntaxError`s before execution.
93
- - Bare `except:` / `except Exception:` / `except BaseException:` handlers.
94
- - Calls to dangerous parametrizable functions: `eval()`, `exec()`, `compile()`.
95
- - Calls to system/subprocess primitives: `os.system()`, `subprocess.call()`, `subprocess.run()`, `subprocess.Popen()`.
93
+ - Bare `except:` / `except Exception:` / `except BaseException:` handlers (including tuple handlers).
94
+ - Dangerous builtins & reflection (`eval()`, `exec()`, `compile()`, `__import__()`, `getattr()`, `globals()`, etc.) even when aliased or reassigned.
95
+ - Blocked high-risk modules (`subprocess`, `ctypes`, `importlib`, `pickle`, `socket`, `shutil`, `builtins`, etc.) and dangerous `os`/`sys` APIs (`os.system`, `os.popen`, `os.environ`, `sys.modules`, `sys._getframe`).
96
+ - Reflection dunder traversal (`__subclasses__`, `__builtins__`, `__globals__`, `__class__`, `__bases__`, etc.).
96
97
 
97
98
  ### 3. Silent Failure Detection
98
99
 
@@ -112,7 +113,7 @@ AST Validation ──► Sandbox Execution ──► Traceback Classification
112
113
  ```
113
114
 
114
115
  - **Local heuristic fallback**: handles `NameError`, `ImportError`, `ModuleNotFoundError` by injecting safe imports or placeholder definitions.
115
- - **LLM-guided healing**: when an LLM is configured (built-in Gemini Flash by default, or any custom provider via `patch_generator`), it asks the model for a corrected version of the code, validates it with the AST gate, and re-executes the patched snippet.
116
+ - **LLM-guided healing**: when an LLM is configured (built-in Gemini 4 by default, or any custom provider via `patch_generator`), it asks the model for a corrected version of the code, validates it with the AST gate, and re-executes the patched snippet.
116
117
 
117
118
  ---
118
119
 
@@ -188,13 +189,13 @@ result, diagnosis = engine.run('print("Result: " + 42)')
188
189
  print(result.stdout) # Result: 42
189
190
  ```
190
191
 
191
- ### Zero-Config Self-Healing with Gemini Flash
192
+ ### Zero-Config Self-Healing with Gemini 4
192
193
 
193
194
  For the built-in zero-config experience, create a `.env` file from `.env.example`:
194
195
 
195
196
  ```text
196
197
  GEMINI_API_KEY=your_key_here
197
- GEMINI_MODEL=gemini-3.7-flash
198
+ GEMINI_MODEL=gemini-4-hydrogen
198
199
  ```
199
200
 
200
201
  ```python
@@ -251,15 +252,22 @@ Everything is re-exported at the package root, so imports never need internal su
251
252
 
252
253
  ```python
253
254
  from codeshield import (
255
+ DEFAULT_GEMINI_MODEL,
254
256
  ASTSecurityError,
255
257
  CodeExecutionRequest,
256
258
  ErrorDiagnosis,
257
259
  ExecutionResult,
260
+ GeminiPatchGenerator,
261
+ LLMPatchError,
262
+ PatchProposal,
263
+ SandboxError,
258
264
  SandboxManager,
259
265
  SelfHealingEngine,
260
266
  SelfHealingError,
261
267
  SubprocessRunner,
268
+ SubprocessRunnerError,
262
269
  TracebackClassifier,
270
+ ValidationReport,
263
271
  create_code_execution_tool,
264
272
  validate_syntax_and_safety,
265
273
  )
@@ -267,6 +275,31 @@ from codeshield import (
267
275
 
268
276
  `ASTSecurityError` subclasses `SelfHealingError` and is raised whenever the static AST gate blocks either the original snippet or a generated patch.
269
277
 
278
+ ### Explicit Environment Variables
279
+
280
+ Host environment variables (including API keys loaded from `.env`) are never leaked into executed code. To expose specific variables to a snippet, pass them explicitly:
281
+
282
+ ```python
283
+ from codeshield import CodeExecutionRequest, SelfHealingEngine
284
+
285
+ request = CodeExecutionRequest(
286
+ code="import json\nprint(json.dumps({'status': 'ok'}))",
287
+ env={"APP_MODE": "sandbox"},
288
+ )
289
+ with SelfHealingEngine(use_llm=False) as engine:
290
+ result, _ = engine.run(request)
291
+ ```
292
+
293
+ ---
294
+
295
+ ## Security Model & Threat Boundaries
296
+
297
+ CodeShield provides **application-layer defense-in-depth** tailored for LLM-generated data, math, and automation snippets (fail-closed AST checks, env allowlisting, scoped workspace `cwd`, path traversal & pip-flag validation, bounded output capture, host-path redaction, and process-tree termination).
298
+
299
+ > **Threat boundary:** Ephemeral virtualenvs and static AST inspection do **not** provide OS kernel isolation (namespaces, seccomp, cgroups, or network firewalls). For **untrusted or adversarial multi-tenant workloads**, run CodeShield inside a hardened container or microVM (Docker with `--network=none --read-only`, gVisor, or Firecracker).
300
+
301
+ See [SECURITY.md](SECURITY.md) for the full security policy and private vulnerability disclosure instructions.
302
+
270
303
  ---
271
304
 
272
305
  ## Verified Examples
@@ -289,10 +322,10 @@ python examples/05_custom_llm_openai_compatible.py
289
322
 
290
323
  ## Running Tests & Lint
291
324
 
292
- The suite currently has **54 tests** with **>83% code coverage** on `src/codeshield`.
325
+ The suite currently has **110 tests** with **>85% code coverage** on `src/codeshield`.
293
326
 
294
327
  ```bash
295
- ruff check src tests examples
328
+ ruff check src tests examples demo.py
296
329
  pytest tests -v --cov=src/codeshield
297
330
  ```
298
331
 
@@ -1,7 +1,7 @@
1
1
  # CodeShield: Autonomous Code Execution Engine
2
2
 
3
3
  [![CI](https://img.shields.io/github/actions/workflow/status/AlgorithmicMind/codeshield/ci.yml?branch=main&label=CI)](https://github.com/AlgorithmicMind/codeshield/actions)
4
- [![Python](https://img.shields.io/badge/python-3.11%20%7C%203.12-blue)](https://www.python.org/)
4
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/)
5
5
  [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
6
6
  [![Code Style: Ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
7
7
  [![PyPI](https://img.shields.io/pypi/v/codeshield-runtime.svg)](https://pypi.org/project/codeshield-runtime/)
@@ -16,8 +16,8 @@ This open-source engine executes Python code generated by LLMs inside a disposab
16
16
  | Feature | Vanilla `subprocess` | Docker Container | CodeShield (This Engine) |
17
17
  | :--- | :--- | :--- | :--- |
18
18
  | **Startup Overhead** | ~5 – 10 ms | ~1,500 – 3,000 ms | **Sub-second (~30–250 ms via `uv`)** |
19
- | **Isolation Mechanism** | None (Host Process) | Container Namespaces / cgroups | **Ephemeral Virtualenv (`tempfile` + `uv`)** |
20
- | **AST Security Gate** | ❌ None | ❌ None | **✅ Static AST inspection (`os.system`, `eval`)** |
19
+ | **Isolation Mechanism** | None (Host Process) | Container Namespaces / cgroups | **Ephemeral Virtualenv + Env Allowlist + Scoped `cwd` + Tree Kill** |
20
+ | **AST Security Gate** | ❌ None | ❌ None | **✅ Fail-closed AST gate (aliases, dunders, blocked modules, dangerous calls)** |
21
21
  | **Silent Failure Detection** | ❌ None | ❌ None | **✅ Regex scanning for empty DataFrames/NaNs** |
22
22
  | **Self-Healing Loop** | ❌ None | ❌ None | **✅ 3-Tier Traceback Diagnosis + LLM Patch (Any Provider)** |
23
23
 
@@ -43,20 +43,21 @@ This open-source engine executes Python code generated by LLMs inside a disposab
43
43
 
44
44
  ## Key Features
45
45
 
46
- ### 1. Ephemeral Sandboxing with Dual-Mode Backend
46
+ ### 1. Ephemeral Sandboxing with Hardened Subprocess Controls
47
47
 
48
- - **Primary**: `uv venv` for ultra-fast environment creation and package installation.
49
- - **Fallback**: native `python -m venv` + `pip` when `uv` is unavailable, so the engine works out of the box on any machine.
50
- - Each execution lands in its own temporary workspace that is destroyed after use.
48
+ - **Primary**: `uv venv` for ultra-fast environment creation and package installation, with native `python -m venv` + `pip` fallback.
49
+ - **Minimal Environment Allowlist**: host secrets (`GEMINI_API_KEY`, cloud tokens, `.env` values) are **never** inherited by the child process. Pass explicit variables via `CodeExecutionRequest(env={...})` or `SubprocessRunner(env_allowlist=[...])`.
50
+ - **Workspace & Resource Guardrails**: scripts execute with `cwd` and temp directories pinned inside the disposable workspace, strict path-traversal & PEP 508 package validation, bounded `stdout`/`stderr` capture (`max_output_bytes`), redacted host paths in tracebacks, and process-tree termination on timeout.
51
51
 
52
- ### 2. Deterministic AST Security Gates
52
+ ### 2. Fail-Closed AST Security Gates
53
53
 
54
- The engine parses every snippet with the standard `ast` module and rejects:
54
+ The engine parses every snippet (and every LLM-generated patch) with the standard `ast` module and fails closed on:
55
55
 
56
56
  - `SyntaxError`s before execution.
57
- - Bare `except:` / `except Exception:` / `except BaseException:` handlers.
58
- - Calls to dangerous parametrizable functions: `eval()`, `exec()`, `compile()`.
59
- - Calls to system/subprocess primitives: `os.system()`, `subprocess.call()`, `subprocess.run()`, `subprocess.Popen()`.
57
+ - Bare `except:` / `except Exception:` / `except BaseException:` handlers (including tuple handlers).
58
+ - Dangerous builtins & reflection (`eval()`, `exec()`, `compile()`, `__import__()`, `getattr()`, `globals()`, etc.) even when aliased or reassigned.
59
+ - Blocked high-risk modules (`subprocess`, `ctypes`, `importlib`, `pickle`, `socket`, `shutil`, `builtins`, etc.) and dangerous `os`/`sys` APIs (`os.system`, `os.popen`, `os.environ`, `sys.modules`, `sys._getframe`).
60
+ - Reflection dunder traversal (`__subclasses__`, `__builtins__`, `__globals__`, `__class__`, `__bases__`, etc.).
60
61
 
61
62
  ### 3. Silent Failure Detection
62
63
 
@@ -76,7 +77,7 @@ AST Validation ──► Sandbox Execution ──► Traceback Classification
76
77
  ```
77
78
 
78
79
  - **Local heuristic fallback**: handles `NameError`, `ImportError`, `ModuleNotFoundError` by injecting safe imports or placeholder definitions.
79
- - **LLM-guided healing**: when an LLM is configured (built-in Gemini Flash by default, or any custom provider via `patch_generator`), it asks the model for a corrected version of the code, validates it with the AST gate, and re-executes the patched snippet.
80
+ - **LLM-guided healing**: when an LLM is configured (built-in Gemini 4 by default, or any custom provider via `patch_generator`), it asks the model for a corrected version of the code, validates it with the AST gate, and re-executes the patched snippet.
80
81
 
81
82
  ---
82
83
 
@@ -152,13 +153,13 @@ result, diagnosis = engine.run('print("Result: " + 42)')
152
153
  print(result.stdout) # Result: 42
153
154
  ```
154
155
 
155
- ### Zero-Config Self-Healing with Gemini Flash
156
+ ### Zero-Config Self-Healing with Gemini 4
156
157
 
157
158
  For the built-in zero-config experience, create a `.env` file from `.env.example`:
158
159
 
159
160
  ```text
160
161
  GEMINI_API_KEY=your_key_here
161
- GEMINI_MODEL=gemini-3.7-flash
162
+ GEMINI_MODEL=gemini-4-hydrogen
162
163
  ```
163
164
 
164
165
  ```python
@@ -215,15 +216,22 @@ Everything is re-exported at the package root, so imports never need internal su
215
216
 
216
217
  ```python
217
218
  from codeshield import (
219
+ DEFAULT_GEMINI_MODEL,
218
220
  ASTSecurityError,
219
221
  CodeExecutionRequest,
220
222
  ErrorDiagnosis,
221
223
  ExecutionResult,
224
+ GeminiPatchGenerator,
225
+ LLMPatchError,
226
+ PatchProposal,
227
+ SandboxError,
222
228
  SandboxManager,
223
229
  SelfHealingEngine,
224
230
  SelfHealingError,
225
231
  SubprocessRunner,
232
+ SubprocessRunnerError,
226
233
  TracebackClassifier,
234
+ ValidationReport,
227
235
  create_code_execution_tool,
228
236
  validate_syntax_and_safety,
229
237
  )
@@ -231,6 +239,31 @@ from codeshield import (
231
239
 
232
240
  `ASTSecurityError` subclasses `SelfHealingError` and is raised whenever the static AST gate blocks either the original snippet or a generated patch.
233
241
 
242
+ ### Explicit Environment Variables
243
+
244
+ Host environment variables (including API keys loaded from `.env`) are never leaked into executed code. To expose specific variables to a snippet, pass them explicitly:
245
+
246
+ ```python
247
+ from codeshield import CodeExecutionRequest, SelfHealingEngine
248
+
249
+ request = CodeExecutionRequest(
250
+ code="import json\nprint(json.dumps({'status': 'ok'}))",
251
+ env={"APP_MODE": "sandbox"},
252
+ )
253
+ with SelfHealingEngine(use_llm=False) as engine:
254
+ result, _ = engine.run(request)
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Security Model & Threat Boundaries
260
+
261
+ CodeShield provides **application-layer defense-in-depth** tailored for LLM-generated data, math, and automation snippets (fail-closed AST checks, env allowlisting, scoped workspace `cwd`, path traversal & pip-flag validation, bounded output capture, host-path redaction, and process-tree termination).
262
+
263
+ > **Threat boundary:** Ephemeral virtualenvs and static AST inspection do **not** provide OS kernel isolation (namespaces, seccomp, cgroups, or network firewalls). For **untrusted or adversarial multi-tenant workloads**, run CodeShield inside a hardened container or microVM (Docker with `--network=none --read-only`, gVisor, or Firecracker).
264
+
265
+ See [SECURITY.md](SECURITY.md) for the full security policy and private vulnerability disclosure instructions.
266
+
234
267
  ---
235
268
 
236
269
  ## Verified Examples
@@ -253,10 +286,10 @@ python examples/05_custom_llm_openai_compatible.py
253
286
 
254
287
  ## Running Tests & Lint
255
288
 
256
- The suite currently has **54 tests** with **>83% code coverage** on `src/codeshield`.
289
+ The suite currently has **110 tests** with **>85% code coverage** on `src/codeshield`.
257
290
 
258
291
  ```bash
259
- ruff check src tests examples
292
+ ruff check src tests examples demo.py
260
293
  pytest tests -v --cov=src/codeshield
261
294
  ```
262
295
 
@@ -0,0 +1,31 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Security fixes are applied to the latest minor release on the `main` branch.
6
+
7
+ | Version | Supported |
8
+ | :--- | :--- |
9
+ | `0.2.x` (latest) | :white_check_mark: |
10
+ | `< 0.2.0` | :x: (upgrade to `>=0.2.0`) |
11
+
12
+ ## Security Model & Threat Boundaries
13
+
14
+ CodeShield provides **application-layer defense-in-depth** for executing LLM-generated Python snippets (analytics, data transformation, scripting, and agent tool calls):
15
+
16
+ - **Fail-closed Static AST Gate**: blocks syntax errors, overly broad exception handlers, dangerous builtins (`eval`, `exec`, `compile`, `__import__`, reflection helpers), aliased or variable-rebound calls, restricted modules (`subprocess`, `ctypes`, `importlib`, `pickle`, `socket`, `shutil`, `builtins`, etc.), dangerous `os`/`sys` APIs, and reflection dunder attributes (`__subclasses__`, `__builtins__`, `__globals__`, etc.).
17
+ - **Minimal Environment Allowlist**: subprocesses never inherit the full host `os.environ` (protecting `GEMINI_API_KEY`, cloud credentials, and database secrets). Extra variables must be passed explicitly via `CodeExecutionRequest(env=...)` or `SubprocessRunner(env_allowlist=...)`, while interpreter-hijacking variables (`LD_PRELOAD`, `PYTHONPATH`, `PYTHONSTARTUP`, etc.) are blocked.
18
+ - **Workspace & Path Hardening**: child processes execute with `cwd` locked to the ephemeral sandbox directory, temporary directories redirected inside the workspace, strict validation against path traversal in file/venv names, and strict PEP 508 validation on package specifiers (blocking pip flags, VCS URLs, and local paths).
19
+ - **Resource & Process-Tree Guardrails**: bounded `stdout`/`stderr` capture (`max_output_bytes`) prevents memory exhaustion, `stdin=DEVNULL` prevents interactive hangs, host workspace paths are redacted from `stderr`/tool errors, and timeouts terminate the entire process tree.
20
+
21
+ > **Important boundary:** Python virtualenvs and static AST inspection are **not** a substitute for kernel-level OS isolation. If your deployment runs **untrusted or adversarial multi-tenant code**, run CodeShield inside an OS-level sandbox such as Docker (with `--network=none`, `--read-only`, dropped capabilities, and memory/CPU limits), gVisor, Kata Containers, or Firecracker microVMs.
22
+
23
+ ## Reporting a Vulnerability
24
+
25
+ Please **do not** open a public GitHub issue for suspected security vulnerabilities.
26
+
27
+ Instead, report vulnerabilities privately via GitHub Security Advisories:
28
+
29
+ - [Report a vulnerability privately](https://github.com/AlgorithmicMind/codeshield/security/advisories/new)
30
+
31
+ Include a concise description of the issue, affected version, reproduction steps, and potential impact. We aim to acknowledge reports within 72 hours and coordinate a fix before public disclosure.
@@ -4,13 +4,13 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "codeshield-runtime"
7
- version = "0.1.3"
7
+ version = "0.2.0"
8
8
  description = "A secure, isolated, and self-healing Python code execution engine powered by uv and AST analysis."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
11
11
  requires-python = ">=3.10"
12
12
  authors = [
13
- { name = "Senior Python Core Engineer" },
13
+ { name = "AlgorithmicMind" },
14
14
  ]
15
15
  keywords = ["code", "execution", "sandbox", "self-healing", "ast", "uv"]
16
16
  classifiers = [
@@ -46,6 +46,9 @@ dev = [
46
46
  "twine>=5.0.0",
47
47
  ]
48
48
 
49
+ [project.scripts]
50
+ codeshield = "codeshield.cli:main"
51
+
49
52
  [project.urls]
50
53
  Homepage = "https://github.com/AlgorithmicMind/codeshield"
51
54
  Repository = "https://github.com/AlgorithmicMind/codeshield"
@@ -59,6 +62,7 @@ include = [
59
62
  "/src",
60
63
  "/tests",
61
64
  "/README.md",
65
+ "/SECURITY.md",
62
66
  "/LICENSE",
63
67
  "/pyproject.toml",
64
68
  ]
@@ -1,46 +1,48 @@
1
- """CodeShield.
2
-
3
- A secure, isolated, and self-healing Python code execution engine.
4
- """
5
-
6
- __version__ = "0.1.3"
7
-
8
- from codeshield.analyzer import validate_syntax_and_safety
9
- from codeshield.classifier import TracebackClassifier
10
- from codeshield.environment import SandboxError, SandboxManager
11
- from codeshield.loop import (
12
- ASTSecurityError,
13
- GeminiPatchGenerator,
14
- LLMPatchError,
15
- SelfHealingEngine,
16
- SelfHealingError,
17
- )
18
- from codeshield.runner import SubprocessRunner, SubprocessRunnerError
19
- from codeshield.schemas import (
20
- CodeExecutionRequest,
21
- ErrorDiagnosis,
22
- ExecutionResult,
23
- PatchProposal,
24
- ValidationReport,
25
- )
26
- from codeshield.tools import create_code_execution_tool
27
-
28
- __all__ = [
29
- "ASTSecurityError",
30
- "CodeExecutionRequest",
31
- "ErrorDiagnosis",
32
- "ExecutionResult",
33
- "GeminiPatchGenerator",
34
- "LLMPatchError",
35
- "PatchProposal",
36
- "SandboxError",
37
- "SandboxManager",
38
- "SelfHealingEngine",
39
- "SelfHealingError",
40
- "SubprocessRunner",
41
- "SubprocessRunnerError",
42
- "TracebackClassifier",
43
- "ValidationReport",
44
- "create_code_execution_tool",
45
- "validate_syntax_and_safety",
46
- ]
1
+ """CodeShield.
2
+
3
+ A secure, isolated, and self-healing Python code execution engine.
4
+ """
5
+
6
+ __version__ = "0.2.0"
7
+
8
+ from codeshield.analyzer import validate_syntax_and_safety
9
+ from codeshield.classifier import TracebackClassifier
10
+ from codeshield.environment import SandboxError, SandboxManager
11
+ from codeshield.loop import (
12
+ DEFAULT_GEMINI_MODEL,
13
+ ASTSecurityError,
14
+ GeminiPatchGenerator,
15
+ LLMPatchError,
16
+ SelfHealingEngine,
17
+ SelfHealingError,
18
+ )
19
+ from codeshield.runner import SubprocessRunner, SubprocessRunnerError
20
+ from codeshield.schemas import (
21
+ CodeExecutionRequest,
22
+ ErrorDiagnosis,
23
+ ExecutionResult,
24
+ PatchProposal,
25
+ ValidationReport,
26
+ )
27
+ from codeshield.tools import create_code_execution_tool
28
+
29
+ __all__ = [
30
+ "ASTSecurityError",
31
+ "CodeExecutionRequest",
32
+ "DEFAULT_GEMINI_MODEL",
33
+ "ErrorDiagnosis",
34
+ "ExecutionResult",
35
+ "GeminiPatchGenerator",
36
+ "LLMPatchError",
37
+ "PatchProposal",
38
+ "SandboxError",
39
+ "SandboxManager",
40
+ "SelfHealingEngine",
41
+ "SelfHealingError",
42
+ "SubprocessRunner",
43
+ "SubprocessRunnerError",
44
+ "TracebackClassifier",
45
+ "ValidationReport",
46
+ "create_code_execution_tool",
47
+ "validate_syntax_and_safety",
48
+ ]