cartography 0.98.0rc3__py3-none-any.whl → 0.98.0rc4__py3-none-any.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 cartography might be problematic. Click here for more details.

cartography/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.98.0rc3'
15
+ __version__ = version = '0.98.0rc4'
16
16
  __version_tuple__ = version_tuple = (0, 98, 0)
@@ -7,9 +7,10 @@ from typing import Set
7
7
 
8
8
  import googleapiclient.discovery
9
9
  import neo4j
10
+ from google.auth import default
11
+ from google.auth.credentials import Credentials as GoogleCredentials
12
+ from google.auth.exceptions import DefaultCredentialsError
10
13
  from googleapiclient.discovery import Resource
11
- from oauth2client.client import ApplicationDefaultCredentialsError
12
- from oauth2client.client import GoogleCredentials
13
14
 
14
15
  from cartography.config import Config
15
16
  from cartography.intel.gcp import compute
@@ -295,10 +296,9 @@ def get_gcp_credentials() -> GoogleCredentials:
295
296
  """
296
297
  try:
297
298
  # Explicitly use Application Default Credentials.
298
- # See https://oauth2client.readthedocs.io/en/latest/source/
299
- # oauth2client.client.html#oauth2client.client.OAuth2Credentials
300
- credentials = GoogleCredentials.get_application_default()
301
- except ApplicationDefaultCredentialsError as e:
299
+ # See https://google-auth.readthedocs.io/en/master/user-guide.html#application-default-credentials
300
+ credentials, project_id = default()
301
+ except DefaultCredentialsError as e:
302
302
  logger.debug("Error occurred calling GoogleCredentials.get_application_default().", exc_info=True)
303
303
  logger.error(
304
304
  (
@@ -5,11 +5,14 @@ import os
5
5
  from collections import namedtuple
6
6
 
7
7
  import googleapiclient.discovery
8
- import httplib2
9
8
  import neo4j
9
+ from google.auth.exceptions import DefaultCredentialsError
10
+ from google.auth.transport.requests import Request
11
+ from google.oauth2 import credentials
12
+ from google.oauth2 import service_account
13
+ from google.oauth2.credentials import Credentials as OAuth2Credentials
14
+ from google.oauth2.service_account import Credentials as ServiceAccountCredentials
10
15
  from googleapiclient.discovery import Resource
11
- from oauth2client.client import ApplicationDefaultCredentialsError
12
- from oauth2client.client import GoogleCredentials
13
16
 
14
17
  from cartography.config import Config
15
18
  from cartography.intel.gsuite import api
@@ -26,21 +29,21 @@ logger = logging.getLogger(__name__)
26
29
  Resources = namedtuple('Resources', 'admin')
27
30
 
28
31
 
29
- def _get_admin_resource(credentials: GoogleCredentials) -> Resource:
32
+ def _get_admin_resource(credentials: OAuth2Credentials | ServiceAccountCredentials) -> Resource:
30
33
  """
31
34
  Instantiates a Google API resource object to call the Google API.
32
35
  Used to pull users and groups. See https://developers.google.com/admin-sdk/directory/v1/guides/manage-users
33
36
 
34
- :param credentials: The GoogleCredentials object
37
+ :param credentials: The credentials object
35
38
  :return: An admin api resource object
36
39
  """
37
40
  return googleapiclient.discovery.build('admin', 'directory_v1', credentials=credentials, cache_discovery=False)
38
41
 
39
42
 
40
- def _initialize_resources(credentials: GoogleCredentials) -> Resources:
43
+ def _initialize_resources(credentials: OAuth2Credentials | ServiceAccountCredentials) -> Resources:
41
44
  """
42
45
  Create namedtuple of all resource objects necessary for Google API data gathering.
43
- :param credentials: The GoogleCredentials object
46
+ :param credentials: The credentials object
44
47
  :return: namedtuple of all resource objects
45
48
  """
46
49
  return Resources(
@@ -61,14 +64,17 @@ def start_gsuite_ingestion(neo4j_session: neo4j.Session, config: Config) -> None
61
64
  "UPDATE_TAG": config.update_tag,
62
65
  }
63
66
 
67
+ creds: OAuth2Credentials | ServiceAccountCredentials
64
68
  if config.gsuite_auth_method == 'delegated': # Legacy delegated method
65
69
  logger.info('Attempting to authenticate to GSuite using legacy delegated method')
66
70
  try:
67
- credentials = GoogleCredentials.from_stream(config.gsuite_config)
68
- credentials = credentials.create_scoped(OAUTH_SCOPE)
69
- credentials = credentials.create_delegated(os.environ.get('GSUITE_DELEGATED_ADMIN'))
71
+ creds = service_account.Credentials.from_service_account_file(
72
+ config.gsuite_config,
73
+ scopes=OAUTH_SCOPE,
74
+ )
75
+ creds = creds.with_subject(os.environ.get('GSUITE_DELEGATED_ADMIN'))
70
76
 
71
- except ApplicationDefaultCredentialsError as e:
77
+ except DefaultCredentialsError as e:
72
78
  logger.error(
73
79
  (
74
80
  "Unable to initialize GSuite creds. If you don't have GSuite data or don't want to load "
@@ -83,18 +89,18 @@ def start_gsuite_ingestion(neo4j_session: neo4j.Session, config: Config) -> None
83
89
  auth_tokens = json.loads(str(base64.b64decode(config.gsuite_config).decode()))
84
90
  logger.info('Attempting to authenticate to GSuite using OAuth')
85
91
  try:
86
- credentials = GoogleCredentials(
87
- None,
88
- auth_tokens['client_id'],
89
- auth_tokens['client_secret'],
90
- auth_tokens['refresh_token'],
91
- None,
92
- auth_tokens['token_uri'],
93
- 'Cartography',
92
+ creds = credentials.Credentials(
93
+ token=None,
94
+ client_id=auth_tokens['client_id'],
95
+ client_secret=auth_tokens['client_secret'],
96
+ refresh_token=auth_tokens['refresh_token'],
97
+ expiry=None,
98
+ token_uri=auth_tokens['token_uri'],
99
+ scopes=OAUTH_SCOPE,
94
100
  )
95
- credentials.refresh(httplib2.Http())
96
- credentials = credentials.create_scoped(OAUTH_SCOPE)
97
- except ApplicationDefaultCredentialsError as e:
101
+ creds.refresh(Request())
102
+ creds = creds.create_scoped(OAUTH_SCOPE)
103
+ except DefaultCredentialsError as e:
98
104
  logger.error(
99
105
  (
100
106
  "Unable to initialize GSuite creds. If you don't have GSuite data or don't want to load "
@@ -106,6 +112,6 @@ def start_gsuite_ingestion(neo4j_session: neo4j.Session, config: Config) -> None
106
112
  )
107
113
  return
108
114
 
109
- resources = _initialize_resources(credentials)
115
+ resources = _initialize_resources(creds)
110
116
  api.sync_gsuite_users(neo4j_session, resources.admin, config.update_tag, common_job_parameters)
111
117
  api.sync_gsuite_groups(neo4j_session, resources.admin, config.update_tag, common_job_parameters)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cartography
3
- Version: 0.98.0rc3
3
+ Version: 0.98.0rc4
4
4
  Summary: Explore assets and their relationships across your technical infrastructure.
5
5
  Maintainer: Cartography Contributors
6
6
  License: apache2
@@ -29,7 +29,7 @@ Requires-Dist: dnspython>=1.15.0
29
29
  Requires-Dist: neo4j<5.0.0,>=4.4.4
30
30
  Requires-Dist: policyuniverse>=1.1.0.0
31
31
  Requires-Dist: google-api-python-client>=1.7.8
32
- Requires-Dist: oauth2client>=4.1.3
32
+ Requires-Dist: google-auth>=2.37.0
33
33
  Requires-Dist: marshmallow>=3.0.0rc7
34
34
  Requires-Dist: oci>=2.71.0
35
35
  Requires-Dist: okta<1.0.0
@@ -1,6 +1,6 @@
1
1
  cartography/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  cartography/__main__.py,sha256=JftXT_nUPkqcEh8uxCCT4n-OyHYqbldEgrDS-4ygy0U,101
3
- cartography/_version.py,sha256=S3NFuE-lXnEY5jp6jj2rWIR_80fYZi_neDtpyro9xU0,416
3
+ cartography/_version.py,sha256=0sgJhYfa51TBEnCTxKv6kmE6_0dlbwqFC4kFMbUT6nM,416
4
4
  cartography/cli.py,sha256=LPjeOkx-cKhRkuhqMicB-0X3SHOjLXxEeGqsp2FtpC0,33285
5
5
  cartography/config.py,sha256=ZcadsKmooAkti9Kv0eDl8Ec1PcZDu3lWobtNaCnwY3k,11872
6
6
  cartography/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -222,7 +222,7 @@ cartography/intel/duo/phones.py,sha256=ueJheqSLD2xYcMus5eOiixPYS3_xVjgQzeomjV2a6
222
222
  cartography/intel/duo/tokens.py,sha256=bEEnjfc4waQnkRHVSnZLAeGE8wHOOZL7FA9m80GGQdQ,2396
223
223
  cartography/intel/duo/users.py,sha256=lc7ly_XKeUjJ50szw31WT_GiCrZfGKJv1zVUpmTchh4,4097
224
224
  cartography/intel/duo/web_authn_credentials.py,sha256=IbDf3CWqfEyI7f9zJugUvoDd6vZOECfb_7ANZaRYzuk,2636
225
- cartography/intel/gcp/__init__.py,sha256=jJOT6Ys97qm1W0jGXFwtSOOSGPa7q-Xxr1YIR8fKejo,15849
225
+ cartography/intel/gcp/__init__.py,sha256=raPnE8b4WAwLfWJwU2D3JJwSnENHBRi_Bv9x-pMavdQ,15813
226
226
  cartography/intel/gcp/compute.py,sha256=CH2cBdOwbLZCAbkfRJkkI-sFybXVKRWEUGDJANQmvyA,48333
227
227
  cartography/intel/gcp/crm.py,sha256=Uw5PILhVFhpM8gq7uu2v7F_YikDW3gsTZ3d7-e8Z1_k,12324
228
228
  cartography/intel/gcp/dns.py,sha256=y2pvbmV04cnrMyuu_nbW3oc7uwHX6yEzn1n7veCsjmk,7748
@@ -233,7 +233,7 @@ cartography/intel/github/repos.py,sha256=MmpxZASDJFQxDeSMxX3pZcpxCHFPos4_uYC_cX9
233
233
  cartography/intel/github/teams.py,sha256=AltQSmBHHmyzBtnRkez9Bo5yChEKBSt3wwzhGcfqmX4,14180
234
234
  cartography/intel/github/users.py,sha256=MCLE0V0UCzQm3k3KmrNe6PYkI6usRQZYy2rCN3mT8o0,8948
235
235
  cartography/intel/github/util.py,sha256=K0cXOPuhnGvN-aqcSUBO3vTuKQLjufVal9kn2HwOpbo,8110
236
- cartography/intel/gsuite/__init__.py,sha256=AGIUskGlLCVGHbnQicNpNWi9AvmV7_7hUKTt-hsB2J8,4306
236
+ cartography/intel/gsuite/__init__.py,sha256=Ed5Lab8E_OpRY1JM7NBaQwajfbG2MCACU21xKS9_ETY,4636
237
237
  cartography/intel/gsuite/api.py,sha256=qgEnAcajYGsgC5XNKMnYxOli8Su9wooaEnBBEpsk2EY,10336
238
238
  cartography/intel/jamf/__init__.py,sha256=Nof-LrUeevoieo6oP2GyfTwx8k5TUIgreW6hSj53YjQ,419
239
239
  cartography/intel/jamf/computers.py,sha256=EfjlupQ-9HYTjOrmuwrGuJDy9ApAnJvk8WrYcp6_Jkk,1673
@@ -354,9 +354,9 @@ cartography/models/snipeit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
354
354
  cartography/models/snipeit/asset.py,sha256=FyRAaeXuZjMy0eUQcSDFcgEAF5lbLMlvqp1Tv9d3Lv4,3238
355
355
  cartography/models/snipeit/tenant.py,sha256=p4rFnpNNuF1W5ilGBbexDaETWTwavfb38RcQGoImkQI,679
356
356
  cartography/models/snipeit/user.py,sha256=MsB4MiCVNTH6JpESime7cOkB89autZOXQpL6Z0l7L6o,2113
357
- cartography-0.98.0rc3.dist-info/LICENSE,sha256=kvLEBRYaQ1RvUni6y7Ti9uHeooqnjPoo6n_-0JO1ETc,11351
358
- cartography-0.98.0rc3.dist-info/METADATA,sha256=NIyigTeWT6-lGT8j30ZoCOjvHAgCO2RJLFIn91vLx5M,11473
359
- cartography-0.98.0rc3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
360
- cartography-0.98.0rc3.dist-info/entry_points.txt,sha256=GVIAWD0o0_K077qMA_k1oZU4v-M0a8GLKGJR8tZ-qH8,112
361
- cartography-0.98.0rc3.dist-info/top_level.txt,sha256=BHqsNJQiI6Q72DeypC1IINQJE59SLhU4nllbQjgJi9g,12
362
- cartography-0.98.0rc3.dist-info/RECORD,,
357
+ cartography-0.98.0rc4.dist-info/LICENSE,sha256=kvLEBRYaQ1RvUni6y7Ti9uHeooqnjPoo6n_-0JO1ETc,11351
358
+ cartography-0.98.0rc4.dist-info/METADATA,sha256=4GIMY8-iRiXERs3qgTwJXTwwIy2nUvfSVgFBPIcGldE,11473
359
+ cartography-0.98.0rc4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
360
+ cartography-0.98.0rc4.dist-info/entry_points.txt,sha256=GVIAWD0o0_K077qMA_k1oZU4v-M0a8GLKGJR8tZ-qH8,112
361
+ cartography-0.98.0rc4.dist-info/top_level.txt,sha256=BHqsNJQiI6Q72DeypC1IINQJE59SLhU4nllbQjgJi9g,12
362
+ cartography-0.98.0rc4.dist-info/RECORD,,