Skip to content

Commit

Permalink
[backend] fix taxii/feed (#2686)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit committed Nov 22, 2023
1 parent ff3b987 commit e4b4c3c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
6 changes: 0 additions & 6 deletions opencti-platform/opencti-graphql/src/domain/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<BasicStoreEntityFeed> => {
Expand Down
20 changes: 2 additions & 18 deletions opencti-platform/opencti-graphql/src/domain/taxii.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit e4b4c3c

Please sign in to comment.