@swestash/agent-lens 0.9.5 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5035,6 +5035,19 @@ function listFindings(db, f) {
5035
5035
  LIMIT ? OFFSET ?`, ...w.params, f.limit, f.offset);
5036
5036
  return { total, findings };
5037
5037
  }
5038
+ function openFindingIds(db, f) {
5039
+ if (!tableExists(db, "findings"))
5040
+ return [];
5041
+ const attached = triageAttached(db);
5042
+ const w = findingWhere(f);
5043
+ const st = statusWhere("open", attached);
5044
+ const where = [...w.sql, ...st ? [st] : []];
5045
+ return queryAll(db, `SELECT f.id
5046
+ FROM findings f
5047
+ JOIN sessions s ON s.id = f.session_id
5048
+ ${attached ? "LEFT JOIN triage.dismissed_findings d ON d.finding_id = f.id" : ""}
5049
+ ${where.length ? `WHERE ${where.join(" AND ")}` : ""}`, ...w.params).map((r) => r.id);
5050
+ }
5038
5051
  function securitySummary(db) {
5039
5052
  const categories = SECURITY_CATEGORIES;
5040
5053
  if (!tableExists(db, "findings")) {
@@ -5659,8 +5672,7 @@ async function createApp(db, opts = {}) {
5659
5672
  if (!guardWrite(req, reply))
5660
5673
  return reply;
5661
5674
  const b = req.body ?? {};
5662
- const page = listFindings(db, { ...findingFilters(b.filter ?? {}), status: "open", limit: 1e5, offset: 0 });
5663
- const ids = page.findings.map((r) => r.id);
5675
+ const ids = openFindingIds(db, findingFilters(b.filter ?? {}));
5664
5676
  const n = dismiss(triageDb, ids, b.note ?? null);
5665
5677
  return { ok: true, dismissed: n };
5666
5678
  });