diff --git a/server.js b/server.js index daf60a8..3599053 100644 --- a/server.js +++ b/server.js @@ -4187,15 +4187,22 @@ const server = http.createServer(async (req, res) => { var asnInPaths = neighbours.map(function(n) { return n.asn; }); var bogonAsns = asnInPaths.filter(checkBogonAsn); // "pass" must mean prefixes/neighbours were actually fetched and checked clean -- - // not that the upstream RIPE Stat calls failed and left nothing to check. - var bogonDataUnavailable = !prefixData && !neighbourData; + // not that the upstream source failed and left nothing to check. A source is + // unavailable if it's falsy (fetchRipeStatCached network failure) OR if it's a + // truthy object with status:"error" (local-db-client.js's DB-error signal -- + // see the 2026-07-16 audit; that object is NOT null, so a plain `!x` check + // alone misses this case and would show "pass" on 0 checked prefixes). + function isSourceUnavailable(x) { return !x || x.status === "error"; } + var prefixesUnavailable = isSourceUnavailable(prefixData); + var neighboursUnavailable = isSourceUnavailable(neighbourData); + var bogonDataUnavailable = prefixesUnavailable && neighboursUnavailable; var bogonResult = { status: bogonDataUnavailable ? "info" : (bogonPrefixes.length === 0 && bogonAsns.length === 0 ? "pass" : "fail"), bogon_prefixes: bogonPrefixes, bogon_asns_in_paths: bogonAsns, total_prefixes_checked: allPrefixes.length, - prefixes_source_unavailable: !prefixData, - neighbours_source_unavailable: !neighbourData, + prefixes_source_unavailable: prefixesUnavailable, + neighbours_source_unavailable: neighboursUnavailable, }; // Phase 2: All API-dependent validations in parallel