sf-veritas 0.10.3__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.

Potentially problematic release.


This version of sf-veritas might be problematic. Click here for more details.

Files changed (132) hide show
  1. sf_veritas/__init__.py +20 -0
  2. sf_veritas/_sffastlog.c +889 -0
  3. sf_veritas/_sffastlog.cpython-314-x86_64-linux-gnu.so +0 -0
  4. sf_veritas/_sffastnet.c +924 -0
  5. sf_veritas/_sffastnet.cpython-314-x86_64-linux-gnu.so +0 -0
  6. sf_veritas/_sffastnetworkrequest.c +730 -0
  7. sf_veritas/_sffastnetworkrequest.cpython-314-x86_64-linux-gnu.so +0 -0
  8. sf_veritas/_sffuncspan.c +2155 -0
  9. sf_veritas/_sffuncspan.cpython-314-x86_64-linux-gnu.so +0 -0
  10. sf_veritas/_sffuncspan_config.c +617 -0
  11. sf_veritas/_sffuncspan_config.cpython-314-x86_64-linux-gnu.so +0 -0
  12. sf_veritas/_sfheadercheck.c +341 -0
  13. sf_veritas/_sfheadercheck.cpython-314-x86_64-linux-gnu.so +0 -0
  14. sf_veritas/_sfnetworkhop.c +1451 -0
  15. sf_veritas/_sfnetworkhop.cpython-314-x86_64-linux-gnu.so +0 -0
  16. sf_veritas/_sfservice.c +1175 -0
  17. sf_veritas/_sfservice.cpython-314-x86_64-linux-gnu.so +0 -0
  18. sf_veritas/_sfteepreload.c +5167 -0
  19. sf_veritas/app_config.py +49 -0
  20. sf_veritas/cli.py +336 -0
  21. sf_veritas/constants.py +10 -0
  22. sf_veritas/custom_excepthook.py +304 -0
  23. sf_veritas/custom_log_handler.py +129 -0
  24. sf_veritas/custom_output_wrapper.py +144 -0
  25. sf_veritas/custom_print.py +146 -0
  26. sf_veritas/django_app.py +5 -0
  27. sf_veritas/env_vars.py +186 -0
  28. sf_veritas/exception_handling_middleware.py +18 -0
  29. sf_veritas/exception_metaclass.py +69 -0
  30. sf_veritas/fast_frame_info.py +116 -0
  31. sf_veritas/fast_network_hop.py +293 -0
  32. sf_veritas/frame_tools.py +112 -0
  33. sf_veritas/funcspan_config_loader.py +556 -0
  34. sf_veritas/function_span_profiler.py +1174 -0
  35. sf_veritas/import_hook.py +62 -0
  36. sf_veritas/infra_details/__init__.py +3 -0
  37. sf_veritas/infra_details/get_infra_details.py +24 -0
  38. sf_veritas/infra_details/kubernetes/__init__.py +3 -0
  39. sf_veritas/infra_details/kubernetes/get_cluster_name.py +147 -0
  40. sf_veritas/infra_details/kubernetes/get_details.py +7 -0
  41. sf_veritas/infra_details/running_on/__init__.py +17 -0
  42. sf_veritas/infra_details/running_on/kubernetes.py +11 -0
  43. sf_veritas/interceptors.py +497 -0
  44. sf_veritas/libsfnettee.so +0 -0
  45. sf_veritas/local_env_detect.py +118 -0
  46. sf_veritas/package_metadata.py +6 -0
  47. sf_veritas/patches/__init__.py +0 -0
  48. sf_veritas/patches/concurrent_futures.py +19 -0
  49. sf_veritas/patches/constants.py +1 -0
  50. sf_veritas/patches/exceptions.py +82 -0
  51. sf_veritas/patches/multiprocessing.py +32 -0
  52. sf_veritas/patches/network_libraries/__init__.py +76 -0
  53. sf_veritas/patches/network_libraries/aiohttp.py +281 -0
  54. sf_veritas/patches/network_libraries/curl_cffi.py +363 -0
  55. sf_veritas/patches/network_libraries/http_client.py +419 -0
  56. sf_veritas/patches/network_libraries/httpcore.py +515 -0
  57. sf_veritas/patches/network_libraries/httplib2.py +204 -0
  58. sf_veritas/patches/network_libraries/httpx.py +515 -0
  59. sf_veritas/patches/network_libraries/niquests.py +211 -0
  60. sf_veritas/patches/network_libraries/pycurl.py +385 -0
  61. sf_veritas/patches/network_libraries/requests.py +633 -0
  62. sf_veritas/patches/network_libraries/tornado.py +341 -0
  63. sf_veritas/patches/network_libraries/treq.py +270 -0
  64. sf_veritas/patches/network_libraries/urllib_request.py +468 -0
  65. sf_veritas/patches/network_libraries/utils.py +398 -0
  66. sf_veritas/patches/os.py +17 -0
  67. sf_veritas/patches/threading.py +218 -0
  68. sf_veritas/patches/web_frameworks/__init__.py +54 -0
  69. sf_veritas/patches/web_frameworks/aiohttp.py +793 -0
  70. sf_veritas/patches/web_frameworks/async_websocket_consumer.py +317 -0
  71. sf_veritas/patches/web_frameworks/blacksheep.py +527 -0
  72. sf_veritas/patches/web_frameworks/bottle.py +502 -0
  73. sf_veritas/patches/web_frameworks/cherrypy.py +678 -0
  74. sf_veritas/patches/web_frameworks/cors_utils.py +122 -0
  75. sf_veritas/patches/web_frameworks/django.py +944 -0
  76. sf_veritas/patches/web_frameworks/eve.py +395 -0
  77. sf_veritas/patches/web_frameworks/falcon.py +926 -0
  78. sf_veritas/patches/web_frameworks/fastapi.py +724 -0
  79. sf_veritas/patches/web_frameworks/flask.py +520 -0
  80. sf_veritas/patches/web_frameworks/klein.py +501 -0
  81. sf_veritas/patches/web_frameworks/litestar.py +551 -0
  82. sf_veritas/patches/web_frameworks/pyramid.py +428 -0
  83. sf_veritas/patches/web_frameworks/quart.py +824 -0
  84. sf_veritas/patches/web_frameworks/robyn.py +697 -0
  85. sf_veritas/patches/web_frameworks/sanic.py +857 -0
  86. sf_veritas/patches/web_frameworks/starlette.py +723 -0
  87. sf_veritas/patches/web_frameworks/strawberry.py +813 -0
  88. sf_veritas/patches/web_frameworks/tornado.py +481 -0
  89. sf_veritas/patches/web_frameworks/utils.py +91 -0
  90. sf_veritas/print_override.py +13 -0
  91. sf_veritas/regular_data_transmitter.py +409 -0
  92. sf_veritas/request_interceptor.py +401 -0
  93. sf_veritas/request_utils.py +550 -0
  94. sf_veritas/server_status.py +1 -0
  95. sf_veritas/shutdown_flag.py +11 -0
  96. sf_veritas/subprocess_startup.py +3 -0
  97. sf_veritas/test_cli.py +145 -0
  98. sf_veritas/thread_local.py +970 -0
  99. sf_veritas/timeutil.py +114 -0
  100. sf_veritas/transmit_exception_to_sailfish.py +28 -0
  101. sf_veritas/transmitter.py +132 -0
  102. sf_veritas/types.py +47 -0
  103. sf_veritas/unified_interceptor.py +1580 -0
  104. sf_veritas/utils.py +39 -0
  105. sf_veritas-0.10.3.dist-info/METADATA +97 -0
  106. sf_veritas-0.10.3.dist-info/RECORD +132 -0
  107. sf_veritas-0.10.3.dist-info/WHEEL +5 -0
  108. sf_veritas-0.10.3.dist-info/entry_points.txt +2 -0
  109. sf_veritas-0.10.3.dist-info/top_level.txt +1 -0
  110. sf_veritas.libs/libbrotlicommon-6ce2a53c.so.1.0.6 +0 -0
  111. sf_veritas.libs/libbrotlidec-811d1be3.so.1.0.6 +0 -0
  112. sf_veritas.libs/libcom_err-730ca923.so.2.1 +0 -0
  113. sf_veritas.libs/libcrypt-52aca757.so.1.1.0 +0 -0
  114. sf_veritas.libs/libcrypto-bdaed0ea.so.1.1.1k +0 -0
  115. sf_veritas.libs/libcurl-eaa3cf66.so.4.5.0 +0 -0
  116. sf_veritas.libs/libgssapi_krb5-323bbd21.so.2.2 +0 -0
  117. sf_veritas.libs/libidn2-2f4a5893.so.0.3.6 +0 -0
  118. sf_veritas.libs/libk5crypto-9a74ff38.so.3.1 +0 -0
  119. sf_veritas.libs/libkeyutils-2777d33d.so.1.6 +0 -0
  120. sf_veritas.libs/libkrb5-a55300e8.so.3.3 +0 -0
  121. sf_veritas.libs/libkrb5support-e6594cfc.so.0.1 +0 -0
  122. sf_veritas.libs/liblber-2-d20824ef.4.so.2.10.9 +0 -0
  123. sf_veritas.libs/libldap-2-cea2a960.4.so.2.10.9 +0 -0
  124. sf_veritas.libs/libnghttp2-39367a22.so.14.17.0 +0 -0
  125. sf_veritas.libs/libpcre2-8-516f4c9d.so.0.7.1 +0 -0
  126. sf_veritas.libs/libpsl-99becdd3.so.5.3.1 +0 -0
  127. sf_veritas.libs/libsasl2-7de4d792.so.3.0.0 +0 -0
  128. sf_veritas.libs/libselinux-d0805dcb.so.1 +0 -0
  129. sf_veritas.libs/libssh-c11d285b.so.4.8.7 +0 -0
  130. sf_veritas.libs/libssl-60250281.so.1.1.1k +0 -0
  131. sf_veritas.libs/libunistring-05abdd40.so.2.1.0 +0 -0
  132. 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)