mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-28 02:40:53 +08:00
fix(server): count only the task's assets in the task report
GET /api/report renders one task's report, but its "Assets:" summary line was built from QueryByType over the whole asset library, so it reported every task's and every company's assets as this task's. It also loaded up to 100000 full rows per type only to count them. Use CountsByTypeForTask, the per-task count the assets tab already uses.
This commit is contained in:
+1
-7
@@ -4583,14 +4583,8 @@ func (s *Server) getReport(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
findings, _ := t.Store.ListByKind(db.KindFinding, 1000) // pure vulnerabilities (facts are a separate KindFact and never enter the report)
|
||||
counts := map[string]int{}
|
||||
for _, ty := range []string{"root_domain", "ip", "subdomain", "app", "service", "endpoint"} {
|
||||
ns, _ := s.m.Assets().QueryByType(ty, 100000, 0)
|
||||
if len(ns) > 0 {
|
||||
counts[ty] = len(ns)
|
||||
}
|
||||
}
|
||||
taskID, _ := strconv.ParseInt(t.ID, 10, 64)
|
||||
counts, _ := s.m.Assets().CountsByTypeForTask(taskID)
|
||||
var ledger *db.CoverageLedger
|
||||
if t.CoverageEnabled {
|
||||
ledger, _ = s.m.Assets().CoverageLedger(taskID)
|
||||
|
||||
Reference in New Issue
Block a user