@@ -66,36 +66,38 @@ def run
6666 synced = 0
6767 vuln_count = 0
6868
69- packages_to_sync . each_slice ( 100 ) do |batch |
70- queries = batch . map do |pkg |
71- osv_ecosystem = Ecosystems . to_osv ( pkg . ecosystem )
72- next unless osv_ecosystem
73-
74- { ecosystem : osv_ecosystem , name : pkg . name }
75- end . compact
76-
77- results = client . query_batch ( queries )
78-
79- # Collect all unique vuln IDs from this batch to fetch full details
80- vuln_ids = results . flatten . map { |v | v [ "id" ] } . uniq
81-
82- # Fetch full vulnerability details and create records
83- vuln_ids . each do |vuln_id |
84- existing = Models ::Vulnerability . first ( id : vuln_id )
85- next if existing &.vulnerability_packages &.any? && !@options [ :refresh ]
86-
87- begin
88- full_vuln = client . get_vulnerability ( vuln_id )
89- Models ::Vulnerability . from_osv ( full_vuln )
90- vuln_count += 1
91- rescue OsvClient ::ApiError
92- # Skip vulnerabilities we can't fetch
69+ Spinner . with_spinner ( "Fetching from OSV..." ) do
70+ packages_to_sync . each_slice ( 100 ) do |batch |
71+ queries = batch . map do |pkg |
72+ osv_ecosystem = Ecosystems . to_osv ( pkg . ecosystem )
73+ next unless osv_ecosystem
74+
75+ { ecosystem : osv_ecosystem , name : pkg . name }
76+ end . compact
77+
78+ results = client . query_batch ( queries )
79+
80+ # Collect all unique vuln IDs from this batch to fetch full details
81+ vuln_ids = results . flatten . map { |v | v [ "id" ] } . uniq
82+
83+ # Fetch full vulnerability details and create records
84+ vuln_ids . each do |vuln_id |
85+ existing = Models ::Vulnerability . first ( id : vuln_id )
86+ next if existing &.vulnerability_packages &.any? && !@options [ :refresh ]
87+
88+ begin
89+ full_vuln = client . get_vulnerability ( vuln_id )
90+ Models ::Vulnerability . from_osv ( full_vuln )
91+ vuln_count += 1
92+ rescue OsvClient ::ApiError
93+ # Skip vulnerabilities we can't fetch
94+ end
9395 end
94- end
9596
96- batch . each do |pkg |
97- pkg . mark_vulns_synced
98- synced += 1
97+ batch . each do |pkg |
98+ pkg . mark_vulns_synced
99+ synced += 1
100+ end
99101 end
100102 end
101103
0 commit comments