mirror of
https://github.com/ivuorinen/gibidify.git
synced 2026-01-26 11:34:03 +00:00
Add overflow checks before converting uint64 memory values to int64 to prevent potential integer overflow issues identified by gosec (G115). - Add math.MaxInt64 checks in fileproc/backpressure.go - Add math.MaxInt64 checks in fileproc/resource_monitor_validation.go - Add math.MaxInt64 checks in fileproc/resource_monitor_metrics.go - Add math.MaxInt64 check in benchmark/benchmark.go with nosec annotation Co-authored-by: ivuorinen <11024+ivuorinen@users.noreply.github.com>
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package cli
|
|
|
|
import (
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/ivuorinen/gibidify/config"
|
|
)
|
|
|
|
// logFinalStats logs the final back-pressure and resource monitoring statistics.
|
|
func (p *Processor) logFinalStats() {
|
|
// Log back-pressure stats
|
|
backpressureStats := p.backpressure.GetStats()
|
|
if backpressureStats.Enabled {
|
|
logrus.Infof("Back-pressure stats: processed=%d files, memory=%dMB/%dMB",
|
|
backpressureStats.FilesProcessed, backpressureStats.CurrentMemoryUsage/1024/1024, backpressureStats.MaxMemoryUsage/1024/1024)
|
|
}
|
|
|
|
// Log resource monitoring stats
|
|
resourceStats := p.resourceMonitor.GetMetrics()
|
|
if config.GetResourceLimitsEnabled() {
|
|
logrus.Infof("Resource stats: processed=%d files, totalSize=%dMB, avgFileSize=%.2fKB, rate=%.2f files/sec",
|
|
resourceStats.FilesProcessed, resourceStats.TotalSizeProcessed/1024/1024,
|
|
resourceStats.AverageFileSize/1024, resourceStats.ProcessingRate)
|
|
|
|
if len(resourceStats.ViolationsDetected) > 0 {
|
|
logrus.Warnf("Resource violations detected: %v", resourceStats.ViolationsDetected)
|
|
}
|
|
|
|
if resourceStats.DegradationActive {
|
|
logrus.Warnf("Processing completed with degradation mode active")
|
|
}
|
|
|
|
if resourceStats.EmergencyStopActive {
|
|
logrus.Errorf("Processing completed with emergency stop active")
|
|
}
|
|
}
|
|
|
|
// Clean up resource monitor
|
|
p.resourceMonitor.Close()
|
|
}
|