aboutsummaryrefslogtreecommitdiff
path: root/reports.go
diff options
context:
space:
mode:
Diffstat (limited to 'reports.go')
-rw-r--r--reports.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/reports.go b/reports.go
index 91ff2df..fdf472e 100644
--- a/reports.go
+++ b/reports.go
@@ -3,8 +3,31 @@
package lilin
+import "sync"
+
+const failKeepSize = 600
+const failMax = failKeepSize + (failKeepSize / 3)
+
// Reports contains the report for all services.
type Reports struct {
Services map[string]*ServiceReport
Title string
+ Fail []ScanReport
+ sync.Mutex
+}
+
+// Store the service scan report.
+func (reports *Reports) Store(scanReport ScanReport) {
+ reports.Lock()
+ var svcReport = reports.Services[scanReport.Name]
+ svcReport.Store(scanReport)
+ if !scanReport.Success {
+ reports.Fail = append(reports.Fail, scanReport)
+ if len(reports.Fail) >= failMax {
+ var start = len(reports.Fail) - failKeepSize
+ copy(reports.Fail, reports.Fail[start:])
+ reports.Fail = reports.Fail[:failKeepSize-1]
+ }
+ }
+ reports.Unlock()
}