@@ -39,7 +39,7 @@ class Project(TypedDict):
39
39
"""
40
40
41
41
name : str
42
- git_repo : str
42
+ git_repo : NotRequired [ str ]
43
43
git_tag : NotRequired [str ]
44
44
45
45
@@ -185,7 +185,7 @@ def build_database(
185
185
return database_dir
186
186
187
187
188
- def generate_models (args , name : str , database_dir : str ) -> None :
188
+ def generate_models (args , project : Project , database_dir : str ) -> None :
189
189
"""
190
190
Generate models for a project.
191
191
@@ -194,6 +194,7 @@ def generate_models(args, name: str, database_dir: str) -> None:
194
194
name: The name of the project.
195
195
database_dir: Path to the CodeQL database.
196
196
"""
197
+ name = project ["name" ]
197
198
198
199
generator = mad .Generator (args .lang )
199
200
generator .generateSinks = args .with_sinks
@@ -205,7 +206,7 @@ def generate_models(args, name: str, database_dir: str) -> None:
205
206
206
207
def build_databases_from_projects (
207
208
language : str , extractor_options , projects : List [Project ]
208
- ) -> List [tuple [str , str | None ]]:
209
+ ) -> List [tuple [Project , str | None ]]:
209
210
"""
210
211
Build databases for all projects in parallel.
211
212
@@ -225,7 +226,7 @@ def build_databases_from_projects(
225
226
print ("\n === Building databases ===" )
226
227
database_results = [
227
228
(
228
- project [ "name" ] ,
229
+ project ,
229
230
build_database (language , extractor_options , project , project_dir ),
230
231
)
231
232
for project , project_dir in project_dirs
@@ -290,8 +291,8 @@ def pretty_name_from_artifact_name(artifact_name: str) -> str:
290
291
291
292
292
293
def download_dca_databases (
293
- experiment_name : str , pat : str , projects
294
- ) -> List [tuple [str , str | None ]]:
294
+ experiment_name : str , pat : str , projects : List [ Project ]
295
+ ) -> List [tuple [Project , str | None ]]:
295
296
"""
296
297
Download databases from a DCA experiment.
297
298
Args:
@@ -308,7 +309,7 @@ def download_dca_databases(
308
309
pat ,
309
310
)
310
311
targets = response ["targets" ]
311
- for target , data in targets .items ():
312
+ for data in targets .values ():
312
313
downloads = data ["downloads" ]
313
314
analyzed_database = downloads ["analyzed_database" ]
314
315
artifact_name = analyzed_database ["artifact_name" ]
@@ -349,20 +350,21 @@ def download_dca_databases(
349
350
tar_ref .extractall (artifact_unzipped_location )
350
351
database_results .append (
351
352
(
352
- pretty_name ,
353
+ { "name" : pretty_name } ,
353
354
os .path .join (
354
355
artifact_unzipped_location , remove_extension (entry )
355
356
),
356
357
)
357
358
)
359
+
358
360
print (f"\n === Extracted { len (database_results )} databases ===" )
359
361
360
362
def compare (a , b ):
361
363
a_index = next (
362
- i for i , project in enumerate (projects ) if project ["name" ] == a [0 ]
364
+ i for i , project in enumerate (projects ) if project ["name" ] == a [0 ][ "name" ]
363
365
)
364
366
b_index = next (
365
- i for i , project in enumerate (projects ) if project ["name" ] == b [0 ]
367
+ i for i , project in enumerate (projects ) if project ["name" ] == b [0 ][ "name" ]
366
368
)
367
369
return a_index - b_index
368
370
@@ -431,7 +433,9 @@ def main(config, args) -> None:
431
433
# Generate models for all projects
432
434
print ("\n === Generating models ===" )
433
435
434
- failed_builds = [project for project , db_dir in database_results if db_dir is None ]
436
+ failed_builds = [
437
+ project ["name" ] for project , db_dir in database_results if db_dir is None
438
+ ]
435
439
if failed_builds :
436
440
print (
437
441
f"ERROR: { len (failed_builds )} database builds failed: { ', ' .join (failed_builds )} "
@@ -440,7 +444,7 @@ def main(config, args) -> None:
440
444
441
445
# Delete the MaD directory for each project
442
446
for project , database_dir in database_results :
443
- mad_dir = get_mad_destination_for_project (config , project )
447
+ mad_dir = get_mad_destination_for_project (config , project [ "name" ] )
444
448
if os .path .exists (mad_dir ):
445
449
print (f"Deleting existing MaD directory at { mad_dir } " )
446
450
subprocess .check_call (["rm" , "-rf" , mad_dir ])
0 commit comments