From 51c2ea90933804cdda874844cc888261d2e13510 Mon Sep 17 00:00:00 2001 From: Samuel Hassine Date: Thu, 24 Nov 2022 08:47:53 +0100 Subject: [PATCH] [api] Fix the export filters after multi-keys enhancement --- opencti-platform/opencti-front/package.json | 2 +- opencti-platform/opencti-graphql/package.json | 2 +- .../src/domain/stixCoreRelationship.js | 42 +++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/opencti-platform/opencti-front/package.json b/opencti-platform/opencti-front/package.json index 64cb8e7c2111..200f0a603753 100644 --- a/opencti-platform/opencti-front/package.json +++ b/opencti-platform/opencti-front/package.json @@ -1,6 +1,6 @@ { "name": "opencti-front", - "version": "5.4.0", + "version": "5.4.1", "private": true, "main": "src/index.tsx", "license": "Apache-2.0", diff --git a/opencti-platform/opencti-graphql/package.json b/opencti-platform/opencti-graphql/package.json index 8233fcb93937..da2b4427ed03 100644 --- a/opencti-platform/opencti-graphql/package.json +++ b/opencti-platform/opencti-graphql/package.json @@ -1,6 +1,6 @@ { "name": "opencti-graphql", - "version": "5.4.0", + "version": "5.4.1", "main": "src/back.js", "license": "Apache-2.0", "scripts": { diff --git a/opencti-platform/opencti-graphql/src/domain/stixCoreRelationship.js b/opencti-platform/opencti-graphql/src/domain/stixCoreRelationship.js index d0460bfa3afb..d3805c0ce800 100644 --- a/opencti-platform/opencti-graphql/src/domain/stixCoreRelationship.js +++ b/opencti-platform/opencti-graphql/src/domain/stixCoreRelationship.js @@ -130,33 +130,33 @@ export const stixCoreRelationshipsExportAsk = async (context, user, args) => { let newArgsFiltersFilters = argsFilters.filters; const initialParams = {}; if (argsFilters.filters && argsFilters.filters.length > 0) { - if (argsFilters.filters.filter((n) => n.key === 'relationship_type').length > 0) { - initialParams.relationship_type = R.head(R.head(argsFilters.filters.filter((n) => n.key === 'relationship_type')).values); - newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => n.key !== 'relationship_type'); + if (argsFilters.filters.filter((n) => n.key.includes('relationship_type')).length > 0) { + initialParams.relationship_type = R.head(R.head(argsFilters.filters.filter((n) => n.key.includes('relationship_type'))).values); + newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => !n.key.includes('relationship_type')); } - if (argsFilters.filters.filter((n) => n.key === 'elementId').length > 0) { - initialParams.elementId = R.head(R.head(argsFilters.filters.filter((n) => n.key === 'elementId')).values); - newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => n.key !== 'elementId'); + if (argsFilters.filters.filter((n) => n.key.includes('elementId')).length > 0) { + initialParams.elementId = R.head(R.head(argsFilters.filters.filter((n) => n.key.includes('elementId'))).values); + newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => !n.key.includes('elementId')); } - if (argsFilters.filters.filter((n) => n.key === 'fromId').length > 0) { - initialParams.fromId = R.head(R.head(argsFilters.filters.filter((n) => n.key === 'fromId')).values); - newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => n.key !== 'fromId'); + if (argsFilters.filters.filter((n) => n.key.includes('fromId')).length > 0) { + initialParams.fromId = R.head(R.head(argsFilters.filters.filter((n) => n.key.includes('fromId'))).values); + newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => !n.key.includes('fromId')); } - if (argsFilters.filters.filter((n) => n.key === 'toId').length > 0) { - initialParams.toId = R.head(R.head(argsFilters.filters.filter((n) => n.key === 'toId')).values); - newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => n.key !== 'toId'); + if (argsFilters.filters.filter((n) => n.key.includes('toId')).length > 0) { + initialParams.toId = R.head(R.head(argsFilters.filters.filter((n) => n.key.includes('toId'))).values); + newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => !n.key.includes('toId')); } - if (argsFilters.filters.filter((n) => n.key === 'elementWithTargetTypes').length > 0) { - initialParams.elementWithTargetTypes = R.head(argsFilters.filters.filter((n) => n.key === 'elementWithTargetTypes')).values; - newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => n.key !== 'elementWithTargetTypes'); + if (argsFilters.filters.filter((n) => n.key.includes('elementWithTargetTypes')).length > 0) { + initialParams.elementWithTargetTypes = R.head(argsFilters.filters.filter((n) => n.key.includes('elementWithTargetTypes'))).values; + newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => !n.key.includes('elementWithTargetTypes')); } - if (argsFilters.filters.filter((n) => n.key === 'fromTypes').length > 0) { - initialParams.fromTypes = R.head(argsFilters.filters.filter((n) => n.key === 'fromTypes')).values; - newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => n.key !== 'fromTypes'); + if (argsFilters.filters.filter((n) => n.key.includes('fromTypes')).length > 0) { + initialParams.fromTypes = R.head(argsFilters.filters.filter((n) => n.key.includes('fromTypes'))).values; + newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => !n.key.includes('fromTypes')); } - if (argsFilters.filters.filter((n) => n.key === 'toTypes').length > 0) { - initialParams.toTypes = R.head(argsFilters.filters.filter((n) => n.key === 'toTypes')).values; - newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => n.key !== 'toTypes'); + if (argsFilters.filters.filter((n) => n.key.includes('toTypes')).length > 0) { + initialParams.toTypes = R.head(argsFilters.filters.filter((n) => n.key.includes('toTypes'))).values; + newArgsFiltersFilters = newArgsFiltersFilters.filter((n) => !n.key.includes('toTypes')); } } const finalArgsFilter = R.assoc('filters', newArgsFiltersFilters, argsFilters);