From 15dceb403777f80e76b110d51b6c112863cd5532 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 30 Oct 2024 02:01:38 +0000 Subject: [PATCH] update order of validation; catch exceptions in semver check (#1212) Signed-off-by: Amardeepsingh Siglani (cherry picked from commit b350af5d97b0bed52184103be55aad969cd51886) Signed-off-by: github-actions[bot] --- public/utils/helpers.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/public/utils/helpers.tsx b/public/utils/helpers.tsx index 378db069..14527df3 100644 --- a/public/utils/helpers.tsx +++ b/public/utils/helpers.tsx @@ -654,12 +654,18 @@ export function setBreadcrumbs(crumbs: ChromeBreadcrumb[]) { } export function dataSourceFilterFn(dataSource: SavedObject) { - const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || ''; - const installedPlugins = dataSource?.attributes?.installedPlugins || []; - return ( - semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions) && - pluginManifest.requiredOSDataSourcePlugins.every((plugin) => installedPlugins.includes(plugin)) - ); + try { + const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || ''; + const installedPlugins = dataSource?.attributes?.installedPlugins || []; + return ( + pluginManifest.requiredOSDataSourcePlugins.every((plugin) => + installedPlugins.includes(plugin) + ) && semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions) + ); + } catch (error: any) { + // Filter out invalid data source + return false; + } } export function getSeverityText(severity: string) {