external-systems 0.103.0rc3__tar.gz → 0.104.0__tar.gz
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 external-systems might be problematic. Click here for more details.
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/PKG-INFO +1 -1
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/_version.py +1 -1
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_proxies.py +14 -1
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_sources.py +15 -33
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_utils.py +5 -0
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/pyproject.toml +1 -1
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/LICENSE.txt +0 -0
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/README.md +0 -0
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/__init__.py +0 -0
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/py.typed +0 -0
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/__init__.py +0 -0
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_api.py +0 -0
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_connections.py +0 -0
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_refreshable.py +0 -0
- {external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_sockets.py +0 -0
{external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_proxies.py
RENAMED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
import os
|
|
15
16
|
from functools import cache
|
|
16
17
|
from typing import Any, Mapping, Optional, Union
|
|
17
18
|
|
|
@@ -25,12 +26,24 @@ class CustomCaBundleSession(Session):
|
|
|
25
26
|
A wrapper for requests.Session to override 'verify' property, ignoring REQUESTS_CA_BUNDLE environment variable.
|
|
26
27
|
|
|
27
28
|
This is a workaround for https://github.com/psf/requests/issues/3829 (will be fixed in requests 3.0.0)
|
|
29
|
+
|
|
30
|
+
The standard behavior of requests is to ALWAYS use the REQUESTS_CA_BUNDLE environment variable here if "verify" is not set on
|
|
31
|
+
the request (even if it's set on the session level).
|
|
28
32
|
"""
|
|
29
33
|
|
|
30
34
|
def merge_environment_settings(self, url, proxies, stream, verify, *args, **kwargs): # type: ignore[no-untyped-def]
|
|
31
|
-
|
|
35
|
+
user_has_manually_overridden_verify = verify is not None
|
|
36
|
+
|
|
37
|
+
# The source certs will not exist, for example, if the client is passed to a spark UDF that runs in a different environment.
|
|
38
|
+
# In this case, the verify path does not exist on the new environment, so we should not try use it and instead default to standard behavior.
|
|
39
|
+
source_certs_exist = isinstance(self.verify, str) and os.path.exists(self.verify)
|
|
40
|
+
|
|
41
|
+
if not user_has_manually_overridden_verify and source_certs_exist:
|
|
32
42
|
verify = self.verify
|
|
33
43
|
|
|
44
|
+
# else (override exists or the source certs do not exist):
|
|
45
|
+
# Use the override. If there is no override (verify=None), then this will default to REQUESTS_CA_BUNDLE.
|
|
46
|
+
|
|
34
47
|
return super(CustomCaBundleSession, self).merge_environment_settings(
|
|
35
48
|
url, proxies, stream, verify, *args, **kwargs
|
|
36
49
|
)
|
{external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_sources.py
RENAMED
|
@@ -29,6 +29,7 @@ from ._connections import HttpsConnection
|
|
|
29
29
|
from ._proxies import create_proxy_session
|
|
30
30
|
from ._refreshable import DefaultSessionCredentialsManager, Refreshable, RefreshHandler
|
|
31
31
|
from ._sockets import create_socket
|
|
32
|
+
from ._utils import read_file
|
|
32
33
|
|
|
33
34
|
log = logging.getLogger(__name__)
|
|
34
35
|
|
|
@@ -81,43 +82,24 @@ class Source:
|
|
|
81
82
|
|
|
82
83
|
@cached_property
|
|
83
84
|
def _ca_bundle_path(self) -> Optional[str]:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
Precedence of which CA bundle to use:
|
|
88
|
-
1. Custom CA bundle path (if provided assumes PEM format)
|
|
89
|
-
2. Requests CA bundle path
|
|
90
|
-
3. Temporary file
|
|
91
|
-
"""
|
|
92
|
-
|
|
93
|
-
provided_ca_bundle_path = self._custom_ca_bundle_path or os.environ.get("REQUESTS_CA_BUNDLE")
|
|
94
|
-
|
|
95
|
-
if not self._source_parameters.server_certificates:
|
|
96
|
-
return provided_ca_bundle_path
|
|
97
|
-
|
|
98
|
-
# Certificates from the Source to add to the CA bundle
|
|
99
|
-
server_certificates = list(self._source_parameters.server_certificates.values())
|
|
85
|
+
if self._source_parameters.server_certificates is None:
|
|
86
|
+
return None
|
|
100
87
|
|
|
101
|
-
|
|
102
|
-
if not provided_ca_bundle_path:
|
|
103
|
-
with NamedTemporaryFile(delete=False, mode="w") as ca_bundle_file:
|
|
104
|
-
ca_bundle_file.write(os.linesep.join(server_certificates) + os.linesep)
|
|
105
|
-
return ca_bundle_file.name
|
|
88
|
+
new_ca_contents = []
|
|
106
89
|
|
|
107
|
-
#
|
|
108
|
-
#
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
log.warning("PermissionError when writing to provided CA bundle path, falling back to temporary file.")
|
|
90
|
+
# If a custom CA bundle path is provided, use it.
|
|
91
|
+
# Otherwise, use the requests CA bundle path if it is set.
|
|
92
|
+
ca_bundle_path = (
|
|
93
|
+
self._custom_ca_bundle_path
|
|
94
|
+
if self._custom_ca_bundle_path is not None
|
|
95
|
+
else os.environ.get("REQUESTS_CA_BUNDLE")
|
|
96
|
+
)
|
|
115
97
|
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
new_ca_contents.append(provided_ca_bundle_file.read())
|
|
98
|
+
# Copy the CA bundle contents to the new CA bundle file.
|
|
99
|
+
if ca_bundle_path:
|
|
100
|
+
new_ca_contents.append(read_file(ca_bundle_path))
|
|
120
101
|
|
|
102
|
+
# Add all CAs for the source
|
|
121
103
|
for required_ca in self._source_parameters.server_certificates.values():
|
|
122
104
|
new_ca_contents.append(required_ca)
|
|
123
105
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_connections.py
RENAMED
|
File without changes
|
{external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_refreshable.py
RENAMED
|
File without changes
|
{external_systems-0.103.0rc3 → external_systems-0.104.0}/external_systems/sources/_sockets.py
RENAMED
|
File without changes
|