cartography 0.96.0rc1__py3-none-any.whl → 0.96.0rc3__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.

Files changed (29) hide show
  1. cartography/cli.py +15 -0
  2. cartography/client/core/tx.py +1 -1
  3. cartography/config.py +6 -2
  4. cartography/data/indexes.cypher +1 -2
  5. cartography/data/jobs/cleanup/aws_import_identity_center_cleanup.json +16 -0
  6. cartography/data/jobs/cleanup/{github_users_cleanup.json → github_org_and_users_cleanup.json} +5 -0
  7. cartography/intel/aws/apigateway.py +3 -3
  8. cartography/intel/aws/identitycenter.py +307 -0
  9. cartography/intel/aws/resources.py +2 -0
  10. cartography/intel/cve/__init__.py +1 -1
  11. cartography/intel/cve/feed.py +4 -4
  12. cartography/intel/github/users.py +156 -39
  13. cartography/intel/okta/users.py +2 -1
  14. cartography/intel/semgrep/__init__.py +1 -1
  15. cartography/intel/semgrep/dependencies.py +54 -22
  16. cartography/models/aws/identitycenter/__init__.py +0 -0
  17. cartography/models/aws/identitycenter/awsidentitycenter.py +44 -0
  18. cartography/models/aws/identitycenter/awspermissionset.py +84 -0
  19. cartography/models/aws/identitycenter/awsssouser.py +68 -0
  20. cartography/models/github/orgs.py +26 -0
  21. cartography/models/github/users.py +119 -0
  22. cartography/models/semgrep/dependencies.py +13 -0
  23. cartography-0.96.0rc3.dist-info/METADATA +53 -0
  24. {cartography-0.96.0rc1.dist-info → cartography-0.96.0rc3.dist-info}/RECORD +28 -20
  25. {cartography-0.96.0rc1.dist-info → cartography-0.96.0rc3.dist-info}/WHEEL +1 -1
  26. cartography-0.96.0rc1.dist-info/METADATA +0 -53
  27. {cartography-0.96.0rc1.dist-info → cartography-0.96.0rc3.dist-info}/LICENSE +0 -0
  28. {cartography-0.96.0rc1.dist-info → cartography-0.96.0rc3.dist-info}/entry_points.txt +0 -0
  29. {cartography-0.96.0rc1.dist-info → cartography-0.96.0rc3.dist-info}/top_level.txt +0 -0
cartography/cli.py CHANGED
@@ -9,6 +9,7 @@ import cartography.config
9
9
  import cartography.sync
10
10
  import cartography.util
11
11
  from cartography.intel.aws.util.common import parse_and_validate_aws_requested_syncs
12
+ from cartography.intel.semgrep.dependencies import parse_and_validate_semgrep_ecosystems
12
13
 
13
14
 
14
15
  logger = logging.getLogger(__name__)
@@ -524,6 +525,17 @@ class CLI:
524
525
  'Required if you are using the Semgrep intel module. Ignored otherwise.'
525
526
  ),
526
527
  )
528
+ parser.add_argument(
529
+ '--semgrep-dependency-ecosystems',
530
+ type=str,
531
+ default=None,
532
+ help=(
533
+ 'Comma-separated list of language ecosystems for which dependencies will be retrieved from Semgrep. '
534
+ 'For example, a value of "gomod,npm" will retrieve Go and NPM dependencies. '
535
+ 'See the full list of supported ecosystems in source code at cartography.intel.semgrep.dependencies. '
536
+ 'Required if you are using the Semgrep dependencies intel module. Ignored otherwise.'
537
+ ),
538
+ )
527
539
  parser.add_argument(
528
540
  '--snipeit-base-uri',
529
541
  type=str,
@@ -734,6 +746,9 @@ class CLI:
734
746
  config.semgrep_app_token = os.environ.get(config.semgrep_app_token_env_var)
735
747
  else:
736
748
  config.semgrep_app_token = None
749
+ if config.semgrep_dependency_ecosystems:
750
+ # No need to store the returned value; we're using this for input validation.
751
+ parse_and_validate_semgrep_ecosystems(config.semgrep_dependency_ecosystems)
737
752
 
738
753
  # CVE feed config
739
754
  if config.cve_api_key_env_var:
@@ -122,7 +122,7 @@ def read_list_of_tuples_tx(tx: neo4j.Transaction, query: str, **kwargs) -> List[
122
122
  return [tuple(val) for val in values]
123
123
 
124
124
 
125
- def read_single_dict_tx(tx: neo4j.Transaction, query: str, **kwargs) -> Dict[str, Any]:
125
+ def read_single_dict_tx(tx: neo4j.Transaction, query: str, **kwargs) -> Any:
126
126
  """
127
127
  Runs the given Neo4j query in the given transaction object and returns the single dict result. This is intended to
128
128
  be run only with queries that return a single dict.
cartography/config.py CHANGED
@@ -107,6 +107,8 @@ class Config:
107
107
  :param duo_api_hostname: The Duo api hostname, e.g. "api-abc123.duosecurity.com". Optional.
108
108
  :param semgrep_app_token: The Semgrep api token. Optional.
109
109
  :type semgrep_app_token: str
110
+ :param semgrep_dependency_ecosystems: Comma-separated list of Semgrep dependency ecosystems to fetch. Optional.
111
+ :type semgrep_dependency_ecosystems: str
110
112
  :type snipeit_base_uri: string
111
113
  :param snipeit_base_uri: SnipeIT data provider base URI. Optional.
112
114
  :type snipeit_token: string
@@ -155,7 +157,7 @@ class Config:
155
157
  pagerduty_request_timeout=None,
156
158
  nist_cve_url=None,
157
159
  cve_enabled=False,
158
- cve_api_key=None,
160
+ cve_api_key: str | None = None,
159
161
  crowdstrike_client_id=None,
160
162
  crowdstrike_client_secret=None,
161
163
  crowdstrike_api_url=None,
@@ -170,6 +172,7 @@ class Config:
170
172
  duo_api_secret=None,
171
173
  duo_api_hostname=None,
172
174
  semgrep_app_token=None,
175
+ semgrep_dependency_ecosystems=None,
173
176
  snipeit_base_uri=None,
174
177
  snipeit_token=None,
175
178
  snipeit_tenant_id=None,
@@ -212,7 +215,7 @@ class Config:
212
215
  self.pagerduty_request_timeout = pagerduty_request_timeout
213
216
  self.nist_cve_url = nist_cve_url
214
217
  self.cve_enabled = cve_enabled
215
- self.cve_api_key = cve_api_key
218
+ self.cve_api_key: str | None = cve_api_key
216
219
  self.crowdstrike_client_id = crowdstrike_client_id
217
220
  self.crowdstrike_client_secret = crowdstrike_client_secret
218
221
  self.crowdstrike_api_url = crowdstrike_api_url
@@ -227,6 +230,7 @@ class Config:
227
230
  self.duo_api_secret = duo_api_secret
228
231
  self.duo_api_hostname = duo_api_hostname
229
232
  self.semgrep_app_token = semgrep_app_token
233
+ self.semgrep_dependency_ecosystems = semgrep_dependency_ecosystems
230
234
  self.snipeit_base_uri = snipeit_base_uri
231
235
  self.snipeit_token = snipeit_token
232
236
  self.snipeit_tenant_id = snipeit_tenant_id
@@ -305,8 +305,7 @@ CREATE INDEX IF NOT EXISTS FOR (n:SpotlightVulnerability) ON (n.host_info_local_
305
305
  CREATE INDEX IF NOT EXISTS FOR (n:SpotlightVulnerability) ON (n.lastupdated);
306
306
  CREATE INDEX IF NOT EXISTS FOR (n:SQSQueue) ON (n.id);
307
307
  CREATE INDEX IF NOT EXISTS FOR (n:SQSQueue) ON (n.lastupdated);
308
- CREATE INDEX IF NOT EXISTS FOR (n:User) ON (n.arn);
309
- CREATE INDEX IF NOT EXISTS FOR (n:User) ON (n.lastupdated);
308
+ CREATE INDEX IF NOT EXISTS FOR (n:UserAccount) ON (n.id);
310
309
  CREATE INDEX IF NOT EXISTS FOR (n:AzureTenant) ON (n.id);
311
310
  CREATE INDEX IF NOT EXISTS FOR (n:AzureTenant) ON (n.lastupdated);
312
311
  CREATE INDEX IF NOT EXISTS FOR (n:AzurePrincipal) ON (n.email);
@@ -0,0 +1,16 @@
1
+ {
2
+ "statements": [
3
+
4
+ {
5
+ "query": "MATCH (:AWSAccount{id: $AWS_ID})-[:RESOURCE]->(:AWSSSOUser)<-[r:CAN_ASSUME_IDENTITY]-(:OktaUser) WHERE r.lastupdated <> $UPDATE_TAG WITH r LIMIT $LIMIT_SIZE DELETE (r) RETURN COUNT(*) as TotalDeleted",
6
+ "iterative": true,
7
+ "iterationsize": 100
8
+ },
9
+ {
10
+ "query": "MATCH (:AWSAccount{id: $AWS_ID})-[:RESOURCE]->(:AWSRole)-[r:ALLOWED_BY]->(:AWSSSOUser) WHERE r.lastupdated <> $UPDATE_TAG WITH r LIMIT $LIMIT_SIZE DELETE (r) RETURN COUNT(*) as TotalDeleted",
11
+ "iterative": true,
12
+ "iterationsize": 100
13
+ }
14
+ ],
15
+ "name": "cleanup AWS Identity Center Instances and Related Data"
16
+ }
@@ -18,6 +18,11 @@
18
18
  "query": "MATCH (:GitHubUser)-[r:MEMBER_OF]->(:GitHubOrganization) WHERE r.lastupdated <> $UPDATE_TAG WITH r LIMIT $LIMIT_SIZE DELETE (r)",
19
19
  "iterative": true,
20
20
  "iterationsize": 100
21
+ },
22
+ {
23
+ "query": "MATCH (:GitHubUser)-[r:UNAFFILIATED]->(:GitHubOrganization) WHERE r.lastupdated <> $UPDATE_TAG WITH r LIMIT $LIMIT_SIZE DELETE (r)",
24
+ "iterative": true,
25
+ "iterationsize": 100
21
26
  }],
22
27
  "name": "cleanup GitHub users data"
23
28
  }
@@ -43,7 +43,7 @@ def get_rest_api_details(
43
43
  for api in rest_apis:
44
44
  stages = get_rest_api_stages(api, client)
45
45
  # clientcertificate id is given by the api stage
46
- certificate = get_rest_api_client_certificate(stages, client) # type: ignore
46
+ certificate = get_rest_api_client_certificate(stages, client)
47
47
  resources = get_rest_api_resources(api, client)
48
48
  policy = get_rest_api_policy(api, client)
49
49
  apis.append((api['id'], stages, certificate, resources, policy))
@@ -51,7 +51,7 @@ def get_rest_api_details(
51
51
 
52
52
 
53
53
  @timeit
54
- def get_rest_api_stages(api: Dict, client: botocore.client.BaseClient) -> List[Any]:
54
+ def get_rest_api_stages(api: Dict, client: botocore.client.BaseClient) -> Any:
55
55
  """
56
56
  Gets the REST API Stage Resources.
57
57
  """
@@ -99,7 +99,7 @@ def get_rest_api_resources(api: Dict, client: botocore.client.BaseClient) -> Lis
99
99
 
100
100
 
101
101
  @timeit
102
- def get_rest_api_policy(api: Dict, client: botocore.client.BaseClient) -> List[Any]:
102
+ def get_rest_api_policy(api: Dict, client: botocore.client.BaseClient) -> Any:
103
103
  """
104
104
  Gets the REST API policy. Returns policy string or None if no policy is present.
105
105
  """
@@ -0,0 +1,307 @@
1
+ import logging
2
+ from typing import Any
3
+ from typing import Dict
4
+ from typing import List
5
+
6
+ import boto3
7
+ import neo4j
8
+
9
+ from cartography.client.core.tx import load
10
+ from cartography.graph.job import GraphJob
11
+ from cartography.models.aws.identitycenter.awsidentitycenter import AWSIdentityCenterInstanceSchema
12
+ from cartography.models.aws.identitycenter.awspermissionset import AWSPermissionSetSchema
13
+ from cartography.models.aws.identitycenter.awsssouser import AWSSSOUserSchema
14
+ from cartography.util import aws_handle_regions
15
+ from cartography.util import run_cleanup_job
16
+ from cartography.util import timeit
17
+ logger = logging.getLogger(__name__)
18
+
19
+
20
+ @timeit
21
+ @aws_handle_regions
22
+ def get_identity_center_instances(boto3_session: boto3.session.Session, region: str) -> List[Dict]:
23
+ """
24
+ Get all AWS IAM Identity Center instances in the current region
25
+ """
26
+ client = boto3_session.client('sso-admin', region_name=region)
27
+ instances = []
28
+
29
+ paginator = client.get_paginator('list_instances')
30
+ for page in paginator.paginate():
31
+ instances.extend(page.get('Instances', []))
32
+
33
+ return instances
34
+
35
+
36
+ @timeit
37
+ def load_identity_center_instances(
38
+ neo4j_session: neo4j.Session,
39
+ instance_data: List[Dict],
40
+ region: str,
41
+ current_aws_account_id: str,
42
+ aws_update_tag: int,
43
+ ) -> None:
44
+ """
45
+ Load Identity Center instances into the graph
46
+ """
47
+ logger.info(f"Loading {len(instance_data)} Identity Center instances for region {region}")
48
+ load(
49
+ neo4j_session,
50
+ AWSIdentityCenterInstanceSchema(),
51
+ instance_data,
52
+ lastupdated=aws_update_tag,
53
+ Region=region,
54
+ AWS_ID=current_aws_account_id,
55
+ )
56
+
57
+
58
+ @timeit
59
+ def get_permission_sets(boto3_session: boto3.session.Session, instance_arn: str, region: str) -> List[Dict]:
60
+ """
61
+ Get all permission sets for a given Identity Center instance
62
+ """
63
+ client = boto3_session.client('sso-admin', region_name=region)
64
+ permission_sets = []
65
+
66
+ paginator = client.get_paginator('list_permission_sets')
67
+ for page in paginator.paginate(InstanceArn=instance_arn):
68
+ # Get detailed info for each permission set
69
+ for arn in page.get('PermissionSets', []):
70
+ details = client.describe_permission_set(
71
+ InstanceArn=instance_arn,
72
+ PermissionSetArn=arn,
73
+ )
74
+ permission_set = details.get('PermissionSet', {})
75
+ if permission_set:
76
+ permission_set['RoleHint'] = (
77
+ f":role/aws-reserved/sso.amazonaws.com/AWSReservedSSO_{permission_set.get('Name')}"
78
+ )
79
+ permission_sets.append(permission_set)
80
+
81
+ return permission_sets
82
+
83
+
84
+ @timeit
85
+ def get_permission_set_roles(
86
+ boto3_session: boto3.session.Session,
87
+ instance_arn: str,
88
+ permission_set_arn: str,
89
+ region: str,
90
+ ) -> List[Dict]:
91
+ """
92
+ Get all accounts associated with a given permission set
93
+ """
94
+ client = boto3_session.client('sso-admin', region_name=region)
95
+ accounts = []
96
+
97
+ paginator = client.get_paginator('list_accounts_for_provisioned_permission_set')
98
+ for page in paginator.paginate(InstanceArn=instance_arn, PermissionSetArn=permission_set_arn):
99
+ accounts.extend(page.get('AccountIds', []))
100
+
101
+ return accounts
102
+
103
+
104
+ @timeit
105
+ def load_permission_sets(
106
+ neo4j_session: neo4j.Session,
107
+ permission_sets: List[Dict],
108
+ instance_arn: str,
109
+ region: str,
110
+ aws_account_id: str,
111
+ aws_update_tag: int,
112
+ ) -> None:
113
+ """
114
+ Load Identity Center permission sets into the graph
115
+ """
116
+ logger.info(f"Loading {len(permission_sets)} permission sets for instance {instance_arn} in region {region}")
117
+
118
+ load(
119
+ neo4j_session,
120
+ AWSPermissionSetSchema(),
121
+ permission_sets,
122
+ lastupdated=aws_update_tag,
123
+ InstanceArn=instance_arn,
124
+ Region=region,
125
+ AWS_ID=aws_account_id,
126
+ )
127
+
128
+
129
+ @timeit
130
+ def get_sso_users(
131
+ boto3_session: boto3.session.Session,
132
+ identity_store_id: str,
133
+ region: str,
134
+ ) -> List[Dict]:
135
+ """
136
+ Get all SSO users for a given Identity Store
137
+ """
138
+ client = boto3_session.client('identitystore', region_name=region)
139
+ users = []
140
+
141
+ paginator = client.get_paginator('list_users')
142
+ for page in paginator.paginate(IdentityStoreId=identity_store_id):
143
+ user_page = page.get('Users', [])
144
+ for user in user_page:
145
+ if user.get('ExternalIds', None):
146
+ user['ExternalId'] = user.get('ExternalIds')[0].get('Id')
147
+ users.append(user)
148
+
149
+ return users
150
+
151
+
152
+ @timeit
153
+ def load_sso_users(
154
+ neo4j_session: neo4j.Session,
155
+ users: List[Dict],
156
+ identity_store_id: str,
157
+ region: str,
158
+ aws_account_id: str,
159
+ aws_update_tag: int,
160
+ ) -> None:
161
+ """
162
+ Load SSO users into the graph
163
+ """
164
+ logger.info(f"Loading {len(users)} SSO users for identity store {identity_store_id} in region {region}")
165
+
166
+ load(
167
+ neo4j_session,
168
+ AWSSSOUserSchema(),
169
+ users,
170
+ lastupdated=aws_update_tag,
171
+ IdentityStoreId=identity_store_id,
172
+ AWS_ID=aws_account_id,
173
+ Region=region,
174
+ )
175
+
176
+
177
+ @timeit
178
+ def get_role_assignments(
179
+ boto3_session: boto3.session.Session,
180
+ users: List[Dict],
181
+ instance_arn: str,
182
+ region: str,
183
+ ) -> List[Dict]:
184
+ """
185
+ Get role assignments for SSO users
186
+ """
187
+
188
+ logger.info(f"Getting role assignments for {len(users)} users")
189
+ client = boto3_session.client('sso-admin', region_name=region)
190
+ role_assignments = []
191
+
192
+ for user in users:
193
+ user_id = user['UserId']
194
+ paginator = client.get_paginator('list_account_assignments_for_principal')
195
+ for page in paginator.paginate(InstanceArn=instance_arn, PrincipalId=user_id, PrincipalType='USER'):
196
+ for assignment in page.get('AccountAssignments', []):
197
+ role_assignments.append({
198
+ 'UserId': user_id,
199
+ 'PermissionSetArn': assignment.get('PermissionSetArn'),
200
+ 'AccountId': assignment.get('AccountId'),
201
+ })
202
+
203
+ return role_assignments
204
+
205
+
206
+ @timeit
207
+ def load_role_assignments(
208
+ neo4j_session: neo4j.Session,
209
+ role_assignments: List[Dict],
210
+ aws_update_tag: int,
211
+ ) -> None:
212
+ """
213
+ Load role assignments into the graph
214
+ """
215
+ logger.info(f"Loading {len(role_assignments)} role assignments")
216
+ if role_assignments:
217
+ neo4j_session.run(
218
+ """
219
+ UNWIND $role_assignments AS ra
220
+ MATCH (acc:AWSAccount{id:ra.AccountId}) -[:RESOURCE]->
221
+ (role:AWSRole)<-[:ASSIGNED_TO_ROLE]-
222
+ (permset:AWSPermissionSet {id: ra.PermissionSetArn})
223
+ MATCH (sso:AWSSSOUser {id: ra.UserId})
224
+ MERGE (role)-[r:ALLOWED_BY]->(sso)
225
+ SET r.lastupdated = $aws_update_tag,
226
+ r.permission_set_arn = ra.PermissionSetArn
227
+ """,
228
+ role_assignments=role_assignments,
229
+ aws_update_tag=aws_update_tag,
230
+ )
231
+
232
+
233
+ def cleanup(neo4j_session: neo4j.Session, common_job_parameters: Dict[str, Any]) -> None:
234
+ GraphJob.from_node_schema(AWSIdentityCenterInstanceSchema(), common_job_parameters).run(neo4j_session)
235
+ GraphJob.from_node_schema(AWSPermissionSetSchema(), common_job_parameters).run(neo4j_session)
236
+ GraphJob.from_node_schema(AWSSSOUserSchema(), common_job_parameters).run(neo4j_session)
237
+ run_cleanup_job(
238
+ 'aws_import_identity_center_cleanup.json',
239
+ neo4j_session,
240
+ common_job_parameters,
241
+ )
242
+
243
+
244
+ @timeit
245
+ def sync_identity_center_instances(
246
+ neo4j_session: neo4j.Session,
247
+ boto3_session: boto3.session.Session,
248
+ regions: List[str],
249
+ current_aws_account_id: str,
250
+ update_tag: int,
251
+ common_job_parameters: Dict,
252
+ ) -> None:
253
+ """
254
+ Sync Identity Center instances, their permission sets, and SSO users
255
+ """
256
+ logger.info(f"Syncing Identity Center instances for regions {regions}")
257
+ for region in regions:
258
+ logger.info(f"Syncing Identity Center instances for region {region}")
259
+ instances = get_identity_center_instances(boto3_session, region)
260
+ load_identity_center_instances(
261
+ neo4j_session,
262
+ instances,
263
+ region,
264
+ current_aws_account_id,
265
+ update_tag,
266
+ )
267
+
268
+ # For each instance, get and load its permission sets and SSO users
269
+ for instance in instances:
270
+ instance_arn = instance['InstanceArn']
271
+ identity_store_id = instance['IdentityStoreId']
272
+
273
+ permission_sets = get_permission_sets(boto3_session, instance_arn, region)
274
+
275
+ load_permission_sets(
276
+ neo4j_session,
277
+ permission_sets,
278
+ instance_arn,
279
+ region,
280
+ current_aws_account_id,
281
+ update_tag,
282
+ )
283
+
284
+ users = get_sso_users(boto3_session, identity_store_id, region)
285
+ load_sso_users(
286
+ neo4j_session,
287
+ users,
288
+ identity_store_id,
289
+ region,
290
+ current_aws_account_id,
291
+ update_tag,
292
+ )
293
+
294
+ # Get and load role assignments
295
+ role_assignments = get_role_assignments(
296
+ boto3_session,
297
+ users,
298
+ instance_arn,
299
+ region,
300
+ )
301
+ load_role_assignments(
302
+ neo4j_session,
303
+ role_assignments,
304
+ update_tag,
305
+ )
306
+
307
+ cleanup(neo4j_session, common_job_parameters)
@@ -10,6 +10,7 @@ from . import elasticache
10
10
  from . import elasticsearch
11
11
  from . import emr
12
12
  from . import iam
13
+ from . import identitycenter
13
14
  from . import inspector
14
15
  from . import kms
15
16
  from . import lambda_function
@@ -88,4 +89,5 @@ RESOURCE_FUNCTIONS: Dict = {
88
89
  'ssm': ssm.sync,
89
90
  'inspector': inspector.sync,
90
91
  'config': config.sync,
92
+ 'identitycenter': identitycenter.sync_identity_center_instances,
91
93
  }
@@ -25,7 +25,7 @@ def start_cve_ingestion(
25
25
  """
26
26
  if not config.cve_enabled:
27
27
  return
28
- cve_api_key = config.cve_api_key if config.cve_api_key else None
28
+ cve_api_key: str | None = config.cve_api_key if config.cve_api_key else None
29
29
 
30
30
  # sync CVE year archives, if not yet synced
31
31
  existing_years = feed.get_cve_sync_metadata(neo4j_session)
@@ -68,7 +68,7 @@ def _map_cve_dict(cve_dict: Dict[Any, Any], data: Dict[Any, Any]) -> None:
68
68
  cve_dict["startIndex"] = data["startIndex"]
69
69
 
70
70
 
71
- def _call_cves_api(url: str, api_key: str, params: Dict[str, Any]) -> Dict[Any, Any]:
71
+ def _call_cves_api(url: str, api_key: str | None, params: Dict[str, Any]) -> Dict[Any, Any]:
72
72
  totalResults = 0
73
73
  sleep_time = DEFAULT_SLEEP_TIME
74
74
  retries = 0
@@ -114,7 +114,7 @@ def get_cves_in_batches(
114
114
  start_date: datetime,
115
115
  end_date: datetime,
116
116
  date_param_names: Dict[str, str],
117
- api_key: str,
117
+ api_key: str | None,
118
118
  ) -> Dict[Any, Any]:
119
119
  cves: Dict[Any, Any] = dict()
120
120
  current_start_date: datetime = start_date
@@ -153,7 +153,7 @@ def get_cves_in_batches(
153
153
 
154
154
 
155
155
  def get_modified_cves(
156
- nist_cve_url: str, last_modified_date: str, api_key: str,
156
+ nist_cve_url: str, last_modified_date: str, api_key: str | None,
157
157
  ) -> Dict[Any, Any]:
158
158
  cves = dict()
159
159
  end_date = datetime.now(tz=timezone.utc)
@@ -171,7 +171,7 @@ def get_modified_cves(
171
171
 
172
172
 
173
173
  def get_published_cves_per_year(
174
- nist_cve_url: str, year: str, api_key: str,
174
+ nist_cve_url: str, year: str, api_key: str | None,
175
175
  ) -> Dict[Any, Any]:
176
176
  cves = {}
177
177
  start_of_year = datetime.strptime(f"{year}-01-01", "%Y-%m-%d")