sf-veritas 0.10.3__cp39-cp39-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.
- sf_veritas/__init__.py +20 -0
- sf_veritas/_sffastlog.c +889 -0
- sf_veritas/_sffastlog.cpython-39-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sffastnet.c +924 -0
- sf_veritas/_sffastnet.cpython-39-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sffastnetworkrequest.c +730 -0
- sf_veritas/_sffastnetworkrequest.cpython-39-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sffuncspan.c +2155 -0
- sf_veritas/_sffuncspan.cpython-39-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sffuncspan_config.c +617 -0
- sf_veritas/_sffuncspan_config.cpython-39-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sfheadercheck.c +341 -0
- sf_veritas/_sfheadercheck.cpython-39-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sfnetworkhop.c +1451 -0
- sf_veritas/_sfnetworkhop.cpython-39-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sfservice.c +1175 -0
- sf_veritas/_sfservice.cpython-39-x86_64-linux-gnu.so +0 -0
- sf_veritas/_sfteepreload.c +5167 -0
- sf_veritas/app_config.py +49 -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 +129 -0
- sf_veritas/custom_output_wrapper.py +144 -0
- sf_veritas/custom_print.py +146 -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 +556 -0
- sf_veritas/function_span_profiler.py +1174 -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 +497 -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/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 +76 -0
- sf_veritas/patches/network_libraries/aiohttp.py +281 -0
- sf_veritas/patches/network_libraries/curl_cffi.py +363 -0
- sf_veritas/patches/network_libraries/http_client.py +419 -0
- sf_veritas/patches/network_libraries/httpcore.py +515 -0
- sf_veritas/patches/network_libraries/httplib2.py +204 -0
- sf_veritas/patches/network_libraries/httpx.py +515 -0
- sf_veritas/patches/network_libraries/niquests.py +211 -0
- sf_veritas/patches/network_libraries/pycurl.py +385 -0
- sf_veritas/patches/network_libraries/requests.py +633 -0
- sf_veritas/patches/network_libraries/tornado.py +341 -0
- sf_veritas/patches/network_libraries/treq.py +270 -0
- sf_veritas/patches/network_libraries/urllib_request.py +468 -0
- sf_veritas/patches/network_libraries/utils.py +398 -0
- sf_veritas/patches/os.py +17 -0
- sf_veritas/patches/threading.py +218 -0
- sf_veritas/patches/web_frameworks/__init__.py +54 -0
- sf_veritas/patches/web_frameworks/aiohttp.py +793 -0
- sf_veritas/patches/web_frameworks/async_websocket_consumer.py +317 -0
- sf_veritas/patches/web_frameworks/blacksheep.py +527 -0
- sf_veritas/patches/web_frameworks/bottle.py +502 -0
- sf_veritas/patches/web_frameworks/cherrypy.py +678 -0
- sf_veritas/patches/web_frameworks/cors_utils.py +122 -0
- sf_veritas/patches/web_frameworks/django.py +944 -0
- sf_veritas/patches/web_frameworks/eve.py +395 -0
- sf_veritas/patches/web_frameworks/falcon.py +926 -0
- sf_veritas/patches/web_frameworks/fastapi.py +724 -0
- sf_veritas/patches/web_frameworks/flask.py +520 -0
- sf_veritas/patches/web_frameworks/klein.py +501 -0
- sf_veritas/patches/web_frameworks/litestar.py +551 -0
- sf_veritas/patches/web_frameworks/pyramid.py +428 -0
- sf_veritas/patches/web_frameworks/quart.py +824 -0
- sf_veritas/patches/web_frameworks/robyn.py +697 -0
- sf_veritas/patches/web_frameworks/sanic.py +857 -0
- sf_veritas/patches/web_frameworks/starlette.py +723 -0
- sf_veritas/patches/web_frameworks/strawberry.py +813 -0
- sf_veritas/patches/web_frameworks/tornado.py +481 -0
- sf_veritas/patches/web_frameworks/utils.py +91 -0
- sf_veritas/print_override.py +13 -0
- sf_veritas/regular_data_transmitter.py +409 -0
- sf_veritas/request_interceptor.py +401 -0
- sf_veritas/request_utils.py +550 -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 +970 -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 +1580 -0
- sf_veritas/utils.py +39 -0
- sf_veritas-0.10.3.dist-info/METADATA +97 -0
- sf_veritas-0.10.3.dist-info/RECORD +132 -0
- sf_veritas-0.10.3.dist-info/WHEEL +5 -0
- sf_veritas-0.10.3.dist-info/entry_points.txt +2 -0
- sf_veritas-0.10.3.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
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Utilities for automatically injecting Sailfish headers into CORS configurations.
|
|
3
|
+
|
|
4
|
+
This module provides helper functions to ensure that Sailfish's tracing and control
|
|
5
|
+
headers are always included in CORS allow-headers, without disrupting user configurations.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from ...env_vars import SF_DEBUG
|
|
9
|
+
|
|
10
|
+
# Sailfish headers that must be allowed for proper operation
|
|
11
|
+
# Include both original case and lowercase variants for compatibility
|
|
12
|
+
SAILFISH_CORS_HEADERS = [
|
|
13
|
+
"X-Sf3-Rid", # Tracing header (request ID)
|
|
14
|
+
"x-sf3-rid", # Lowercase variant
|
|
15
|
+
"X-Sf3-FunctionSpanCaptureOverride", # Function span capture control
|
|
16
|
+
"x-sf3-functionspancaptureoverride", # Lowercase variant
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def inject_sailfish_headers(user_headers):
|
|
21
|
+
"""
|
|
22
|
+
Inject Sailfish headers into a user's CORS allow-headers configuration.
|
|
23
|
+
|
|
24
|
+
Ensures Sailfish headers come first, followed by user headers, with de-duplication.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
user_headers: User's existing allowed headers (can be None, string, list, tuple, or set)
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
List with Sailfish headers prepended, or None if user_headers was None
|
|
31
|
+
|
|
32
|
+
Safety:
|
|
33
|
+
- Returns None if user_headers is None (doesn't enable CORS if not configured)
|
|
34
|
+
- Preserves all user headers
|
|
35
|
+
- De-duplicates while maintaining order
|
|
36
|
+
- Handles "*" wildcard (leaves as-is)
|
|
37
|
+
- Handles comma-separated strings (common CORS format)
|
|
38
|
+
"""
|
|
39
|
+
# Don't enable CORS if user didn't configure it
|
|
40
|
+
if user_headers is None:
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
# If user allows all headers with wildcard, leave as-is
|
|
44
|
+
if user_headers == "*" or (isinstance(user_headers, (list, tuple)) and "*" in user_headers):
|
|
45
|
+
if SF_DEBUG:
|
|
46
|
+
print(
|
|
47
|
+
"[[cors_utils]] User has wildcard '*' in CORS headers, skipping injection",
|
|
48
|
+
log=False
|
|
49
|
+
)
|
|
50
|
+
return user_headers
|
|
51
|
+
|
|
52
|
+
# Convert to list for processing
|
|
53
|
+
if isinstance(user_headers, str):
|
|
54
|
+
# Handle comma-separated string (common CORS format: "foo, bar, baz")
|
|
55
|
+
# Split by comma and strip whitespace
|
|
56
|
+
user_headers = [h.strip() for h in user_headers.split(',') if h.strip()]
|
|
57
|
+
if SF_DEBUG:
|
|
58
|
+
print(
|
|
59
|
+
f"[[cors_utils]] Parsed string headers: {user_headers}",
|
|
60
|
+
log=False
|
|
61
|
+
)
|
|
62
|
+
elif isinstance(user_headers, (tuple, set)):
|
|
63
|
+
user_headers = list(user_headers)
|
|
64
|
+
elif not isinstance(user_headers, list):
|
|
65
|
+
# Handle other iterables (but NOT strings, which we handled above)
|
|
66
|
+
try:
|
|
67
|
+
user_headers = list(user_headers)
|
|
68
|
+
except TypeError:
|
|
69
|
+
# Not iterable, return as-is
|
|
70
|
+
if SF_DEBUG:
|
|
71
|
+
print(
|
|
72
|
+
f"[[cors_utils]] Unexpected headers type: {type(user_headers)}, skipping injection",
|
|
73
|
+
log=False
|
|
74
|
+
)
|
|
75
|
+
return user_headers
|
|
76
|
+
|
|
77
|
+
# Prepend Sailfish headers, then add user headers
|
|
78
|
+
combined = SAILFISH_CORS_HEADERS + user_headers
|
|
79
|
+
|
|
80
|
+
# De-duplicate while preserving order (dict.fromkeys preserves insertion order in Python 3.7+)
|
|
81
|
+
# Convert to lowercase for comparison to handle case-insensitive duplicates
|
|
82
|
+
seen = set()
|
|
83
|
+
deduplicated = []
|
|
84
|
+
for header in combined:
|
|
85
|
+
header_lower = header.lower() if isinstance(header, str) else str(header).lower()
|
|
86
|
+
if header_lower not in seen:
|
|
87
|
+
seen.add(header_lower)
|
|
88
|
+
deduplicated.append(header)
|
|
89
|
+
|
|
90
|
+
if SF_DEBUG:
|
|
91
|
+
added_headers = [h for h in SAILFISH_CORS_HEADERS if h.lower() in seen]
|
|
92
|
+
print(
|
|
93
|
+
f"[[cors_utils]] Injected Sailfish headers into CORS: {added_headers}",
|
|
94
|
+
log=False
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
return deduplicated
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def should_inject_headers(allow_headers_value):
|
|
101
|
+
"""
|
|
102
|
+
Determine if we should inject Sailfish headers based on the current value.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
allow_headers_value: The current allow_headers value
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
bool: True if we should inject, False otherwise
|
|
109
|
+
"""
|
|
110
|
+
# Don't inject if CORS isn't configured
|
|
111
|
+
if allow_headers_value is None:
|
|
112
|
+
return False
|
|
113
|
+
|
|
114
|
+
# Don't inject if wildcard is already present
|
|
115
|
+
if allow_headers_value == "*":
|
|
116
|
+
return False
|
|
117
|
+
|
|
118
|
+
if isinstance(allow_headers_value, (list, tuple, set)):
|
|
119
|
+
if "*" in allow_headers_value:
|
|
120
|
+
return False
|
|
121
|
+
|
|
122
|
+
return True
|