@@ -426,40 +426,54 @@ func (s *VulnDBService) populateDBFromGobs(ctx context.Context, tx pgx.Tx, worki
426426
427427 if lastImportTime .IsZero () {
428428 group .Go (func () error {
429- slog .Info ("full import: truncating vulndb tables" )
430- return truncateVulnDBTables (ctx , tx )
429+ t := time .Now ()
430+ slog .Info ("start truncating vulndb tables" )
431+ if err := truncateVulnDBTables (ctx , tx ); err != nil {
432+ return err
433+ }
434+ slog .Info ("finished truncating vulndb tables" , "took" , time .Since (t ).Round (time .Millisecond ))
435+ return nil
431436 })
432437 }
433438
434439 group .Go (func () error {
440+ t := time .Now ()
435441 if err := readGobFile (workingDir + "/osv.gob" , & osvEntries ); err != nil {
436442 return fmt .Errorf ("could not read OSV gob: %w" , err )
437443 }
438- slog .Info ("decoded OSV gob file " , "amount " , len (osvEntries ))
444+ slog .Info ("finished decoding OSV gob" , "entries " , len (osvEntries ), "took" , time . Since ( t ). Round ( time . Millisecond ))
439445 return nil
440446 })
441447 group .Go (func () error {
448+ t := time .Now ()
442449 if err := readGobFile (workingDir + "/epss.gob" , & epssData ); err != nil {
443450 return fmt .Errorf ("could not read EPSS gob: %w" , err )
444451 }
452+ slog .Info ("finished decoding EPSS gob" , "entries" , len (epssData ), "took" , time .Since (t ).Round (time .Millisecond ))
445453 return nil
446454 })
447455 group .Go (func () error {
456+ t := time .Now ()
448457 if err := readGobFile (workingDir + "/cisakev.gob" , & kevEntries ); err != nil {
449458 return fmt .Errorf ("could not read CISA KEV gob: %w" , err )
450459 }
460+ slog .Info ("finished decoding CISA KEV gob" , "entries" , len (kevEntries ), "took" , time .Since (t ).Round (time .Millisecond ))
451461 return nil
452462 })
453463 group .Go (func () error {
464+ t := time .Now ()
454465 if err := readGobFile (workingDir + "/exploits.gob" , & gobExploit ); err != nil {
455466 return fmt .Errorf ("could not read exploits gob: %w" , err )
456467 }
468+ slog .Info ("finished decoding exploits gob" , "entries" , len (gobExploit ), "took" , time .Since (t ).Round (time .Millisecond ))
457469 return nil
458470 })
459471 group .Go (func () error {
472+ t := time .Now ()
460473 if err := readGobFile (workingDir + "/maliciouspackages.gob" , & malExport ); err != nil {
461474 return fmt .Errorf ("could not read malicious packages gob: %w" , err )
462475 }
476+ slog .Info ("finished decoding malicious packages gob" , "took" , time .Since (t ).Round (time .Millisecond ))
463477 return nil
464478 })
465479 if err := group .Wait (); err != nil {
@@ -470,31 +484,40 @@ func (s *VulnDBService) populateDBFromGobs(ctx context.Context, tx pgx.Tx, worki
470484 exploits := gobExploitsToModels (gobExploit , lastImportTime )
471485 pkgs , comps := gobMalPackagesExportToModels (malExport , lastImportTime )
472486
473- slog .Info ("applying OSV data" )
487+ t := time .Now ()
488+ slog .Info ("start applying OSV data" , "entries" , len (osvEntries ), "incremental" , ! lastImportTime .IsZero ())
474489 if err := s .osv .applyOSVEntries (ctx , tx , osvEntries , lastImportTime ); err != nil {
475490 return fmt .Errorf ("OSV import failed: %w" , err )
476491 }
492+ slog .Info ("finished applying OSV data" , "took" , time .Since (t ).Round (time .Millisecond ))
477493
478- slog .Info ("applying EPSS data" , "entries" , len (epssData ))
494+ t = time .Now ()
495+ slog .Info ("start applying EPSS data" , "entries" , len (epssData ))
479496 if err := insertEPSSBulk (ctx , tx , epssData ); err != nil {
480497 return fmt .Errorf ("could not apply EPSS data: %w" , err )
481498 }
499+ slog .Info ("finished applying EPSS data" , "took" , time .Since (t ).Round (time .Millisecond ))
482500
483- slog .Info ("applying CISA KEV data" , "entries" , len (kevEntries ))
501+ t = time .Now ()
502+ slog .Info ("start applying CISA KEV data" , "entries" , len (kevEntries ))
484503 if err := insertCISAKEVBulk (ctx , tx , kevEntries ); err != nil {
485504 return fmt .Errorf ("could not apply CISA KEV data: %w" , err )
486505 }
506+ slog .Info ("finished applying CISA KEV data" , "took" , time .Since (t ).Round (time .Millisecond ))
487507
488- slog .Info ("applying exploit data" , "entries" , len (exploits ))
508+ t = time .Now ()
509+ slog .Info ("start applying exploit data" , "entries" , len (exploits ))
489510 if err := insertExploitsBulk (ctx , tx , exploits ); err != nil {
490511 return fmt .Errorf ("could not apply exploit data: %w" , err )
491512 }
513+ slog .Info ("finished applying exploit data" , "took" , time .Since (t ).Round (time .Millisecond ))
492514
493- slog .Info ("applying malicious packages" )
515+ t = time .Now ()
516+ slog .Info ("start applying malicious packages" , "packages" , len (pkgs ), "components" , len (comps ))
494517 if err := insertMaliciousPackagesBulk (ctx , tx , pkgs , comps ); err != nil {
495518 return fmt .Errorf ("could not apply malicious packages: %w" , err )
496519 }
497- slog .Info ("applied malicious packages" , "packages " , len ( pkgs ), "components" , len ( comps ))
520+ slog .Info ("finished applying malicious packages" , "took " , time . Since ( t ). Round ( time . Millisecond ))
498521
499522 return nil
500523}
0 commit comments