snowflake-connector-python 3.16.0__cp313-cp313-win_amd64.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.
- snowflake/connector/__init__.py +96 -0
- snowflake/connector/_query_context_cache.py +276 -0
- snowflake/connector/_sql_util.py +48 -0
- snowflake/connector/_utils.py +70 -0
- snowflake/connector/arrow_context.py +203 -0
- snowflake/connector/auth/__init__.py +53 -0
- snowflake/connector/auth/_auth.py +586 -0
- snowflake/connector/auth/_http_server.py +220 -0
- snowflake/connector/auth/_oauth_base.py +400 -0
- snowflake/connector/auth/by_plugin.py +219 -0
- snowflake/connector/auth/default.py +36 -0
- snowflake/connector/auth/idtoken.py +72 -0
- snowflake/connector/auth/keypair.py +222 -0
- snowflake/connector/auth/no_auth.py +39 -0
- snowflake/connector/auth/oauth.py +49 -0
- snowflake/connector/auth/oauth_code.py +479 -0
- snowflake/connector/auth/oauth_credentials.py +66 -0
- snowflake/connector/auth/okta.py +335 -0
- snowflake/connector/auth/pat.py +39 -0
- snowflake/connector/auth/usrpwdmfa.py +69 -0
- snowflake/connector/auth/webbrowser.py +502 -0
- snowflake/connector/auth/workload_identity.py +94 -0
- snowflake/connector/azure_storage_client.py +276 -0
- snowflake/connector/backoff_policies.py +141 -0
- snowflake/connector/bind_upload_agent.py +89 -0
- snowflake/connector/cache.py +696 -0
- snowflake/connector/compat.py +127 -0
- snowflake/connector/config_manager.py +496 -0
- snowflake/connector/connection.py +2273 -0
- snowflake/connector/connection_diagnostic.py +776 -0
- snowflake/connector/constants.py +442 -0
- snowflake/connector/converter.py +785 -0
- snowflake/connector/converter_issue23517.py +87 -0
- snowflake/connector/converter_null.py +14 -0
- snowflake/connector/converter_snowsql.py +205 -0
- snowflake/connector/cursor.py +1951 -0
- snowflake/connector/dbapi.py +53 -0
- snowflake/connector/description.py +19 -0
- snowflake/connector/direct_file_operation_utils.py +88 -0
- snowflake/connector/encryption_util.py +220 -0
- snowflake/connector/errorcode.py +91 -0
- snowflake/connector/errors.py +615 -0
- snowflake/connector/externals_utils/__init__.py +0 -0
- snowflake/connector/externals_utils/externals_setup.py +27 -0
- snowflake/connector/feature.py +4 -0
- snowflake/connector/file_compression_type.py +118 -0
- snowflake/connector/file_lock.py +72 -0
- snowflake/connector/file_transfer_agent.py +1215 -0
- snowflake/connector/file_util.py +153 -0
- snowflake/connector/gcs_storage_client.py +474 -0
- snowflake/connector/gzip_decoder.py +85 -0
- snowflake/connector/local_storage_client.py +90 -0
- snowflake/connector/log_configuration.py +60 -0
- snowflake/connector/logging_utils/__init__.py +0 -0
- snowflake/connector/logging_utils/filters.py +72 -0
- snowflake/connector/nanoarrow_arrow_iterator.cp313-win_amd64.pyd +0 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.cpp +60 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.hpp +29 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.cpp +19 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.hpp +26 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.cpp +21 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.hpp +23 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.cpp +557 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.hpp +98 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.cpp +125 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.hpp +115 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.cpp +1005 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.hpp +127 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.cpp +47 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.hpp +46 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.cpp +83 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.hpp +35 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.cpp +97 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.hpp +72 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.cpp +73 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.hpp +28 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.cpp +30 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.hpp +35 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IColumnConverter.hpp +17 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.cpp +23 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.hpp +45 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.cpp +71 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.hpp +56 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/LICENSE.txt +209 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.cpp +75 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.hpp +30 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.cpp +46 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.hpp +29 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.cpp +8 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.hpp +95 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.cpp +57 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.hpp +36 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.cpp +34 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.hpp +48 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.cpp +19 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.hpp +26 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.cpp +36 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.hpp +31 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.cpp +346 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.hpp +145 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/macros.hpp +14 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.cpp +65 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.hpp +68 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_accessors.h +101 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_alloc.h +127 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_assert.h +45 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_builder.h +1908 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_emitter.h +215 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_endian.h +125 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_epilogue.h +7 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_flatbuffers.h +55 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_identifier.h +148 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_iov.h +31 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_prologue.h +8 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_refmap.h +144 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_rtconfig.h +162 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_types.h +97 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_verifier.h +239 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/flatcc_portable.h +14 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/paligned_alloc.h +210 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pattributes.h +84 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic.h +84 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_pop.h +20 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_push.h +51 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian.h +206 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian_detect.h +118 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinline.h +19 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinttypes.h +52 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable.h +2 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable_basic.h +25 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstatic_assert.h +67 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdalign.h +162 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdint.h +898 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/punaligned.h +190 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pversion.h +6 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pwarnings.h +52 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc.c +3204 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.c +3217 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.h +3618 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.hpp +379 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_arrow_iterator.pyx +256 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.c +512 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.h +350 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c +33273 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.h +397 -0
- snowflake/connector/nanoarrow_cpp/Logging/logging.cpp +100 -0
- snowflake/connector/nanoarrow_cpp/Logging/logging.hpp +49 -0
- snowflake/connector/network.py +1297 -0
- snowflake/connector/ocsp_asn1crypto.py +447 -0
- snowflake/connector/ocsp_snowflake.py +1883 -0
- snowflake/connector/options.py +131 -0
- snowflake/connector/pandas_tools.py +732 -0
- snowflake/connector/proxy.py +43 -0
- snowflake/connector/py.typed +0 -0
- snowflake/connector/result_batch.py +786 -0
- snowflake/connector/result_set.py +319 -0
- snowflake/connector/s3_storage_client.py +605 -0
- snowflake/connector/secret_detector.py +181 -0
- snowflake/connector/sf_dirs.py +64 -0
- snowflake/connector/sfbinaryformat.py +35 -0
- snowflake/connector/sfdatetime.py +345 -0
- snowflake/connector/snow_logging.py +144 -0
- snowflake/connector/sqlstate.py +9 -0
- snowflake/connector/ssd_internal_keys.py +30 -0
- snowflake/connector/ssl_wrap_socket.py +134 -0
- snowflake/connector/storage_client.py +478 -0
- snowflake/connector/telemetry.py +249 -0
- snowflake/connector/telemetry_oob.py +543 -0
- snowflake/connector/test_util.py +30 -0
- snowflake/connector/time_util.py +159 -0
- snowflake/connector/token_cache.py +402 -0
- snowflake/connector/tool/__init__.py +0 -0
- snowflake/connector/tool/dump_certs.py +57 -0
- snowflake/connector/tool/dump_ocsp_response.py +139 -0
- snowflake/connector/tool/dump_ocsp_response_cache.py +194 -0
- snowflake/connector/tool/probe_connection.py +69 -0
- snowflake/connector/url_util.py +49 -0
- snowflake/connector/util_text.py +301 -0
- snowflake/connector/vendored/__init__.py +3 -0
- snowflake/connector/vendored/requests/LICENSE +175 -0
- snowflake/connector/vendored/requests/__init__.py +169 -0
- snowflake/connector/vendored/requests/__version__.py +14 -0
- snowflake/connector/vendored/requests/_internal_utils.py +50 -0
- snowflake/connector/vendored/requests/adapters.py +537 -0
- snowflake/connector/vendored/requests/api.py +157 -0
- snowflake/connector/vendored/requests/auth.py +315 -0
- snowflake/connector/vendored/requests/certs.py +17 -0
- snowflake/connector/vendored/requests/compat.py +79 -0
- snowflake/connector/vendored/requests/cookies.py +561 -0
- snowflake/connector/vendored/requests/exceptions.py +140 -0
- snowflake/connector/vendored/requests/help.py +134 -0
- snowflake/connector/vendored/requests/hooks.py +33 -0
- snowflake/connector/vendored/requests/models.py +1033 -0
- snowflake/connector/vendored/requests/sessions.py +833 -0
- snowflake/connector/vendored/requests/status_codes.py +128 -0
- snowflake/connector/vendored/requests/structures.py +99 -0
- snowflake/connector/vendored/requests/utils.py +1093 -0
- snowflake/connector/vendored/urllib3/LICENSE.txt +21 -0
- snowflake/connector/vendored/urllib3/__init__.py +85 -0
- snowflake/connector/vendored/urllib3/_collections.py +355 -0
- snowflake/connector/vendored/urllib3/_version.py +2 -0
- snowflake/connector/vendored/urllib3/connection.py +572 -0
- snowflake/connector/vendored/urllib3/connectionpool.py +1137 -0
- snowflake/connector/vendored/urllib3/contrib/__init__.py +0 -0
- snowflake/connector/vendored/urllib3/contrib/_appengine_environ.py +36 -0
- snowflake/connector/vendored/urllib3/contrib/_securetransport/__init__.py +0 -0
- snowflake/connector/vendored/urllib3/contrib/_securetransport/bindings.py +519 -0
- snowflake/connector/vendored/urllib3/contrib/_securetransport/low_level.py +397 -0
- snowflake/connector/vendored/urllib3/contrib/appengine.py +314 -0
- snowflake/connector/vendored/urllib3/contrib/ntlmpool.py +130 -0
- snowflake/connector/vendored/urllib3/contrib/pyopenssl.py +509 -0
- snowflake/connector/vendored/urllib3/contrib/securetransport.py +920 -0
- snowflake/connector/vendored/urllib3/contrib/socks.py +216 -0
- snowflake/connector/vendored/urllib3/exceptions.py +323 -0
- snowflake/connector/vendored/urllib3/fields.py +274 -0
- snowflake/connector/vendored/urllib3/filepost.py +98 -0
- snowflake/connector/vendored/urllib3/packages/__init__.py +0 -0
- snowflake/connector/vendored/urllib3/packages/backports/__init__.py +0 -0
- snowflake/connector/vendored/urllib3/packages/backports/makefile.py +51 -0
- snowflake/connector/vendored/urllib3/packages/backports/weakref_finalize.py +155 -0
- snowflake/connector/vendored/urllib3/packages/six.py +1076 -0
- snowflake/connector/vendored/urllib3/poolmanager.py +540 -0
- snowflake/connector/vendored/urllib3/request.py +191 -0
- snowflake/connector/vendored/urllib3/response.py +885 -0
- snowflake/connector/vendored/urllib3/util/__init__.py +49 -0
- snowflake/connector/vendored/urllib3/util/connection.py +156 -0
- snowflake/connector/vendored/urllib3/util/proxy.py +57 -0
- snowflake/connector/vendored/urllib3/util/queue.py +22 -0
- snowflake/connector/vendored/urllib3/util/request.py +146 -0
- snowflake/connector/vendored/urllib3/util/response.py +107 -0
- snowflake/connector/vendored/urllib3/util/retry.py +620 -0
- snowflake/connector/vendored/urllib3/util/ssl_.py +495 -0
- snowflake/connector/vendored/urllib3/util/ssl_match_hostname.py +159 -0
- snowflake/connector/vendored/urllib3/util/ssltransport.py +221 -0
- snowflake/connector/vendored/urllib3/util/timeout.py +271 -0
- snowflake/connector/vendored/urllib3/util/url.py +435 -0
- snowflake/connector/vendored/urllib3/util/wait.py +152 -0
- snowflake/connector/version.py +3 -0
- snowflake/connector/wif_util.py +407 -0
- snowflake_connector_python-3.16.0.dist-info/METADATA +1475 -0
- snowflake_connector_python-3.16.0.dist-info/RECORD +246 -0
- snowflake_connector_python-3.16.0.dist-info/WHEEL +5 -0
- snowflake_connector_python-3.16.0.dist-info/entry_points.txt +4 -0
- snowflake_connector_python-3.16.0.dist-info/licenses/LICENSE.txt +202 -0
- snowflake_connector_python-3.16.0.dist-info/licenses/NOTICE +8 -0
- snowflake_connector_python-3.16.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import warnings
|
|
5
|
+
from collections.abc import Mapping
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def getSnowLogger(
|
|
10
|
+
name: str,
|
|
11
|
+
extra: Mapping[str, object] | None = None,
|
|
12
|
+
) -> SnowLogger:
|
|
13
|
+
logger = logging.getLogger(name)
|
|
14
|
+
return SnowLogger(logger, extra) # type:ignore[arg-type]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SnowLogger(logging.LoggerAdapter):
|
|
18
|
+
"""Snowflake Python logger wrapper of the built-in Python logger.
|
|
19
|
+
|
|
20
|
+
This logger wrapper supports user-provided logging info about
|
|
21
|
+
file name, function name and line number. This wrapper can be
|
|
22
|
+
used in Cython code (.pyx).
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def debug( # type: ignore[override]
|
|
26
|
+
self,
|
|
27
|
+
msg: str,
|
|
28
|
+
path_name: str | None = None,
|
|
29
|
+
func_name: str | None = None,
|
|
30
|
+
*args: Any,
|
|
31
|
+
**kwargs: Any,
|
|
32
|
+
) -> None:
|
|
33
|
+
self.log(logging.DEBUG, msg, path_name, func_name, *args, **kwargs)
|
|
34
|
+
|
|
35
|
+
def info( # type: ignore[override]
|
|
36
|
+
self,
|
|
37
|
+
msg: str,
|
|
38
|
+
path_name: str | None = None,
|
|
39
|
+
func_name: str | None = None,
|
|
40
|
+
*args: Any,
|
|
41
|
+
**kwargs: Any,
|
|
42
|
+
) -> None:
|
|
43
|
+
self.log(logging.INFO, msg, path_name, func_name, *args, **kwargs)
|
|
44
|
+
|
|
45
|
+
def warning( # type: ignore[override]
|
|
46
|
+
self,
|
|
47
|
+
msg: str,
|
|
48
|
+
path_name: str | None = None,
|
|
49
|
+
func_name: str | None = None,
|
|
50
|
+
*args: Any,
|
|
51
|
+
**kwargs: Any,
|
|
52
|
+
) -> None:
|
|
53
|
+
self.log(logging.WARNING, msg, path_name, func_name, *args, **kwargs)
|
|
54
|
+
|
|
55
|
+
def warn( # type: ignore[override]
|
|
56
|
+
self,
|
|
57
|
+
msg: str,
|
|
58
|
+
path_name: str | None = None,
|
|
59
|
+
func_name: str | None = None,
|
|
60
|
+
*args: Any,
|
|
61
|
+
**kwargs: Any,
|
|
62
|
+
) -> None:
|
|
63
|
+
warnings.warn(
|
|
64
|
+
"The 'warn' method is deprecated, " "use 'warning' instead",
|
|
65
|
+
DeprecationWarning,
|
|
66
|
+
stacklevel=2,
|
|
67
|
+
)
|
|
68
|
+
self.warning(msg, path_name, func_name, *args, **kwargs)
|
|
69
|
+
|
|
70
|
+
def error( # type: ignore[override]
|
|
71
|
+
self,
|
|
72
|
+
msg: str,
|
|
73
|
+
path_name: str | None = None,
|
|
74
|
+
func_name: str | None = None,
|
|
75
|
+
*args: Any,
|
|
76
|
+
**kwargs: Any,
|
|
77
|
+
) -> None:
|
|
78
|
+
self.log(logging.ERROR, msg, path_name, func_name, *args, **kwargs)
|
|
79
|
+
|
|
80
|
+
def exception( # type: ignore[override]
|
|
81
|
+
self,
|
|
82
|
+
msg: str,
|
|
83
|
+
path_name: str | None = None,
|
|
84
|
+
func_name: str | None = None,
|
|
85
|
+
*args: Any,
|
|
86
|
+
exc_info: bool = True,
|
|
87
|
+
**kwargs: Any,
|
|
88
|
+
) -> None:
|
|
89
|
+
"""Convenience method for logging an ERROR with exception information."""
|
|
90
|
+
self.error(msg, path_name, func_name, *args, exc_info=exc_info, **kwargs)
|
|
91
|
+
|
|
92
|
+
def critical( # type: ignore[override]
|
|
93
|
+
self,
|
|
94
|
+
msg: str,
|
|
95
|
+
path_name: str | None = None,
|
|
96
|
+
func_name: str | None = None,
|
|
97
|
+
*args: Any,
|
|
98
|
+
**kwargs: Any,
|
|
99
|
+
) -> None:
|
|
100
|
+
self.log(logging.CRITICAL, msg, path_name, func_name, *args, **kwargs)
|
|
101
|
+
|
|
102
|
+
fatal = critical
|
|
103
|
+
|
|
104
|
+
def log( # type: ignore[override]
|
|
105
|
+
self,
|
|
106
|
+
level: int,
|
|
107
|
+
msg: str,
|
|
108
|
+
path_name: str | None = None,
|
|
109
|
+
func_name: str | None = None,
|
|
110
|
+
line_num: int = 0,
|
|
111
|
+
*args: Any,
|
|
112
|
+
**kwargs: Any,
|
|
113
|
+
) -> None:
|
|
114
|
+
"""Generalized log method of SnowLogger wrapper.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
level: Logging level.
|
|
118
|
+
msg: Logging message.
|
|
119
|
+
path_name: Absolute or relative path of the file where the logger gets called.
|
|
120
|
+
func_name: Function inside which the logger gets called.
|
|
121
|
+
line_num: Line number at which the logger gets called.
|
|
122
|
+
"""
|
|
123
|
+
if not path_name:
|
|
124
|
+
path_name = "path_name not provided"
|
|
125
|
+
if not func_name:
|
|
126
|
+
func_name = "func_name not provided"
|
|
127
|
+
if not isinstance(level, int):
|
|
128
|
+
if logging.raiseExceptions:
|
|
129
|
+
raise TypeError("level must be an integer")
|
|
130
|
+
else:
|
|
131
|
+
return
|
|
132
|
+
if self.logger.isEnabledFor(level):
|
|
133
|
+
record = self.logger.makeRecord(
|
|
134
|
+
self.logger.name,
|
|
135
|
+
level,
|
|
136
|
+
path_name,
|
|
137
|
+
line_num,
|
|
138
|
+
msg,
|
|
139
|
+
args,
|
|
140
|
+
None,
|
|
141
|
+
func_name,
|
|
142
|
+
**kwargs,
|
|
143
|
+
)
|
|
144
|
+
self.logger.handle(record)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
SQLSTATE_CONNECTION_WAS_NOT_ESTABLISHED = "08001"
|
|
3
|
+
SQLSTATE_CONNECTION_ALREADY_EXISTS = "08002"
|
|
4
|
+
SQLSTATE_CONNECTION_NOT_EXISTS = "08003"
|
|
5
|
+
SQLSTATE_CONNECTION_REJECTED = "08004"
|
|
6
|
+
SQLSTATE_CONNECTION_FAILED_BUT_REESTABLISHED = "08506"
|
|
7
|
+
SQLSTATE_HOST_NOT_FOUND = "08508"
|
|
8
|
+
SQLSTATE_FEATURE_NOT_SUPPORTED = "0A000"
|
|
9
|
+
SQLSTATE_IO_ERROR = "58030"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from binascii import unhexlify
|
|
5
|
+
|
|
6
|
+
# key version
|
|
7
|
+
ocsp_internal_dep1_key_ver = 0.1
|
|
8
|
+
ocsp_internal_dep2_key_ver = 0.1
|
|
9
|
+
|
|
10
|
+
# OCSP Hard coded public keys
|
|
11
|
+
ocsp_internal_ssd_pub_dep1 = None
|
|
12
|
+
ocsp_internal_ssd_pub_dep2 = None
|
|
13
|
+
|
|
14
|
+
# Default cert if for key update directives
|
|
15
|
+
SF_KEY_UPDATE_SSD_DEFAULT_CERT_ID = 0
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def ret_int_pub_key_ver(issuer):
|
|
19
|
+
if issuer == "dep1":
|
|
20
|
+
return ocsp_internal_dep1_key_ver
|
|
21
|
+
else:
|
|
22
|
+
return ocsp_internal_dep2_key_ver
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def ret_wildcard_hkey():
|
|
26
|
+
issuer_name_hash = unhexlify("040130")
|
|
27
|
+
issuer_key_hash = unhexlify("040130")
|
|
28
|
+
serial_number = unhexlify("020100")
|
|
29
|
+
hkey = (issuer_name_hash, issuer_key_hash, serial_number)
|
|
30
|
+
return hkey
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# SSL wrap socket for PyOpenSSL.
|
|
5
|
+
# Mostly copied from
|
|
6
|
+
#
|
|
7
|
+
# https://github.com/shazow/urllib3/blob/master/urllib3/contrib/pyopenssl.py
|
|
8
|
+
#
|
|
9
|
+
# and added OCSP validator on the top.
|
|
10
|
+
import logging
|
|
11
|
+
import time
|
|
12
|
+
from functools import wraps
|
|
13
|
+
from inspect import getfullargspec as get_args
|
|
14
|
+
from socket import socket
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
import certifi
|
|
18
|
+
import OpenSSL.SSL
|
|
19
|
+
|
|
20
|
+
from .constants import OCSPMode
|
|
21
|
+
from .errorcode import ER_OCSP_RESPONSE_CERT_STATUS_REVOKED
|
|
22
|
+
from .errors import OperationalError
|
|
23
|
+
from .vendored.urllib3 import connection as connection_
|
|
24
|
+
from .vendored.urllib3.contrib.pyopenssl import PyOpenSSLContext, WrappedSocket
|
|
25
|
+
from .vendored.urllib3.util import ssl_ as ssl_
|
|
26
|
+
|
|
27
|
+
DEFAULT_OCSP_MODE: OCSPMode = OCSPMode.FAIL_OPEN
|
|
28
|
+
FEATURE_OCSP_MODE: OCSPMode = DEFAULT_OCSP_MODE
|
|
29
|
+
|
|
30
|
+
"""
|
|
31
|
+
OCSP Response cache file name
|
|
32
|
+
"""
|
|
33
|
+
FEATURE_OCSP_RESPONSE_CACHE_FILE_NAME: str | None = None
|
|
34
|
+
|
|
35
|
+
log = logging.getLogger(__name__)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def inject_into_urllib3() -> None:
|
|
39
|
+
"""Monkey-patch urllib3 with PyOpenSSL-backed SSL-support and OCSP."""
|
|
40
|
+
log.debug("Injecting ssl_wrap_socket_with_ocsp")
|
|
41
|
+
connection_.ssl_wrap_socket = ssl_wrap_socket_with_ocsp
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@wraps(ssl_.ssl_wrap_socket)
|
|
45
|
+
def ssl_wrap_socket_with_ocsp(*args: Any, **kwargs: Any) -> WrappedSocket:
|
|
46
|
+
# Extract host_name
|
|
47
|
+
hostname_index = get_args(ssl_.ssl_wrap_socket).args.index("server_hostname")
|
|
48
|
+
server_hostname = (
|
|
49
|
+
args[hostname_index]
|
|
50
|
+
if len(args) > hostname_index
|
|
51
|
+
else kwargs.get("server_hostname", None)
|
|
52
|
+
)
|
|
53
|
+
# Remove context if present
|
|
54
|
+
ssl_context_index = get_args(ssl_.ssl_wrap_socket).args.index("ssl_context")
|
|
55
|
+
context_in_args = len(args) > ssl_context_index
|
|
56
|
+
ssl_context = (
|
|
57
|
+
args[hostname_index] if context_in_args else kwargs.get("ssl_context", None)
|
|
58
|
+
)
|
|
59
|
+
if not isinstance(ssl_context, PyOpenSSLContext):
|
|
60
|
+
# Create new default context
|
|
61
|
+
if context_in_args:
|
|
62
|
+
new_args = list(args)
|
|
63
|
+
new_args[ssl_context_index] = None
|
|
64
|
+
args = tuple(new_args)
|
|
65
|
+
else:
|
|
66
|
+
del kwargs["ssl_context"]
|
|
67
|
+
# Fix ca certs location
|
|
68
|
+
ca_certs_index = get_args(ssl_.ssl_wrap_socket).args.index("ca_certs")
|
|
69
|
+
ca_certs_in_args = len(args) > ca_certs_index
|
|
70
|
+
if not ca_certs_in_args and not kwargs.get("ca_certs"):
|
|
71
|
+
kwargs["ca_certs"] = certifi.where()
|
|
72
|
+
|
|
73
|
+
ret = ssl_.ssl_wrap_socket(*args, **kwargs)
|
|
74
|
+
|
|
75
|
+
log.debug(
|
|
76
|
+
"OCSP Mode: %s, " "OCSP response cache file name: %s",
|
|
77
|
+
FEATURE_OCSP_MODE.name,
|
|
78
|
+
FEATURE_OCSP_RESPONSE_CACHE_FILE_NAME,
|
|
79
|
+
)
|
|
80
|
+
if FEATURE_OCSP_MODE != OCSPMode.DISABLE_OCSP_CHECKS:
|
|
81
|
+
from .ocsp_asn1crypto import SnowflakeOCSPAsn1Crypto as SFOCSP
|
|
82
|
+
|
|
83
|
+
v = SFOCSP(
|
|
84
|
+
ocsp_response_cache_uri=FEATURE_OCSP_RESPONSE_CACHE_FILE_NAME,
|
|
85
|
+
use_fail_open=FEATURE_OCSP_MODE == OCSPMode.FAIL_OPEN,
|
|
86
|
+
hostname=server_hostname,
|
|
87
|
+
).validate(server_hostname, ret.connection)
|
|
88
|
+
if not v:
|
|
89
|
+
raise OperationalError(
|
|
90
|
+
msg=(
|
|
91
|
+
"The certificate is revoked or "
|
|
92
|
+
"could not be validated: hostname={}".format(server_hostname)
|
|
93
|
+
),
|
|
94
|
+
errno=ER_OCSP_RESPONSE_CERT_STATUS_REVOKED,
|
|
95
|
+
)
|
|
96
|
+
else:
|
|
97
|
+
log.debug(
|
|
98
|
+
"This connection does not perform OCSP checks. "
|
|
99
|
+
"Revocation status of the certificate will not be checked against OCSP Responder."
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
return ret
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _openssl_connect(
|
|
106
|
+
hostname: str, port: int = 443, max_retry: int = 20, timeout: int | None = None
|
|
107
|
+
) -> OpenSSL.SSL.Connection:
|
|
108
|
+
"""The OpenSSL connection without validating certificates.
|
|
109
|
+
|
|
110
|
+
This is used to diagnose SSL issues.
|
|
111
|
+
"""
|
|
112
|
+
err = None
|
|
113
|
+
sleeping_time = 1
|
|
114
|
+
for _ in range(max_retry):
|
|
115
|
+
try:
|
|
116
|
+
client = socket()
|
|
117
|
+
client.connect((hostname, port))
|
|
118
|
+
context = OpenSSL.SSL.Context(OpenSSL.SSL.SSLv23_METHOD)
|
|
119
|
+
if timeout is not None:
|
|
120
|
+
context.set_timeout(timeout)
|
|
121
|
+
client_ssl = OpenSSL.SSL.Connection(context, client)
|
|
122
|
+
client_ssl.set_connect_state()
|
|
123
|
+
client_ssl.set_tlsext_host_name(hostname.encode("utf-8"))
|
|
124
|
+
client_ssl.do_handshake()
|
|
125
|
+
return client_ssl
|
|
126
|
+
except (
|
|
127
|
+
OpenSSL.SSL.SysCallError,
|
|
128
|
+
OSError,
|
|
129
|
+
) as ex:
|
|
130
|
+
err = ex
|
|
131
|
+
sleeping_time = min(sleeping_time * 2, 16)
|
|
132
|
+
time.sleep(sleeping_time)
|
|
133
|
+
if err:
|
|
134
|
+
raise err
|