From 09db1c2ae91f2dd0fa5f0483131ebf6a3d99a0dc Mon Sep 17 00:00:00 2001 From: Jordan Ramos Date: Tue, 16 Jun 2026 15:40:51 -0600 Subject: [PATCH] =?UTF-8?q?Fix=20atlas=5Fknown=20=E2=80=94=20managed=20BU?= =?UTF-8?q?=20hosts=20always=20show=20badge=20regardless=20of=20plans?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A STEAM/ACCESS-ENG host with zero Atlas plans but tracked in Atlas (like olt01k7) wasn't showing the amber shield because atlas_known was only true when plans existed. Now managed BU hosts always get atlas_known=true so the '0 plans' warning badge renders. Non-managed BU hosts only show badge if Atlas actually has plan data for them. --- backend/routes/atlas.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/backend/routes/atlas.js b/backend/routes/atlas.js index 3a1d31f..ac73437 100644 --- a/backend/routes/atlas.js +++ b/backend/routes/atlas.js @@ -251,6 +251,19 @@ function createAtlasRouter() { return res.json({ synced: 0, withPlans: 0, failed: 0 }); } + // Build a set of host IDs belonging to managed BUs — these always show the badge + const managedPatterns = managedBUs.map(b => `%${b}%`); + let managedHostIds = new Set(); + try { + const { rows: managedRows } = await pool.query( + `SELECT DISTINCT host_id FROM ivanti_findings + WHERE host_id IS NOT NULL AND host_id > 0 + AND bu_ownership ILIKE ANY($1::text[])`, + [managedPatterns] + ); + managedHostIds = new Set(managedRows.map(r => r.host_id)); + } catch (_) { /* non-fatal — fall back to plans-only logic */ } + let synced = 0; let withPlans = 0; let failed = 0; @@ -273,6 +286,7 @@ function createAtlasRouter() { } const { hostId, result } = settled.value; + const isManagedHost = managedHostIds.has(hostId); if (result.status >= 200 && result.status < 300) { let allPlans = []; @@ -294,9 +308,11 @@ function createAtlasRouter() { const planCount = activePlans.length; const hasActionPlan = planCount > 0; - // Atlas "knows" this host if it returned any plans (active or inactive). - // Hosts with completely empty responses are not tracked by Atlas. - const atlasKnown = allPlans.length > 0; + // Atlas "knows" this host if: + // 1. It returned any plans (active or inactive), OR + // 2. The host belongs to a managed BU (these should always show the badge) + // Non-managed BU hosts with empty responses don't get a badge. + const atlasKnown = allPlans.length > 0 || isManagedHost; try { if (!hasActionPlan) {