Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export type UsageInfo = Record<string, EndpointUsage>

export type TiResult<T> =
| { kind: 'ok'; value: T }
| { kind: 'empty'; value: T }
| { kind: 'not-configured' }

export interface AdvancedRangeCondition {
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/features/threat-intel/hooks/use-ti-search-advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ import type { AdvancedSearchRequest } from '../domain/threat-intel.types'

export function useTiSearchAdvanced() {
return useMutation({
mutationFn: (input: { body: AdvancedSearchRequest; limit?: number; page?: number }) =>
threatIntelHttpService.searchAdvanced(input.body, { limit: input.limit, page: input.page }),
mutationFn: async (input: { body: AdvancedSearchRequest; limit?: number; page?: number }) =>{
try{
return await threatIntelHttpService.searchAdvanced(input.body, { limit: input.limit, page: input.page })
}catch(e){
if(isNotFound(e)){
const resp = await threatIntelHttpService.searchAdvanced({}, { limit: input.limit, page: input.page })
resp.kind="empty"
return resp
}
throw e
}
},
onError: (e) => { if (!isNotConfigured(e) && !isNotFound(e)) toast.error(describeError(e)) },
})
}
10 changes: 7 additions & 3 deletions frontend/src/features/threat-intel/pages/ThreatIntelPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export function ThreatIntelPage() {

const [filters, setFilters] = useState<FiltersState>(EMPTY_FILTERS)
const [lastBody, setLastBody] = useState<AdvancedSearchRequest>({})
const [empty, setEmpty] = useState<boolean>(false)
const [filtersOpen, setFiltersOpen] = useState(false)
const [timeRange, setTimeRange] = useState<TimeRange>('all')

Expand All @@ -113,7 +114,10 @@ export function ThreatIntelPage() {
onSuccess: (data) => {
if (my !== seqRef.current) return
if (data?.kind === 'not-configured') return
if (data?.kind !== 'ok') return
if (data?.kind !== 'ok' && data?.kind !== 'empty') return
if(data.kind =='empty'){
setEmpty(true)
}
setTotalItems(data.value.items)
setTotalPages(data.value.pages)
setIocs((prev) =>
Expand Down Expand Up @@ -232,12 +236,12 @@ export function ThreatIntelPage() {
matchedCount={totalItems}
onExport={handleExport}
isExporting={isExporting}
noInstanceIocs={observedFragment.ready && !observedFragment.hasInstanceIocs}
noInstanceIocs={empty || observedFragment.ready && !observedFragment.hasInstanceIocs}
/>

<div className="mt-5">
<MatchOverviewCard
body={observedFragment.ready ? lastBody : undefined}
body={observedFragment.ready ? (empty? {}:lastBody) : undefined}
interval={TIME_RANGE_OPTIONS.find((o) => o.value === timeRange)?.interval ?? 'hour'}
/>
</div>
Expand Down
Loading