mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
feat(security): size the rescan from measured scan times
The confirmation for a full rescan used a fixed guess of 10 seconds per artifact. Scans now record their wall time in scan_results. The new GET /api/admin/rescan/estimate returns the artifact count of each scope and the time at the configured concurrency, from the average of recent scans. While a rescan runs, the status reports elapsed time and an ETA, and the panel shows the live rate.
This commit is contained in:
@@ -309,6 +309,7 @@ func (m *Manager) scan(ctx context.Context, registry, packageName, version strin
|
||||
key := scanKey(registry, packageName, version)
|
||||
m.markInflight(key, 1)
|
||||
defer m.markInflight(key, -1)
|
||||
started := time.Now()
|
||||
|
||||
log.Info().
|
||||
Str("registry", registry).
|
||||
@@ -429,6 +430,7 @@ func (m *Manager) scan(ctx context.Context, registry, packageName, version strin
|
||||
mergedResult := m.mergeResults(scanResults, scannerNames)
|
||||
// The store finds the package by its cache version, not the release version.
|
||||
mergedResult.PackageVersion = version
|
||||
mergedResult.DurationMs = int(time.Since(started).Milliseconds())
|
||||
|
||||
// Save consolidated result to metadata store
|
||||
if err := m.metadataStore.SaveScanResult(ctx, mergedResult); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user