From e4b4c3c0d0f785f5768f5f42df9455c59441a5ba Mon Sep 17 00:00:00 2001 From: Cathia Archidoit Date: Tue, 21 Nov 2023 17:20:55 +0100 Subject: [PATCH] [backend] fix taxii/feed (#2686) --- .../opencti-graphql/src/domain/feed.ts | 6 ------ .../opencti-graphql/src/domain/taxii.js | 20 ++----------------- .../01-database/taxii-filtering-test.js | 2 +- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/opencti-platform/opencti-graphql/src/domain/feed.ts b/opencti-platform/opencti-graphql/src/domain/feed.ts index 1cb21d30fa06..c856f85009a1 100644 --- a/opencti-platform/opencti-graphql/src/domain/feed.ts +++ b/opencti-platform/opencti-graphql/src/domain/feed.ts @@ -13,7 +13,6 @@ import { isStixDomainObject } from '../schema/stixDomainObject'; import type { DomainFindById } from './domainTypes'; import { publishUserAction } from '../listener/UserActionListener'; import { SYSTEM_USER, TAXIIAPI_SETCOLLECTIONS } from '../utils/access'; -import { validateFilterGroupForStixMatch } from '../utils/filtering/filtering-stix/stix-filtering'; const checkFeedIntegrity = (input: FeedAddInput) => { if (input.separator.length > 1) { @@ -37,11 +36,6 @@ const checkFeedIntegrity = (input: FeedAddInput) => { } }); } - - // our stix matching is currently limited, we need to validate the input filters - if (input.filters) { - validateFilterGroupForStixMatch(JSON.parse(input.filters)); - } }; export const createFeed = async (context: AuthContext, user: AuthUser, input: FeedAddInput): Promise => { diff --git a/opencti-platform/opencti-graphql/src/domain/taxii.js b/opencti-platform/opencti-graphql/src/domain/taxii.js index 7e1f5d59eb8f..2849d262527a 100644 --- a/opencti-platform/opencti-graphql/src/domain/taxii.js +++ b/opencti-platform/opencti-graphql/src/domain/taxii.js @@ -2,14 +2,10 @@ import * as R from 'ramda'; import { Promise } from 'bluebird'; import { elIndex, elPaginate } from '../database/engine'; -import { - INDEX_INTERNAL_OBJECTS, - READ_INDEX_INTERNAL_OBJECTS, - READ_STIX_INDICES -} from '../database/utils'; +import { INDEX_INTERNAL_OBJECTS, READ_INDEX_INTERNAL_OBJECTS, READ_STIX_INDICES } from '../database/utils'; import { generateInternalId, generateStandardId } from '../schema/identifier'; import { ENTITY_TYPE_TAXII_COLLECTION } from '../schema/internalObject'; -import { deleteElementById, updateAttribute, stixLoadByIds } from '../database/middleware'; +import { deleteElementById, stixLoadByIds, updateAttribute } from '../database/middleware'; import { listEntities, storeLoadById } from '../database/middleware-loader'; import { ForbiddenAccess, FunctionalError } from '../config/errors'; import { delEditContext, notify, setEditContext } from '../database/redis'; @@ -18,18 +14,12 @@ import { addFilter } from '../utils/filtering/filtering-utils'; import { convertFiltersToQueryOptions } from '../utils/filtering/filtering-resolution'; import { publishUserAction } from '../listener/UserActionListener'; import { MEMBER_ACCESS_RIGHT_VIEW, SYSTEM_USER, TAXIIAPI_SETCOLLECTIONS } from '../utils/access'; -import { validateFilterGroupForStixMatch } from '../utils/filtering/filtering-stix/stix-filtering'; const MAX_PAGINATION_ELEMENTS = 500; const STIX_MEDIA_TYPE = 'application/stix+json;version=2.1'; // Taxii graphQL handlers export const createTaxiiCollection = async (context, user, input) => { - // our stix matching is currently limited, we need to validate the input filters - if (input.filters) { - validateFilterGroupForStixMatch(JSON.parse(input.filters)); - } - const collectionId = generateInternalId(); const data = { id: collectionId, @@ -72,12 +62,6 @@ export const taxiiCollectionEditField = async (context, user, collectionId, inpu return item; }); - const filtersItem = finalInput.find((item) => item.key === 'filters'); - if (filtersItem?.value) { - // our stix matching is currently limited, we need to validate the input filters - validateFilterGroupForStixMatch(JSON.parse(filtersItem.value)); - } - const { element } = await updateAttribute(context, user, collectionId, ENTITY_TYPE_TAXII_COLLECTION, finalInput); await publishUserAction({ user, diff --git a/opencti-platform/opencti-graphql/tests/02-integration/01-database/taxii-filtering-test.js b/opencti-platform/opencti-graphql/tests/02-integration/01-database/taxii-filtering-test.js index 697e67f173fb..7f244b771dd0 100644 --- a/opencti-platform/opencti-graphql/tests/02-integration/01-database/taxii-filtering-test.js +++ b/opencti-platform/opencti-graphql/tests/02-integration/01-database/taxii-filtering-test.js @@ -81,7 +81,7 @@ describe('Complex filters combinations, behavior tested on taxii collections', ( input: { name: 'Taxii', description: 'Taxii description', - filters: JSON.stringify({}), + filters: undefined, }, }; const taxii = await queryAsAdmin({