vlambda 1.0.0__tar.gz → 1.0.1__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.
- {vlambda-1.0.0 → vlambda-1.0.1}/PKG-INFO +2 -2
- {vlambda-1.0.0 → vlambda-1.0.1}/README.md +1 -1
- {vlambda-1.0.0 → vlambda-1.0.1}/pyproject.toml +1 -1
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/sandbox.py +11 -1
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/version.py +1 -1
- {vlambda-1.0.0 → vlambda-1.0.1}/tests/test_unit.py +8 -5
- {vlambda-1.0.0 → vlambda-1.0.1}/tests/test_vlambda.py +85 -1
- {vlambda-1.0.0 → vlambda-1.0.1}/vcraft.toml +1 -1
- {vlambda-1.0.0 → vlambda-1.0.1}/LICENSE +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/__init__.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/__main__.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/assets.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/async_support.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/auth.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/backup.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/broker.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/cache.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/capabilities.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/cli.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/cron.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/dbpool.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/egress_store.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/env.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/forkd.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/kv_store.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/lifecycle.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/metrics.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/openapi.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/packages.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/pool.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/project.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/py.typed +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/request.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/reset.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/response.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/runner.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/sandbox_os.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/schedules.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/schema.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/selfcheck.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/shared_cache.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/sqlite_compat.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/tasks.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/python/vlambda/transfer.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/src/vlambda_native.v +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/tests/conftest.py +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/v.mod +0 -0
- {vlambda-1.0.0 → vlambda-1.0.1}/vcraft_build.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vlambda
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: An ASGI-like server for Python lambdas, written in V.
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: >=3.14
|
|
@@ -397,7 +397,7 @@ module stays blocked because it exposes sockets indirectly.
|
|
|
397
397
|
|
|
398
398
|
Safe builtins: `abs`, `all`, `any`, `bool`, `dict`, `enumerate`, `filter`, `float`, `int`, `len`, `list`, `map`, `max`, `min`, `range`, `reversed`, `round`, `set`, `sorted`, `str`, `sum`, `tuple`, `zip`, `print`, etc.
|
|
399
399
|
|
|
400
|
-
Blocked modules: `os`, `posix`, `subprocess`, `sys`, `importlib`, `ctypes`, `socket`, `_socket`, `urllib
|
|
400
|
+
Blocked modules: `os`, `posix`, `subprocess`, `sys`, `importlib`, `ctypes`, `socket`, `_socket`, `urllib` (except `urllib.parse`), `http`, `shutil`, `pathlib`, `io`, `pickle`, `marshal`, `resource`, `fcntl`, `mmap`, `sqlite3`, etc.
|
|
401
401
|
|
|
402
402
|
Safe modules: `json`, `math`, `re`, `datetime`, `collections`, `itertools`, `functools`, `hashlib`, `base64`, `string`, `random`, `statistics`, etc.
|
|
403
403
|
|
|
@@ -386,7 +386,7 @@ module stays blocked because it exposes sockets indirectly.
|
|
|
386
386
|
|
|
387
387
|
Safe builtins: `abs`, `all`, `any`, `bool`, `dict`, `enumerate`, `filter`, `float`, `int`, `len`, `list`, `map`, `max`, `min`, `range`, `reversed`, `round`, `set`, `sorted`, `str`, `sum`, `tuple`, `zip`, `print`, etc.
|
|
388
388
|
|
|
389
|
-
Blocked modules: `os`, `posix`, `subprocess`, `sys`, `importlib`, `ctypes`, `socket`, `_socket`, `urllib
|
|
389
|
+
Blocked modules: `os`, `posix`, `subprocess`, `sys`, `importlib`, `ctypes`, `socket`, `_socket`, `urllib` (except `urllib.parse`), `http`, `shutil`, `pathlib`, `io`, `pickle`, `marshal`, `resource`, `fcntl`, `mmap`, `sqlite3`, etc.
|
|
390
390
|
|
|
391
391
|
Safe modules: `json`, `math`, `re`, `datetime`, `collections`, `itertools`, `functools`, `hashlib`, `base64`, `string`, `random`, `statistics`, etc.
|
|
392
392
|
|
|
@@ -21,11 +21,21 @@ BLOCKED_MODULES = {
|
|
|
21
21
|
"sqlite3", "dbm", "shelve", "sysconfig", "site", "platform",
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
# Small pure standard-library submodules that are safe even though their parent
|
|
25
|
+
# package is blocked. Keep this list short and review any addition carefully.
|
|
26
|
+
ALLOWED_SUBMODULES = {
|
|
27
|
+
"urllib.parse",
|
|
28
|
+
"urllib.error",
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
|
|
25
32
|
def blocked_import(name, *args, **kwargs):
|
|
26
33
|
base = name.split(".")[0]
|
|
27
34
|
if base in BLOCKED_MODULES:
|
|
28
|
-
|
|
35
|
+
if name not in ALLOWED_SUBMODULES and not any(
|
|
36
|
+
name.startswith(prefix + ".") for prefix in ALLOWED_SUBMODULES
|
|
37
|
+
):
|
|
38
|
+
raise ImportError(f"module '{name}' is not allowed")
|
|
29
39
|
# Allow safe modules
|
|
30
40
|
import importlib
|
|
31
41
|
return importlib.import_module(name)
|
|
@@ -27,9 +27,12 @@ def test_sandbox_blocked_module():
|
|
|
27
27
|
blocked_import(module)
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
def
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
def test_sandbox_safe_submodule():
|
|
31
|
+
assert blocked_import("urllib.parse") is not None
|
|
32
|
+
with pytest.raises(ImportError):
|
|
33
|
+
blocked_import("urllib.request")
|
|
34
|
+
with pytest.raises(ImportError):
|
|
35
|
+
blocked_import("urllib")
|
|
33
36
|
|
|
34
37
|
|
|
35
38
|
def test_sandbox_missing_handler():
|
|
@@ -1712,7 +1715,7 @@ def test_encrypted_backup_roundtrip(tmp_path, monkeypatch):
|
|
|
1712
1715
|
archive = tmp_path / "backup.tar.gz.enc"
|
|
1713
1716
|
|
|
1714
1717
|
manifest = create_backup(
|
|
1715
|
-
str(archive), db_path=str(db), projects_dir=str(projects), encrypt=True,
|
|
1718
|
+
str(archive), db_path=str(db), metrics_db=str(tmp_path / "missing.db"), projects_dir=str(projects), encrypt=True,
|
|
1716
1719
|
)
|
|
1717
1720
|
assert manifest["encrypted"] is True
|
|
1718
1721
|
assert is_encrypted(str(archive))
|
|
@@ -1721,7 +1724,7 @@ def test_encrypted_backup_roundtrip(tmp_path, monkeypatch):
|
|
|
1721
1724
|
db.unlink()
|
|
1722
1725
|
shutil.rmtree(projects)
|
|
1723
1726
|
result = restore_backup(
|
|
1724
|
-
str(archive), db_path=str(db), projects_dir=str(projects),
|
|
1727
|
+
str(archive), db_path=str(db), metrics_db=str(tmp_path / "missing.db"), projects_dir=str(projects),
|
|
1725
1728
|
)
|
|
1726
1729
|
assert result["encrypted"] is True
|
|
1727
1730
|
assert (projects / "main.py").read_text(encoding="utf-8") == "print('encrypted')\n"
|
|
@@ -299,6 +299,24 @@ def test_request_path_excludes_query():
|
|
|
299
299
|
assert body["query"] == {"a": "1", "b": "two"}, body
|
|
300
300
|
|
|
301
301
|
|
|
302
|
+
def test_sandbox_urllib_parse():
|
|
303
|
+
token = test_register_login()
|
|
304
|
+
code = "from urllib.parse import urlparse\ndef handler(request): return {'path': urlparse(request.path).path}"
|
|
305
|
+
status, body = req("POST", "/vlambda", code, token)
|
|
306
|
+
assert status == 201, body
|
|
307
|
+
slug = body["slug"]
|
|
308
|
+
status, body = req("GET", f"/f/{slug}?a=1")
|
|
309
|
+
assert status == 200 and body["path"] == f"/f/{slug}", body
|
|
310
|
+
|
|
311
|
+
status, body = req("POST", "/vlambda",
|
|
312
|
+
"import urllib.request\ndef handler(request): return {}", token)
|
|
313
|
+
assert status in (201, 400), body
|
|
314
|
+
if status == 201:
|
|
315
|
+
slug = body["slug"]
|
|
316
|
+
status, body = req("GET", f"/f/{slug}")
|
|
317
|
+
assert status == 500 and "not allowed" in body.get("error", ""), body
|
|
318
|
+
|
|
319
|
+
|
|
302
320
|
def test_sensitive_headers_hidden():
|
|
303
321
|
import urllib.request
|
|
304
322
|
|
|
@@ -1945,6 +1963,71 @@ def test_audit_log():
|
|
|
1945
1963
|
assert "old.action" not in [item["action"] for item in body["entries"]]
|
|
1946
1964
|
|
|
1947
1965
|
|
|
1966
|
+
def test_examples_smoke():
|
|
1967
|
+
import base64, io, os, zipfile
|
|
1968
|
+
|
|
1969
|
+
stop_server()
|
|
1970
|
+
start_server({"VLAMBDA_RATE_LIMIT": "100000"}, max_body=10000)
|
|
1971
|
+
token = test_register_login()
|
|
1972
|
+
root = os.path.join(os.environ.get("VLAMBDA_BASE", os.getcwd()), "examples")
|
|
1973
|
+
if not os.path.isdir(root):
|
|
1974
|
+
root = os.path.join(os.getcwd(), "..", "examples")
|
|
1975
|
+
root = os.path.abspath(root)
|
|
1976
|
+
|
|
1977
|
+
def deploy_code(name, rel, method="GET"):
|
|
1978
|
+
with open(os.path.join(root, rel), encoding="utf-8") as f:
|
|
1979
|
+
code = f.read()
|
|
1980
|
+
status, body = req("POST", f"/vlambda?name={name}&method={method}", code, token)
|
|
1981
|
+
assert status == 201, (name, status, body)
|
|
1982
|
+
return body["slug"]
|
|
1983
|
+
|
|
1984
|
+
slug = deploy_code("hello", "hello/main.py")
|
|
1985
|
+
status, body = req("GET", f"/f/{slug}")
|
|
1986
|
+
assert status == 200 and body["msg"] == "hello from vlambda", body
|
|
1987
|
+
|
|
1988
|
+
slug = deploy_code("async", "async/main.py")
|
|
1989
|
+
status, body = req("GET", f"/f/{slug}")
|
|
1990
|
+
assert status == 200 and body["async"] is True and len(body["items"]) == 3, body
|
|
1991
|
+
|
|
1992
|
+
slug = deploy_code("htmlfetch", "html-fetch/main.py")
|
|
1993
|
+
status, html = req("GET", f"/f/{slug}")
|
|
1994
|
+
assert status == 200
|
|
1995
|
+
import urllib.request
|
|
1996
|
+
html = urllib.request.urlopen(f"http://localhost:{PORT}/f/{slug}").read().decode()
|
|
1997
|
+
assert "<h1>vlambda fetch demo</h1>" in html
|
|
1998
|
+
status, body = req("GET", f"/f/{slug}/api")
|
|
1999
|
+
assert status == 200 and body["items"] == ["alpha", "beta", "gamma"], body
|
|
2000
|
+
|
|
2001
|
+
slug = deploy_code("jsonapi", "json-api/main.py")
|
|
2002
|
+
status, body = req("GET", f"/f/{slug}?x=1")
|
|
2003
|
+
assert status == 200 and body["ok"] is True and body["query"] == "x=1", body
|
|
2004
|
+
|
|
2005
|
+
slug = deploy_code("webhook", "webhook/main.py", "POST")
|
|
2006
|
+
status, body = req("POST", f"/f/{slug}", '{"a": 1}',
|
|
2007
|
+
extra_headers={"Content-Type": "application/json"})
|
|
2008
|
+
assert status == 200 and body["received"] is True, body
|
|
2009
|
+
|
|
2010
|
+
buf = io.BytesIO()
|
|
2011
|
+
with zipfile.ZipFile(buf, "w") as z:
|
|
2012
|
+
for dirpath, _, files in os.walk(os.path.join(root, "static-site")):
|
|
2013
|
+
for name in files:
|
|
2014
|
+
full = os.path.join(dirpath, name)
|
|
2015
|
+
rel = os.path.relpath(full, os.path.join(root, "static-site"))
|
|
2016
|
+
z.writestr(rel, open(full, "rb").read())
|
|
2017
|
+
status, body = req("POST", "/vlambda?project=1&entry=main.py&name=static-site",
|
|
2018
|
+
base64.b64encode(buf.getvalue()).decode(), token)
|
|
2019
|
+
assert status == 201, body
|
|
2020
|
+
slug = body["slug"]
|
|
2021
|
+
html = urllib.request.urlopen(f"http://localhost:{PORT}/f/{slug}/").read()
|
|
2022
|
+
assert b"<h1>Static site on vlambda</h1>" in html
|
|
2023
|
+
css = urllib.request.urlopen(f"http://localhost:{PORT}/f/{slug}/style.css").read()
|
|
2024
|
+
assert b"font-family" in css
|
|
2025
|
+
js = urllib.request.urlopen(f"http://localhost:{PORT}/f/{slug}/app.js").read()
|
|
2026
|
+
assert b"ping" in js
|
|
2027
|
+
status, body = req("GET", f"/f/{slug}/api/ping")
|
|
2028
|
+
assert status == 200 and body["ok"] is True, body
|
|
2029
|
+
|
|
2030
|
+
|
|
1948
2031
|
def test_project_static_files():
|
|
1949
2032
|
token, slug = _upload_project("static", {
|
|
1950
2033
|
"main.py": "def handler(request):\n return {'path': request.path}\n",
|
|
@@ -2061,7 +2144,7 @@ def test_fuzz_smoke():
|
|
|
2061
2144
|
|
|
2062
2145
|
|
|
2063
2146
|
if __name__ == "__main__":
|
|
2064
|
-
tests = [test_health, test_ui_assets, test_favicon_only_for_ui, test_register_login, test_registration_controls, test_password_policy, test_registration_limit, test_create_invoke, test_trust_proxy_client_ip, test_request_path_excludes_query, test_sensitive_headers_hidden, test_async_handler, test_lambda_names, test_response_contract, test_status_body_dict_is_data, test_header_responses_not_cached, test_response_binary, test_lambda_env, test_lambda_kv, test_async_kv, test_kv_fork_project, test_egress_fetch, test_schedules, test_openapi, test_openapi_public, test_response_injection_blocked, test_html_lambda, test_auth_required,
|
|
2147
|
+
tests = [test_health, test_ui_assets, test_favicon_only_for_ui, test_register_login, test_registration_controls, test_password_policy, test_registration_limit, test_create_invoke, test_sandbox_urllib_parse, test_trust_proxy_client_ip, test_request_path_excludes_query, test_sensitive_headers_hidden, test_async_handler, test_lambda_names, test_response_contract, test_status_body_dict_is_data, test_header_responses_not_cached, test_response_binary, test_lambda_env, test_lambda_kv, test_async_kv, test_kv_fork_project, test_egress_fetch, test_schedules, test_openapi, test_openapi_public, test_response_injection_blocked, test_html_lambda, test_auth_required,
|
|
2065
2148
|
test_update, test_update_preserves_limits, test_delete, test_delete_cleans_lambda_state, test_validation, test_metrics, test_body_size,
|
|
2066
2149
|
test_method_mismatch, test_pagination, test_ownership, test_project_zip,
|
|
2067
2150
|
test_project_rejects_dependency_urls,
|
|
@@ -2074,6 +2157,7 @@ if __name__ == "__main__":
|
|
|
2074
2157
|
test_sandbox_blocked, test_system_endpoints, test_admin_reset, test_bytes_result, test_request_body_echo, test_packages, test_metrics_aggregate_endpoint, test_lambda_logs, test_delete_metrics_and_logs,
|
|
2075
2158
|
test_project_dependencies_are_private,
|
|
2076
2159
|
test_cors_headers, test_json_listing, test_api_tokens, test_password_change, test_audit_log, test_security_regressions, test_sandbox_runtime_coverage, test_project_static_files,
|
|
2160
|
+
test_examples_smoke,
|
|
2077
2161
|
test_export_import_duplicate, test_project_export_import,
|
|
2078
2162
|
test_concurrency, test_failure_isolation, test_fuzz_smoke, test_rate_limit]
|
|
2079
2163
|
failed = 0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|