@vercel/python
Advanced tools
+3
-3
| { | ||
| "name": "@vercel/python", | ||
| "version": "6.18.1", | ||
| "version": "6.19.0", | ||
| "main": "./dist/index.js", | ||
@@ -38,5 +38,5 @@ "license": "Apache-2.0", | ||
| "is-port-reachable": "3.1.0", | ||
| "@vercel/python-runtime": "0.5.3", | ||
| "@vercel/build-utils": "13.6.1", | ||
| "@vercel/error-utils": "2.0.3", | ||
| "@vercel/build-utils": "13.6.1" | ||
| "@vercel/python-runtime": "0.5.3" | ||
| }, | ||
@@ -43,0 +43,0 @@ "scripts": { |
+182
-1
@@ -7,2 +7,4 @@ # Auto-generated template used by vercel dev (Python, ASGI/WSGI) | ||
| import inspect | ||
| import logging | ||
| import logging.config | ||
| from os import path as _p | ||
@@ -27,2 +29,171 @@ from importlib import util as _importlib_util | ||
| # Configure logging to output DEBUG-WARNING to the stdout | ||
| # and ERROR-CRITICAL to the stderr. | ||
| # We need a custom filter for the stdout stream | ||
| # so it won't print anything higher than WARNING. | ||
| class _MaxLevelFilter(logging.Filter): | ||
| def __init__(self, max_level): | ||
| super().__init__() | ||
| self.max_level = max_level | ||
| def filter(self, record): | ||
| return record.levelno <= self.max_level | ||
| def _build_log_config(loggers, _filter_ref=None) -> dict: | ||
| if _filter_ref is None: | ||
| _filter_ref = "vc_init_dev._MaxLevelFilter" | ||
| return { | ||
| "version": 1, | ||
| "disable_existing_loggers": False, | ||
| "filters": { | ||
| "max_warning": { | ||
| "()": _filter_ref, | ||
| "max_level": logging.WARNING, | ||
| } | ||
| }, | ||
| "handlers": { | ||
| "stdout": { | ||
| "class": "logging.StreamHandler", | ||
| "stream": "ext://sys.stdout", | ||
| "filters": ["max_warning"], | ||
| }, | ||
| "stderr": { | ||
| "class": "logging.StreamHandler", | ||
| "stream": "ext://sys.stderr", | ||
| "level": "ERROR", | ||
| }, | ||
| }, | ||
| "loggers": loggers, | ||
| "root": { | ||
| "handlers": ["stdout", "stderr"], | ||
| "level": "INFO", | ||
| }, | ||
| } | ||
| def _setup_server_log_routing(logger_name=None): | ||
| loggers = {} | ||
| if logger_name: | ||
| loggers[logger_name] = { | ||
| "handlers": ["stdout", "stderr"], | ||
| "level": "INFO", | ||
| "propagate": False, | ||
| } | ||
| logging.config.dictConfig( | ||
| _build_log_config( | ||
| loggers=loggers, | ||
| _filter_ref=_MaxLevelFilter, | ||
| ), | ||
| ) | ||
| def _build_uvicorn_log_config(default_fmt=None, access_fmt=None) -> dict: | ||
| try: | ||
| from uvicorn.config import LOGGING_CONFIG # type: ignore | ||
| uvicorn_fmts = LOGGING_CONFIG["formatters"] | ||
| except ImportError: | ||
| uvicorn_fmts = { | ||
| "default": { | ||
| "()": "uvicorn.logging.DefaultFormatter", | ||
| "fmt": "%(levelprefix)s %(message)s", | ||
| "use_colors": None, | ||
| }, | ||
| "access": { | ||
| "()": "uvicorn.logging.AccessFormatter", | ||
| "fmt": '%(levelprefix)s %(client_addr)s - "%(request_line)s" %(status_code)s', | ||
| }, | ||
| } | ||
| cfg = _build_log_config( | ||
| loggers={ | ||
| "uvicorn": { | ||
| "handlers": ["stdout", "stderr"], | ||
| "level": "INFO", | ||
| "propagate": False, | ||
| }, | ||
| "uvicorn.error": {"level": "INFO"}, | ||
| "uvicorn.access": { | ||
| "handlers": ["access"], | ||
| "level": "INFO", | ||
| "propagate": False, | ||
| }, | ||
| }, | ||
| ) | ||
| if default_fmt is None: | ||
| default_fmt = {**uvicorn_fmts["default"], "use_colors": not _NO_COLOR} | ||
| if access_fmt is None: | ||
| access_fmt = {**uvicorn_fmts["access"], "use_colors": not _NO_COLOR} | ||
| cfg["formatters"] = {"default": default_fmt, "access": access_fmt} | ||
| cfg["handlers"]["stdout"]["formatter"] = "default" | ||
| cfg["handlers"]["stderr"]["formatter"] = "default" | ||
| cfg["handlers"]["access"] = { | ||
| "class": "logging.StreamHandler", | ||
| "stream": "ext://sys.stdout", | ||
| "formatter": "access", | ||
| } | ||
| return cfg | ||
| def _build_hypercorn_log_config(): | ||
| return _build_log_config( | ||
| loggers={ | ||
| "hypercorn.error": { | ||
| "handlers": ["stdout", "stderr"], | ||
| "level": "INFO", | ||
| "propagate": False, | ||
| }, | ||
| "hypercorn.access": { | ||
| "handlers": ["stdout"], | ||
| "level": "INFO", | ||
| "propagate": False, | ||
| }, | ||
| }, | ||
| ) | ||
| def _patch_fastapi_cli_log_config(): | ||
| try: | ||
| import fastapi_cli.utils.cli as _fcli # type: ignore | ||
| import fastapi_cli.cli as _fcli_cli # type: ignore | ||
| _orig_get_config = _fcli.get_uvicorn_log_config # to ensure it's there | ||
| _fcli_cli.get_uvicorn_log_config # to ensure it's there | ||
| except (ImportError, AttributeError): | ||
| return | ||
| def _get_routed_config(): | ||
| orig = _orig_get_config() | ||
| return _build_uvicorn_log_config( | ||
| default_fmt={ | ||
| "()": "fastapi_cli.utils.cli.CustomFormatter", | ||
| "fmt": orig["formatters"]["default"].get( | ||
| "fmt", "%(levelprefix)s %(message)s" | ||
| ), | ||
| "use_colors": orig["formatters"]["default"].get("use_colors"), | ||
| }, | ||
| access_fmt={ | ||
| "()": "fastapi_cli.utils.cli.CustomFormatter", | ||
| "fmt": orig["formatters"]["access"].get( | ||
| "fmt", | ||
| "%(levelprefix)s %(client_addr)s - '%(request_line)s' %(status_code)s", | ||
| ), | ||
| }, | ||
| ) | ||
| _fcli.get_uvicorn_log_config = _get_routed_config | ||
| # we need to patch the local binding as well | ||
| _fcli_cli.get_uvicorn_log_config = _get_routed_config | ||
| def _normalize_service_route_prefix(raw_prefix): | ||
@@ -76,2 +247,7 @@ if not raw_prefix: | ||
| # Pre-configure the root logger before user module import so that any log | ||
| # calls emitted at import time are routed to stdout/stderr correctly. | ||
| _setup_server_log_routing() | ||
| # ASGI/WSGI app detection | ||
@@ -361,3 +537,4 @@ _MODULE_NAME = "__VC_DEV_MODULE_NAME__" | ||
| run_simple(host, port, wsgi_app, use_reloader=True) | ||
| _setup_server_log_routing("werkzeug") | ||
| run_simple(host, port, wsgi_app, use_reloader=True, threaded=True) | ||
| except Exception: | ||
@@ -383,2 +560,3 @@ print( | ||
| if fastapi_dev is not None: | ||
| _patch_fastapi_cli_log_config() | ||
| fastapi_dev( | ||
@@ -398,2 +576,3 @@ entrypoint="vc_init_dev:asgi_app", host=host, port=port, reload=True | ||
| reload=True, | ||
| log_config=_build_uvicorn_log_config(), | ||
| ) | ||
@@ -408,2 +587,4 @@ except Exception: | ||
| config.bind = [f"{host}:{port}"] | ||
| config.use_reloader = True | ||
| config.logconfig_dict = _build_hypercorn_log_config() | ||
@@ -410,0 +591,0 @@ async def _run(): |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 14 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 14 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
418683
1.33%11941
1.29%