Skip to content

Commit

Permalink
Merge pull request #2 from machadoum/fix-ci
Browse files Browse the repository at this point in the history
Fix ci
  • Loading branch information
CAWilson94 authored Oct 15, 2024
2 parents 43912df + a4d3469 commit 29e251a
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export const useAssetCriticalityPrivileges = (

return useQuery({
queryKey: [ASSET_CRITICALITY_KEY, PRIVILEGES_KEY, queryKey, hasEntityAnalyticsCapability],
queryFn: hasEntityAnalyticsCapability ? fetchAssetCriticalityPrivileges : () => nonAuthorizedResponse,
queryFn: hasEntityAnalyticsCapability
? fetchAssetCriticalityPrivileges
: () => nonAuthorizedResponse,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ interface EntityData {
risk: RiskStats;
}

export const buildColumns: (showFooter: boolean) => Array<EuiBasicTableColumn<TableItem>> = (
showFooter
) => [
export const buildColumns: () => Array<EuiBasicTableColumn<TableItem>> = () => [
{
field: 'category',
name: (
Expand All @@ -38,12 +36,12 @@ export const buildColumns: (showFooter: boolean) => Array<EuiBasicTableColumn<Ta
truncateText: false,
mobileOptions: { show: true },
sortable: true,
footer: showFooter ? (
footer: (
<FormattedMessage
id="xpack.securitySolution.flyout.entityDetails.categoryColumnFooterLabel"
defaultMessage="Result"
/>
) : undefined,
),
},
{
field: 'score',
Expand All @@ -59,12 +57,11 @@ export const buildColumns: (showFooter: boolean) => Array<EuiBasicTableColumn<Ta
dataType: 'number',
align: 'right',
render: formatRiskScore,
footer: (props) =>
showFooter ? (
<span data-test-subj="risk-summary-result-score">
{formatRiskScore(sumBy((i) => i.score, props.items))}
</span>
) : undefined,
footer: (props) => (
<span data-test-subj="risk-summary-result-score">
{formatRiskScore(sumBy((i) => i.score, props.items))}
</span>
),
},
{
field: 'count',
Expand All @@ -79,18 +76,15 @@ export const buildColumns: (showFooter: boolean) => Array<EuiBasicTableColumn<Ta
sortable: true,
dataType: 'number',
align: 'right',
footer: (props) =>
showFooter ? (
<span data-test-subj="risk-summary-result-count">
{sumBy((i) => i.count ?? 0, props.items)}
</span>
) : undefined,
footer: (props) => (
<span data-test-subj="risk-summary-result-count">
{sumBy((i) => i.count ?? 0, props.items)}
</span>
),
},
];

export const getItems: (
entityData: EntityData | undefined,
) => TableItem[] = (entityData) => {
export const getItems: (entityData: EntityData | undefined) => TableItem[] = (entityData) => {
return [
{
category: i18n.translate('xpack.securitySolution.flyout.entityDetails.alertsGroupLabel', {
Expand All @@ -99,17 +93,17 @@ export const getItems: (
score: entityData?.risk.category_1_score ?? 0,
count: entityData?.risk.category_1_count ?? 0,
},
{
category: i18n.translate(
'xpack.securitySolution.flyout.entityDetails.assetCriticalityGroupLabel',
{
defaultMessage: 'Asset Criticality',
}
),
score: entityData?.risk.category_2_score ?? 0,
count: undefined,
},

{
category: i18n.translate(
'xpack.securitySolution.flyout.entityDetails.assetCriticalityGroupLabel',
{
defaultMessage: 'Asset Criticality',
}
),
score: entityData?.risk.category_2_score ?? 0,
count: undefined,
},
];
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,9 @@ const FlyoutRiskSummaryComponent = <T extends RiskScoreEntity>({

const xsFontSize = useEuiFontSize('xxs').fontSize;

const columns = useMemo(() => buildColumns(true), []);
const columns = useMemo(() => buildColumns(), []);

const rows = useMemo(
() => getItems(entityData),
[entityData]
);
const rows = useMemo(() => getItems(entityData), [entityData]);

const onToggle = useCallback(
(isOpen: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,7 @@ export const AssetCriticalityUploadPage = () => {
return null;
}

if (
!hasEntityAnalyticsCapability ||
privilegesError?.body.status_code === 403
) {
const errorMessage = privilegesError?.body.message ?? (
<FormattedMessage
id="xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.advancedSettingDisabledMessage"
/>
);

if (!hasEntityAnalyticsCapability || privilegesError?.body.status_code === 403) {
return (
<EuiEmptyPrompt
iconType="warning"
Expand All @@ -65,7 +56,7 @@ export const AssetCriticalityUploadPage = () => {
/>
</h2>
}
body={<p>{errorMessage}</p>}
body={<p>{privilegesError?.body.message}</p>}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,6 @@ export const getHostsColumns = (
return getEmptyTagValue();
},
},
{
field: 'node.criticality',
name: i18n.ASSET_CRITICALITY,
truncateText: false,
mobileOptions: { show: true },
sortable: false,
render: (assetCriticality: CriticalityLevelWithUnassigned) => {
if (!assetCriticality) return getEmptyTagValue();
return (
<AssetCriticalityBadge
criticalityLevel={assetCriticality}
css={{ verticalAlign: 'middle' }}
/>
);
},
},
];

if (showRiskColumn) {
Expand Down Expand Up @@ -181,5 +165,22 @@ export const getHostsColumns = (
});
}

columns.push({
field: 'node.criticality',
name: i18n.ASSET_CRITICALITY,
truncateText: false,
mobileOptions: { show: true },
sortable: false,
render: (assetCriticality: CriticalityLevelWithUnassigned) => {
if (!assetCriticality) return getEmptyTagValue();
return (
<AssetCriticalityBadge
criticalityLevel={assetCriticality}
css={{ verticalAlign: 'middle' }}
/>
);
},
});

return columns;
};
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,6 @@ const getUsersColumns = (
})
: getOrEmptyTagFromValue(domain),
},
{
field: 'criticality',
name: i18n.ASSET_CRITICALITY,
truncateText: false,
mobileOptions: { show: true },
sortable: false,
render: (assetCriticality: CriticalityLevelWithUnassigned) => {
return (
<AssetCriticalityBadge
criticalityLevel={assetCriticality}
css={{ verticalAlign: 'middle' }}
/>
);
},
},
];

if (showRiskColumn) {
Expand All @@ -160,6 +145,24 @@ const getUsersColumns = (
},
});
}

columns.push({
field: 'criticality',
name: i18n.ASSET_CRITICALITY,
truncateText: false,
mobileOptions: { show: true },
sortable: false,
render: (assetCriticality: CriticalityLevelWithUnassigned) => {
if (!assetCriticality) return getEmptyTagValue();
return (
<AssetCriticalityBadge
criticalityLevel={assetCriticality}
css={{ verticalAlign: 'middle' }}
/>
);
},
});

return columns;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const enrichEvents: EnrichEventsFunction = async ({
logger.debug('Alert enrichments started');
const isNewRiskScoreModuleAvailable = experimentalFeatures?.riskScoringRoutesEnabled ?? false;
const { uiSettingsClient } = services;
const isAssetCriticalityEnabled = true;

let isNewRiskScoreModuleInstalled = false;
if (isNewRiskScoreModuleAvailable) {
Expand Down Expand Up @@ -84,29 +83,27 @@ export const enrichEvents: EnrichEventsFunction = async ({
);
}

if (isAssetCriticalityEnabled) {
const assetCriticalityIndexExist = await isIndexExist({
services,
index: getAssetCriticalityIndex(spaceId),
});
if (assetCriticalityIndexExist) {
enrichments.push(
createUserAssetCriticalityEnrichments({
services,
logger,
events,
spaceId,
})
);
enrichments.push(
createHostAssetCriticalityEnrichments({
services,
logger,
events,
spaceId,
})
);
}
const assetCriticalityIndexExist = await isIndexExist({
services,
index: getAssetCriticalityIndex(spaceId),
});
if (assetCriticalityIndexExist) {
enrichments.push(
createUserAssetCriticalityEnrichments({
services,
logger,
events,
spaceId,
})
);
enrichments.push(
createHostAssetCriticalityEnrichments({
services,
logger,
events,
spaceId,
})
);
}

const allEnrichmentsResults = await Promise.allSettled(enrichments);
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -38372,7 +38372,6 @@
"xpack.securitySolution.entityAnalytics.assetCriticalityResultStep.successTitle": "Réussite",
"xpack.securitySolution.entityAnalytics.assetCriticalityResultStep.uploadAnotherFile": "Charger un autre fichier",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.acceptedFileFormats": "Formats de fichiers : {formats}",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.advancedSettingDisabledMessage": "Veuillez autoriser \"{ENABLE_ASSET_CRITICALITY_SETTING}\" dans les paramètres avancés pour accéder à la page.",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.advancedSettingDisabledTitle": "Cette page est désactivée",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.assetCriticalityLabels": "Niveau de criticité : Spécifiez n'importe laquelle de ces {labels}",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.assetIdentifierDescription": "Identificateur : Spécifiez le {hostName} ou le {userName} de l'entité.",
Expand Down Expand Up @@ -40610,8 +40609,6 @@
"xpack.securitySolution.uiSettings.defaultThreatIndexLabel": "Index de menaces",
"xpack.securitySolution.uiSettings.defaultTimeRangeDescription": "<p>Période de temps par défaut dans le filtre de temps Security.</p>",
"xpack.securitySolution.uiSettings.defaultTimeRangeLabel": "Période du filtre de temps",
"xpack.securitySolution.uiSettings.enableAssetCriticalityDescription": "<p>Permet des flux de travail pour l'affectation de l'état critique des actifs et ses contributions au risque de l'entité </p>",
"xpack.securitySolution.uiSettings.enableAssetCriticalityTitle": "Criticité des ressources",
"xpack.securitySolution.uiSettings.enableCcsReadWarningLabel": "Avertissement lié aux privilèges de la règle CCS",
"xpack.securitySolution.uiSettings.enableCcsWarningDescription": "<p>Active les avertissements de vérification des privilèges dans les règles relatives aux index CCS</p>",
"xpack.securitySolution.uiSettings.enableNewsFeedDescription": "<p>Active le fil d'actualités</p>",
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -38114,7 +38114,6 @@
"xpack.securitySolution.entityAnalytics.assetCriticalityResultStep.successTitle": "成功",
"xpack.securitySolution.entityAnalytics.assetCriticalityResultStep.uploadAnotherFile": "別のファイルをアップロード",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.acceptedFileFormats": "ファイル形式:{formats}",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.advancedSettingDisabledMessage": "ページにアクセスするには、詳細設定で\"{ENABLE_ASSET_CRITICALITY_SETTING}\"を有効化してください。",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.advancedSettingDisabledTitle": "このページは無効です",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.assetCriticalityLabels": "重要度レベル:{labels}のいずれかを指定",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.assetIdentifierDescription": "識別子:エンティティの{hostName}または{userName}を指定します。",
Expand Down Expand Up @@ -40356,8 +40355,6 @@
"xpack.securitySolution.uiSettings.defaultThreatIndexLabel": "脅威インデックス",
"xpack.securitySolution.uiSettings.defaultTimeRangeDescription": "<p>セキュリティ時間フィルダーのデフォルトの期間です。</p>",
"xpack.securitySolution.uiSettings.defaultTimeRangeLabel": "時間フィルターの期間",
"xpack.securitySolution.uiSettings.enableAssetCriticalityDescription": "<p>アセット重要度割り当てワークフローとエンティティリスクへの寄与を有効化します </p>",
"xpack.securitySolution.uiSettings.enableAssetCriticalityTitle": "アセット重要度",
"xpack.securitySolution.uiSettings.enableCcsReadWarningLabel": "CCSルール権限警告",
"xpack.securitySolution.uiSettings.enableCcsWarningDescription": "<p>CCSインデックスのルールで権限チェック警告を有効にします</p>",
"xpack.securitySolution.uiSettings.enableNewsFeedDescription": "<p>ニュースフィードを有効にします</p>",
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -38160,7 +38160,6 @@
"xpack.securitySolution.entityAnalytics.assetCriticalityResultStep.successTitle": "成功",
"xpack.securitySolution.entityAnalytics.assetCriticalityResultStep.uploadAnotherFile": "上传另一个文件",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.acceptedFileFormats": "文件格式:{formats}",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.advancedSettingDisabledMessage": "请在高级设置上启用“{ENABLE_ASSET_CRITICALITY_SETTING}”以访问此页面。",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.advancedSettingDisabledTitle": "已禁用此页面",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.assetCriticalityLabels": "关键度级别:指定任意 {labels}",
"xpack.securitySolution.entityAnalytics.assetCriticalityUploadPage.assetIdentifierDescription": "标识符:指定实体的 {hostName} 或 {userName}。",
Expand Down Expand Up @@ -40401,8 +40400,6 @@
"xpack.securitySolution.uiSettings.defaultThreatIndexLabel": "威胁索引",
"xpack.securitySolution.uiSettings.defaultTimeRangeDescription": "<p>Security 时间筛选中的默认时段。</p>",
"xpack.securitySolution.uiSettings.defaultTimeRangeLabel": "时间筛选时段",
"xpack.securitySolution.uiSettings.enableAssetCriticalityDescription": "<p>启用资产关键度分配工作流及其对实体风险的贡献率 </p>",
"xpack.securitySolution.uiSettings.enableAssetCriticalityTitle": "资产关键度",
"xpack.securitySolution.uiSettings.enableCcsReadWarningLabel": "CCS 规则权限警告",
"xpack.securitySolution.uiSettings.enableCcsWarningDescription": "<p>在规则中为 CCS 索引启用权限检查警告</p>",
"xpack.securitySolution.uiSettings.enableNewsFeedDescription": "<p>启用新闻源</p>",
Expand Down
Loading

0 comments on commit 29e251a

Please sign in to comment.