Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(threat-intel): name the failure instead of leaving `error` unused (#1005)

Beenu Arora0301ca23ad7e
diff --git a/apps/web/src/components/threat-intel/ThreatIntelCountHonesty.test.tsx b/apps/web/src/components/threat-intel/ThreatIntelCountHonesty.test.tsx
index bf91a6d9d..f51d1185c 100644
--- a/apps/web/src/components/threat-intel/ThreatIntelCountHonesty.test.tsx
+++ b/apps/web/src/components/threat-intel/ThreatIntelCountHonesty.test.tsx
@@ -77,13 +77,17 @@ describe('an unreachable indicator store is not a count of zero', () => {
expect(screen.getByText(/^— indicators$/)).toBeInTheDocument();
});
- it('does not print a zero when the read failed', () => {
+ it('does not print a zero when the read failed, and names the failure', () => {
swrError.value = new Error('503 Service Unavailable');
render(<ThreatIntelView />);
expect(screen.queryByText(/^0 indicators$/)).toBeNull();
expect(screen.getByText(/^— indicators$/)).toBeInTheDocument();
+ // A request that never completed is a different thing from a route that
+ // answered and said it could not read its store, and the copy must say
+ // which. This was destructured and spent on `${error ? '' : ''}`.
+ expect(screen.getByText(/503 Service Unavailable/)).toBeInTheDocument();
});
it('still counts a genuinely empty store as zero', () => {
diff --git a/apps/web/src/components/threat-intel/ThreatIntelView.tsx b/apps/web/src/components/threat-intel/ThreatIntelView.tsx
index eb73cb5f9..4444cd6be 100644
--- a/apps/web/src/components/threat-intel/ThreatIntelView.tsx
+++ b/apps/web/src/components/threat-intel/ThreatIntelView.tsx
@@ -268,7 +268,17 @@ export function ThreatIntelView() {
// confident zero over it. `threatIntelApi.lookup` already treats the same
// flag as a failed lookup; the list did not.
const storeUnknown = !data || data.degraded === true;
- const degradedReason = data?.reason?.trim() || null;
+
+ // Two distinct ways to not know, and the operator needs to be told which.
+ // `reason` is the route answering 200 and saying it could not read its
+ // store; `error` is the request never completing. The latter used to be
+ // destructured and spent on `${error ? '' : ''}` — a no-op that read as a
+ // use — so a transport failure fell through to the same generic sentence
+ // as everything else.
+ const transportFailure =
+ error instanceof Error ? error.message : error ? String(error) : null;
+ const notMeasuredReason =
+ data?.reason?.trim() || transportFailure || 'The threat-intel service did not answer';
// Not `?? MOCK_INDICATORS`. `fallbackData` above already withholds the
// sample set outside the hosted demo; repeating the constant here put it
@@ -423,10 +433,10 @@ export function ThreatIntelView() {
storeUnknown
? isLoading
? 'Reading indicators from the threat-intel service.'
- : // The route's own `reason` when it sent one, because
- // "did not answer (ConnectError)" tells an operator
- // where to look and a generic sentence does not.
- `${degradedReason ?? 'The threat-intel service did not answer'}. This is not a report that no indicators exist.`
+ : // The route's own `reason` when it sent one, because
+ // "did not answer (ConnectError)" tells an operator
+ // where to look and a generic sentence does not.
+ `${notMeasuredReason}. This is not a report that no indicators exist.`
: 'Connect a TI feed (MISP, OTX, AbuseIPDB, GreyNoise, internal STIX/TAXII) from Settings → Connectors to start enriching alerts with reputation context.'
}
className="bg-transparent py-8"