Skip to content

Commit

Permalink
Fix HostsRiskScore interface to match new transform version
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum committed Nov 19, 2021
1 parent 0c4b58d commit 0cdbbf3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ export interface HostsRiskScore {
host: {
name: string;
};
risk_score: number;
risk: string;
risk_stats: {
rule_risks: RuleRisk[];
risk_score: number;
};
}

export interface RuleRisk {
rule_name: string;
rule_risk: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { HostRisk } from '../../containers/overview_risky_host_links/use_hosts_r
import { HostsRiskScore } from '../../../../common';

const getListItemsFromHits = (items: HostsRiskScore[]): LinkPanelListItem[] => {
return items.map(({ host, risk_score: count, risk: copy }) => ({
return items.map(({ host, risk_stats: riskStats, risk: copy }) => ({
title: host.name,
count,
count: riskStats.risk_score,
copy,
path: '',
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ const noop = () => {};
const isRecord = (item: unknown): item is Record<string, unknown> =>
typeof item === 'object' && !!item;

const isHostsRiskScoreHit = (item: unknown): item is HostsRiskScore =>
const isHostsRiskScoreHit = (item: Partial<HostsRiskScore>): item is HostsRiskScore =>
isRecord(item) &&
isRecord(item.host) &&
typeof item.host.name === 'string' &&
typeof item.risk_score === 'number' &&
typeof item.risk_stats?.risk_score === 'number' &&
typeof item.risk === 'string';

export interface HostRisk {
Expand Down

0 comments on commit 0cdbbf3

Please sign in to comment.