From 20a966bbbfc66932f471e0bfd191769f40332233 Mon Sep 17 00:00:00 2001 From: Jin Date: Fri, 24 Mar 2023 14:14:58 -0700 Subject: [PATCH] fix: Python: Remove aws url validation (#1254) * fix: Python: Remove awl url validation * fix: lint failed due to an unused import * update token --- google/auth/aws.py | 19 ------------------- system_tests/secrets.tar.enc | Bin 10324 -> 10324 bytes tests/test_aws.py | 33 --------------------------------- 3 files changed, 52 deletions(-) diff --git a/google/auth/aws.py b/google/auth/aws.py index f651433f0..13644c4c2 100644 --- a/google/auth/aws.py +++ b/google/auth/aws.py @@ -47,7 +47,6 @@ from six.moves import http_client from six.moves import urllib from six.moves.urllib.parse import urljoin -from six.moves.urllib.parse import urlparse from google.auth import _helpers from google.auth import environment_vars @@ -398,8 +397,6 @@ def __init__( self._request_signer = None self._target_resource = audience - self.validate_metadata_server_urls() - # Get the environment ID. Currently, only one version supported (v1). matches = re.match(r"^(aws)([\d]+)$", self._environment_id) if matches: @@ -418,22 +415,6 @@ def __init__( ) ) - def validate_metadata_server_urls(self): - self.validate_metadata_server_url_if_any(self._region_url, "region_url") - self.validate_metadata_server_url_if_any(self._security_credentials_url, "url") - self.validate_metadata_server_url_if_any( - self._imdsv2_session_token_url, "imdsv2_session_token_url" - ) - - @staticmethod - def validate_metadata_server_url_if_any(url_string, name_of_data): - if url_string: - url = urlparse(url_string) - if url.hostname != "169.254.169.254" and url.hostname != "fd00:ec2::254": - raise exceptions.InvalidResource( - "Invalid hostname '{}' for '{}'".format(url.hostname, name_of_data) - ) - def retrieve_subject_token(self, request): """Retrieves the subject token using the credential_source object. The subject token is a serialized `AWS GetCallerIdentity signed request`_. diff --git a/system_tests/secrets.tar.enc b/system_tests/secrets.tar.enc index 5cff634c1fb5fed6fafa4bc34d32409a98fed1f3..96d3dc4fd094ce615f4d10685b63cf256bf2a97f 100644 GIT binary patch literal 10324 zcmV-aD67{BB>?tKRTJ@~|DXYMGAUR!44pNq+2=(7?pXAV5ZFK@m=;Z@0#FjFPypAf z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^o@M!?l=}GSd}T;W^m8re<&yEW31=-=Rcq?fh^%H`s@nIx&Fwg}0yQDUq*6Clde5InInv9Pmwl{qhGrQbt5dH?1&A>*&_L zCx^l*j?A&mLU+f^LSyW`TLME@VHE0VU?Nt>im3;PF9V3X<4OjZFx zc+zb!s25lLlp>4d+=ys|bSK!rl;cN&8}?cuHxT-}Aw+hzQYkg^FIQtkTz{@9N*oVs zz;{46!A`2i#VW7D!3((&cfs#SdiGO-Qv7r>m^P-W*7NW=2{&b}aw{5^lnG)GSW5+m z?J*3WMLZrVZ^f0~A+V3Qn;*f$2-g=6NpOYI`kAm(l@*!#ugB90{{Zl*M9MZiBNdHB z>lNg+FPW5!@UKh-4(lrO1i@1-eUAV~$G6p;s3$dB-1z zr(#{Oq9YXV{`=8bGOWDTg)jVRG35wU9F-QT7Oaz{isA&}x8&|iy3>lWKoIjB6tF{# z)7)5rmTRSRAe+r@W~!X^>Pci$6oG(ZxTw8tu|)vYX)chrv^9Mbvdw~^NCJq5)4;`F zm{>XA-`jBJBdNcU5qBWBe6tvAm3Kic7M`XU;Z6h1b~(n~yx4(Ok={kzsU}erH?5ci z{@06XtdM)ao5)UYq9C(kIoKp~QJx){jX-H+S48Az{N!GgA429!qB|3bumQ&vZ`y5u zQ6yOtfl>T7?&BYwXX z+E5$aCM{U}6o>a3eL*UH!9T18<%fWkakDCBchuHNa?M96al>??cNPt$SfUj7f0&=ko_ z0pZLQCtmiH9q8^}$0npYUaR?XiH0n(UMg^OeVnkYsyxP;&nF*4%FCi~=Y5+(IRbt0k mqt|fTf;J5jnKS^FU#o&q-pf)2{{~5)RLa~K|27#zcY{NCQW7Qr diff --git a/tests/test_aws.py b/tests/test_aws.py index 7d87bdba2..805aa3ce2 100644 --- a/tests/test_aws.py +++ b/tests/test_aws.py @@ -1495,39 +1495,6 @@ def test_retrieve_subject_token_success_temp_creds_idmsv2(self, utcnow): credentials.retrieve_subject_token(request) assert not request.called - def test_validate_metadata_server_url_if_any(self): - aws.Credentials.validate_metadata_server_url_if_any( - "http://[fd00:ec2::254]/latest/meta-data/placement/availability-zone", "url" - ) - aws.Credentials.validate_metadata_server_url_if_any( - "http://169.254.169.254/latest/meta-data/placement/availability-zone", "url" - ) - - with pytest.raises(ValueError) as excinfo: - aws.Credentials.validate_metadata_server_url_if_any( - "http://fd00:ec2::254/latest/meta-data/placement/availability-zone", - "url", - ) - assert excinfo.match("Invalid hostname 'fd00' for 'url'") - - with pytest.raises(ValueError) as excinfo: - aws.Credentials.validate_metadata_server_url_if_any( - "http://abc.com/latest/meta-data/placement/availability-zone", "url" - ) - assert excinfo.match("Invalid hostname 'abc.com' for 'url'") - - def test_retrieve_subject_token_invalid_hosts(self): - keys = ["url", "region_url", "imdsv2_session_token_url"] - for key in keys: - credential_source = self.CREDENTIAL_SOURCE.copy() - credential_source[ - key - ] = "http://abc.com/latest/meta-data/iam/security-credentials" - - with pytest.raises(ValueError) as excinfo: - self.make_credentials(credential_source=credential_source) - assert excinfo.match("Invalid hostname 'abc.com' for '{}'".format(key)) - @mock.patch("google.auth._helpers.utcnow") def test_retrieve_subject_token_success_ipv6(self, utcnow): utcnow.return_value = datetime.datetime.strptime(