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:
@@ -211,6 +211,7 @@ type ScanResult struct {
|
||||
Status ScanStatus `json:"status"`
|
||||
Vulnerabilities []Vulnerability `json:"vulnerabilities"`
|
||||
VulnerabilityCount int `json:"vulnerability_count"`
|
||||
DurationMs int `json:"duration_ms"` // wall time of the scan that produced it
|
||||
}
|
||||
|
||||
// Vulnerability represents a security vulnerability
|
||||
@@ -452,6 +453,12 @@ type TrendingPackage struct {
|
||||
Previous int64 `json:"previous"`
|
||||
}
|
||||
|
||||
// ScanDurationSource reports how long recent scans took, for backends that keep it.
|
||||
type ScanDurationSource interface {
|
||||
// AverageScanDuration averages the latest sample scans that recorded a duration; zero means none did.
|
||||
AverageScanDuration(ctx context.Context, sample int) (time.Duration, error)
|
||||
}
|
||||
|
||||
// TrendingSource ranks packages from persisted download history. Backends without
|
||||
// persisted downloads do not implement it.
|
||||
type TrendingSource interface {
|
||||
|
||||
Reference in New Issue
Block a user