Skip to content

Commit

Permalink
Test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
x4v13r64 committed Mar 17, 2020
1 parent b5da586 commit 65e880c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ScoutSuite/providers/gcp/facade/basefacade.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Since the HTTP library used by the Google API Client library is not
# thread-safe, we leverage https://github.com/GoogleCloudPlatform/httplib2shim
# resolves the following:
# - https://github.com/nccgroup/ScoutSuite/issues/443
# - https://github.com/nccgroup/ScoutSuite/issues/665
import httplib2shim
httplib2shim.patch()

from googleapiclient import discovery

class GCPBaseFacade:
Expand All @@ -10,10 +18,10 @@ def _build_client(self) -> discovery.Resource:
return self._build_arbitrary_client(self._client_name, self._client_version)

def _build_arbitrary_client(self, client_name, client_version):
return discovery.build(client_name, client_version, cache_discovery=False, cache=MemoryCache())
if not self._client:
self._client = discovery.build(client_name, client_version, cache_discovery=False, cache=MemoryCache())
return self._client

# Since the HTTP library used by the Google API Client library is not
# thread-safe, we need to create a new client for each request.
def _get_client(self) -> discovery.Resource:
return self._build_client()

Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ google-cloud-kms>=1.0.0
## API Client Libraries
google-api-python-client>=1.7.8
oauth2client>=4.1.3
## Necessary since API Client Libraries are not thread-safe
httplib2shim>=0.0.3

# Azure Provider
requests>=2.22.0
Expand Down

0 comments on commit 65e880c

Please sign in to comment.