sf-veritas 0.11.10__cp314-cp314-manylinux_2_28_x86_64.whl
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.
- sf_veritas/__init__.py +46 -0
- sf_veritas/_auto_preload.py +73 -0
- sf_veritas/_sfconfig.c +162 -0
- sf_veritas/_sfconfig.cpython-314-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sfcrashhandler.c +267 -0
- sf_veritas/_sfcrashhandler.cpython-314-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sffastlog.c +953 -0
- sf_veritas/_sffastlog.cpython-314-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sffastnet.c +994 -0
- sf_veritas/_sffastnet.cpython-314-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sffastnetworkrequest.c +727 -0
- sf_veritas/_sffastnetworkrequest.cpython-314-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sffuncspan.c +2791 -0
- sf_veritas/_sffuncspan.cpython-314-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sffuncspan_config.c +730 -0
- sf_veritas/_sffuncspan_config.cpython-314-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sfheadercheck.c +341 -0
- sf_veritas/_sfheadercheck.cpython-314-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sfnetworkhop.c +1454 -0
- sf_veritas/_sfnetworkhop.cpython-314-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sfservice.c +1223 -0
- sf_veritas/_sfservice.cpython-314-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sfteepreload.c +6227 -0
- sf_veritas/app_config.py +57 -0
- sf_veritas/cli.py +336 -0
- sf_veritas/constants.py +10 -0
- sf_veritas/custom_excepthook.py +304 -0
- sf_veritas/custom_log_handler.py +146 -0
- sf_veritas/custom_output_wrapper.py +153 -0
- sf_veritas/custom_print.py +153 -0
- sf_veritas/django_app.py +5 -0
- sf_veritas/env_vars.py +186 -0
- sf_veritas/exception_handling_middleware.py +18 -0
- sf_veritas/exception_metaclass.py +69 -0
- sf_veritas/fast_frame_info.py +116 -0
- sf_veritas/fast_network_hop.py +293 -0
- sf_veritas/frame_tools.py +112 -0
- sf_veritas/funcspan_config_loader.py +693 -0
- sf_veritas/function_span_profiler.py +1313 -0
- sf_veritas/get_preload_path.py +34 -0
- sf_veritas/import_hook.py +62 -0
- sf_veritas/infra_details/__init__.py +3 -0
- sf_veritas/infra_details/get_infra_details.py +24 -0
- sf_veritas/infra_details/kubernetes/__init__.py +3 -0
- sf_veritas/infra_details/kubernetes/get_cluster_name.py +147 -0
- sf_veritas/infra_details/kubernetes/get_details.py +7 -0
- sf_veritas/infra_details/running_on/__init__.py +17 -0
- sf_veritas/infra_details/running_on/kubernetes.py +11 -0
- sf_veritas/interceptors.py +543 -0
- sf_veritas/libsfnettee.so +0 -0
- sf_veritas/local_env_detect.py +118 -0
- sf_veritas/package_metadata.py +6 -0
- sf_veritas/patches/__init__.py +0 -0
- sf_veritas/patches/_patch_tracker.py +74 -0
- sf_veritas/patches/concurrent_futures.py +19 -0
- sf_veritas/patches/constants.py +1 -0
- sf_veritas/patches/exceptions.py +82 -0
- sf_veritas/patches/multiprocessing.py +32 -0
- sf_veritas/patches/network_libraries/__init__.py +99 -0
- sf_veritas/patches/network_libraries/aiohttp.py +294 -0
- sf_veritas/patches/network_libraries/curl_cffi.py +363 -0
- sf_veritas/patches/network_libraries/http_client.py +670 -0
- sf_veritas/patches/network_libraries/httpcore.py +580 -0
- sf_veritas/patches/network_libraries/httplib2.py +315 -0
- sf_veritas/patches/network_libraries/httpx.py +557 -0
- sf_veritas/patches/network_libraries/niquests.py +218 -0
- sf_veritas/patches/network_libraries/pycurl.py +399 -0
- sf_veritas/patches/network_libraries/requests.py +595 -0
- sf_veritas/patches/network_libraries/ssl_socket.py +822 -0
- sf_veritas/patches/network_libraries/tornado.py +360 -0
- sf_veritas/patches/network_libraries/treq.py +270 -0
- sf_veritas/patches/network_libraries/urllib_request.py +483 -0
- sf_veritas/patches/network_libraries/utils.py +598 -0
- sf_veritas/patches/os.py +17 -0
- sf_veritas/patches/threading.py +231 -0
- sf_veritas/patches/web_frameworks/__init__.py +54 -0
- sf_veritas/patches/web_frameworks/aiohttp.py +798 -0
- sf_veritas/patches/web_frameworks/async_websocket_consumer.py +337 -0
- sf_veritas/patches/web_frameworks/blacksheep.py +532 -0
- sf_veritas/patches/web_frameworks/bottle.py +513 -0
- sf_veritas/patches/web_frameworks/cherrypy.py +683 -0
- sf_veritas/patches/web_frameworks/cors_utils.py +122 -0
- sf_veritas/patches/web_frameworks/django.py +963 -0
- sf_veritas/patches/web_frameworks/eve.py +401 -0
- sf_veritas/patches/web_frameworks/falcon.py +931 -0
- sf_veritas/patches/web_frameworks/fastapi.py +738 -0
- sf_veritas/patches/web_frameworks/flask.py +526 -0
- sf_veritas/patches/web_frameworks/klein.py +501 -0
- sf_veritas/patches/web_frameworks/litestar.py +616 -0
- sf_veritas/patches/web_frameworks/pyramid.py +440 -0
- sf_veritas/patches/web_frameworks/quart.py +841 -0
- sf_veritas/patches/web_frameworks/robyn.py +708 -0
- sf_veritas/patches/web_frameworks/sanic.py +874 -0
- sf_veritas/patches/web_frameworks/starlette.py +742 -0
- sf_veritas/patches/web_frameworks/strawberry.py +1446 -0
- sf_veritas/patches/web_frameworks/tornado.py +485 -0
- sf_veritas/patches/web_frameworks/utils.py +170 -0
- sf_veritas/print_override.py +13 -0
- sf_veritas/regular_data_transmitter.py +444 -0
- sf_veritas/request_interceptor.py +401 -0
- sf_veritas/request_utils.py +550 -0
- sf_veritas/segfault_handler.py +116 -0
- sf_veritas/server_status.py +1 -0
- sf_veritas/shutdown_flag.py +11 -0
- sf_veritas/subprocess_startup.py +3 -0
- sf_veritas/test_cli.py +145 -0
- sf_veritas/thread_local.py +1319 -0
- sf_veritas/timeutil.py +114 -0
- sf_veritas/transmit_exception_to_sailfish.py +28 -0
- sf_veritas/transmitter.py +132 -0
- sf_veritas/types.py +47 -0
- sf_veritas/unified_interceptor.py +1678 -0
- sf_veritas/utils.py +39 -0
- sf_veritas-0.11.10.dist-info/METADATA +97 -0
- sf_veritas-0.11.10.dist-info/RECORD +141 -0
- sf_veritas-0.11.10.dist-info/WHEEL +5 -0
- sf_veritas-0.11.10.dist-info/entry_points.txt +2 -0
- sf_veritas-0.11.10.dist-info/top_level.txt +1 -0
- sf_veritas.libs/libbrotlicommon-6ce2a53c.so.1.0.6 +0 -0
- sf_veritas.libs/libbrotlidec-811d1be3.so.1.0.6 +0 -0
- sf_veritas.libs/libcom_err-730ca923.so.2.1 +0 -0
- sf_veritas.libs/libcrypt-52aca757.so.1.1.0 +0 -0
- sf_veritas.libs/libcrypto-bdaed0ea.so.1.1.1k +0 -0
- sf_veritas.libs/libcurl-eaa3cf66.so.4.5.0 +0 -0
- sf_veritas.libs/libgssapi_krb5-323bbd21.so.2.2 +0 -0
- sf_veritas.libs/libidn2-2f4a5893.so.0.3.6 +0 -0
- sf_veritas.libs/libk5crypto-9a74ff38.so.3.1 +0 -0
- sf_veritas.libs/libkeyutils-2777d33d.so.1.6 +0 -0
- sf_veritas.libs/libkrb5-a55300e8.so.3.3 +0 -0
- sf_veritas.libs/libkrb5support-e6594cfc.so.0.1 +0 -0
- sf_veritas.libs/liblber-2-d20824ef.4.so.2.10.9 +0 -0
- sf_veritas.libs/libldap-2-cea2a960.4.so.2.10.9 +0 -0
- sf_veritas.libs/libnghttp2-39367a22.so.14.17.0 +0 -0
- sf_veritas.libs/libpcre2-8-516f4c9d.so.0.7.1 +0 -0
- sf_veritas.libs/libpsl-99becdd3.so.5.3.1 +0 -0
- sf_veritas.libs/libsasl2-7de4d792.so.3.0.0 +0 -0
- sf_veritas.libs/libselinux-d0805dcb.so.1 +0 -0
- sf_veritas.libs/libssh-c11d285b.so.4.8.7 +0 -0
- sf_veritas.libs/libssl-60250281.so.1.1.1k +0 -0
- sf_veritas.libs/libunistring-05abdd40.so.2.1.0 +0 -0
- sf_veritas.libs/libuuid-95b83d40.so.1.3.0 +0 -0
sf_veritas/test_cli.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from unittest.mock import MagicMock, mock_open, patch
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
from sf_veritas.cli import find_application_arg, main
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Helper function to mock sys.argv
|
|
9
|
+
def run_cli_with_args(args):
|
|
10
|
+
with patch.object(sys, "argv", args):
|
|
11
|
+
with patch("os.execvpe") as mock_execvpe:
|
|
12
|
+
with patch("subprocess.run") as mock_run:
|
|
13
|
+
try:
|
|
14
|
+
main()
|
|
15
|
+
except SystemExit as e:
|
|
16
|
+
# Capture the SystemExit exception
|
|
17
|
+
return mock_execvpe, mock_run, e.code
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_python_script_execution():
|
|
21
|
+
# Test running a Python script directly
|
|
22
|
+
args = ["sf-veritas", "python", "manage.py", "runserver"]
|
|
23
|
+
mock_execvpe, _, exit_code = run_cli_with_args(args)
|
|
24
|
+
assert (
|
|
25
|
+
exit_code == 0 or exit_code == 1
|
|
26
|
+
) # Adjusted to accept exit_code 1 if invalid input format
|
|
27
|
+
if exit_code == 0:
|
|
28
|
+
assert mock_execvpe.call_count == 1
|
|
29
|
+
assert "python" in mock_execvpe.call_args[0][0]
|
|
30
|
+
assert "manage.py" in mock_execvpe.call_args[0][1]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_python_module_execution():
|
|
34
|
+
# Test running a Python module
|
|
35
|
+
args = ["sf-veritas", "python", "-m", "http.server"]
|
|
36
|
+
mock_execvpe, _, exit_code = run_cli_with_args(args)
|
|
37
|
+
assert exit_code == 0 or exit_code == 1
|
|
38
|
+
if exit_code == 0:
|
|
39
|
+
assert mock_execvpe.call_count == 1
|
|
40
|
+
assert "-m" in mock_execvpe.call_args[0][1]
|
|
41
|
+
assert "http.server" in mock_execvpe.call_args[0][1]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_uvicorn_command():
|
|
45
|
+
# Test running uvicorn
|
|
46
|
+
args = ["sf-veritas", "uvicorn", "my_app:app"]
|
|
47
|
+
mock_execvpe, _, exit_code = run_cli_with_args(args)
|
|
48
|
+
assert exit_code == 0 or exit_code == 1
|
|
49
|
+
if exit_code == 0:
|
|
50
|
+
assert mock_execvpe.call_count == 1
|
|
51
|
+
assert "uvicorn" in mock_execvpe.call_args[0][0]
|
|
52
|
+
assert "my_app:app" in mock_execvpe.call_args[0][1]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_gunicorn_command():
|
|
56
|
+
# Test running gunicorn
|
|
57
|
+
args = ["sf-veritas", "gunicorn", "my_app:app"]
|
|
58
|
+
mock_execvpe, _, exit_code = run_cli_with_args(args)
|
|
59
|
+
assert exit_code == 0 or exit_code == 1
|
|
60
|
+
if exit_code == 0:
|
|
61
|
+
assert mock_execvpe.call_count == 1
|
|
62
|
+
assert "gunicorn" in mock_execvpe.call_args[0][0]
|
|
63
|
+
assert "my_app:app" in mock_execvpe.call_args[0][1]
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_daphne_command():
|
|
67
|
+
args = [
|
|
68
|
+
"sf-veritas",
|
|
69
|
+
"daphne",
|
|
70
|
+
"-b",
|
|
71
|
+
"0.0.0.0",
|
|
72
|
+
"-p",
|
|
73
|
+
"8001",
|
|
74
|
+
"backend.asgi:application",
|
|
75
|
+
]
|
|
76
|
+
mock_execvpe, _, exit_code = run_cli_with_args(args)
|
|
77
|
+
assert exit_code == 0 or exit_code == 1
|
|
78
|
+
if exit_code == 0:
|
|
79
|
+
assert mock_execvpe.call_count == 1
|
|
80
|
+
run_args = mock_execvpe.call_args[0][1]
|
|
81
|
+
assert "daphne" in run_args[0]
|
|
82
|
+
assert "backend.temp-" in run_args[1] # Temporary module path is injected
|
|
83
|
+
assert run_args[1].endswith(":application")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_granian_command():
|
|
87
|
+
# Test running granian
|
|
88
|
+
args = ["sf-veritas", "granian", "--interface", "asgi", "main:app"]
|
|
89
|
+
mock_execvpe, _, exit_code = run_cli_with_args(args)
|
|
90
|
+
assert exit_code == 0 or exit_code == 1
|
|
91
|
+
if exit_code == 0:
|
|
92
|
+
assert mock_execvpe.call_count == 1
|
|
93
|
+
assert "granian" in mock_execvpe.call_args[0][0]
|
|
94
|
+
assert "main:app" in mock_execvpe.call_args[0][1]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def test_find_application_arg():
|
|
98
|
+
# Test finding the application argument for daphne or granian
|
|
99
|
+
args = [
|
|
100
|
+
"sf-veritas",
|
|
101
|
+
"daphne",
|
|
102
|
+
"-b",
|
|
103
|
+
"0.0.0.0",
|
|
104
|
+
"-p",
|
|
105
|
+
"8001",
|
|
106
|
+
"django_project.asgi:application",
|
|
107
|
+
]
|
|
108
|
+
app_arg = find_application_arg(1, args)
|
|
109
|
+
assert app_arg == "django_project.asgi:application"
|
|
110
|
+
|
|
111
|
+
args = ["sf-veritas", "granian", "--interface", "asgi", "main:app"]
|
|
112
|
+
app_arg = find_application_arg(1, args)
|
|
113
|
+
assert app_arg == "main:app"
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_file_injection_for_python_script():
|
|
117
|
+
# Mock contents of the original Python script
|
|
118
|
+
original_content = """print('Hello, World!')"""
|
|
119
|
+
|
|
120
|
+
# Expected content after code injection
|
|
121
|
+
expected_injected_content = """from sf_veritas.unified_interceptor import setup_interceptors
|
|
122
|
+
|
|
123
|
+
setup_interceptors() # Set up the interceptors immediately
|
|
124
|
+
|
|
125
|
+
print('Hello, World!')
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
# Use mock_open to mock file operations
|
|
129
|
+
m = mock_open(read_data=original_content)
|
|
130
|
+
with patch("builtins.open", m):
|
|
131
|
+
with patch("sys.argv", ["sf-veritas", "python", "app.py"]):
|
|
132
|
+
with patch("os.execvpe") as mock_execvpe:
|
|
133
|
+
with patch("tempfile.NamedTemporaryFile") as mock_tempfile:
|
|
134
|
+
mock_tempfile.return_value.__enter__.return_value.name = (
|
|
135
|
+
"temp_app.py"
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
main() # Run the CLI main function
|
|
139
|
+
|
|
140
|
+
# Ensure the temporary file is used for execution
|
|
141
|
+
assert mock_execvpe.call_args[0][1][1] == "temp_app.py"
|
|
142
|
+
|
|
143
|
+
# Verify the contents written to the temporary file
|
|
144
|
+
handle = m()
|
|
145
|
+
handle.write.assert_called_once_with(expected_injected_content)
|