Projects STRLCPY opencti Commits bb13461a
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-front/.eslintrc.json
    skipped 1 lines
    2 2   "extends": [
    3 3   "airbnb-base",
    4 4   "airbnb-typescript/base",
     5 + "plugin:import/recommended",
    5 6   "plugin:import/typescript",
    6 7   "plugin:@typescript-eslint/eslint-recommended",
    7 8   "plugin:@typescript-eslint/recommended"
    skipped 29 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/.eslintrc.json
    skipped 2 lines
    3 3   "extends": [
    4 4   "airbnb-base",
    5 5   "airbnb-typescript/base",
     6 + "plugin:import/recommended",
    6 7   "plugin:import/typescript",
    7 8   "plugin:@typescript-eslint/eslint-recommended",
    8 9   "plugin:@typescript-eslint/recommended"
    skipped 4 lines
    13 14   "project": "./tsconfig.json"
    14 15   },
    15 16   "env": { "jest": true },
     17 + "ignorePatterns": ["**/node_module/**", "**/builder/**", "**/static/**", "jest.setup.js"],
    16 18   "rules": {
    17 19   "import/extensions": [
    18 20   "error",
    skipped 38 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/database/middleware-loader.ts
    1 1  import * as R from 'ramda';
    2 2  import { offsetToCursor, READ_ENTITIES_INDICES, READ_RELATIONSHIPS_INDICES } from './utils';
    3  -import { elPaginate } from './engine';
     3 +import { elFindByIds, elLoadById, elPaginate } from './engine';
    4 4  import { buildRefRelationKey } from '../schema/general';
    5 5  import type { AuthContext, AuthUser } from '../types/user';
    6  -import type { BasicStoreCommon, BasicStoreEntity, StoreEntityConnection, StoreProxyRelation } from '../types/store';
    7  -import { UnsupportedError } from '../config/errors';
     6 +import type {
     7 + BasicStoreCommon,
     8 + BasicStoreEntity,
     9 + BasicStoreObject,
     10 + StoreEntityConnection,
     11 + StoreProxyRelation
     12 +} from '../types/store';
     13 +import { FunctionalError, UnsupportedError } from '../config/errors';
    8 14   
    9 15  const MAX_SEARCH_SIZE = 5000;
    10 16   
    skipped 18 lines
    29 35   filters?: Array<Filter> | null;
    30 36   filterMode?: 'and' | 'or' | undefined | null;
    31 37   callback?: (result: Array<T>) => Promise<boolean | void>
     38 +}
     39 + 
     40 +type InternalListEntities = <T extends BasicStoreCommon>(context: AuthContext, user: AuthUser, entityTypes: Array<string>, args: EntityOptions<T>) => Promise<Array<T>>;
     41 +type InternalFindByIds = (context: AuthContext, user: AuthUser, ids: string[], args?: { type?: string } & Record<string, string | boolean>) => Promise<BasicStoreObject[]>;
     42 + 
     43 +// entities
     44 +interface EntityFilters<T extends BasicStoreCommon> extends ListFilter<T> {
     45 + connectionFormat?: boolean;
     46 + elementId?: string | Array<string>;
     47 + fromId?: string | Array<string>;
     48 + fromRole?: string;
     49 + toId?: string | Array<string>;
     50 + toRole?: string;
     51 + fromTypes?: Array<string>;
     52 + toTypes?: Array<string>;
     53 + types?: Array<string>;
     54 + entityTypes?: Array<string>;
     55 + relationshipTypes?: Array<string>;
     56 + elementWithTargetTypes?: Array<string>;
     57 +}
     58 + 
     59 +export interface EntityOptions<T extends BasicStoreCommon> extends EntityFilters<T> {
     60 + indices?: Array<string>;
    32 61  }
    33 62   
    34 63  export const elList = async <T extends BasicStoreCommon>(context: AuthContext, user: AuthUser, indices: Array<string>, options: ListFilter<T> = {}): Promise<Array<T>> => {
    skipped 191 lines
    226 255   elementWithTargetTypes?: Array<string>;
    227 256  }
    228 257   
    229  -export interface EntityOptions<T extends BasicStoreCommon> extends EntityFilters<T> {
    230  - indices?: Array<string>;
    231  -}
    232  - 
    233 258  const buildEntityFilters = <T extends BasicStoreCommon>(args: EntityFilters<T> = {}) => {
    234 259   const builtFilters = { ...args };
    235 260   const { types = [], entityTypes = [], relationshipTypes = [] } = args;
    skipped 58 lines
    294 319   builtFilters.filters = customFilters;
    295 320   return builtFilters;
    296 321  };
    297  -export const listEntities = async <T extends BasicStoreEntity>(context: AuthContext, user: AuthUser, entityTypes: Array<string>,
    298  - args: EntityOptions<T> = {}): Promise<Array<T>> => {
     322 + 
     323 +export const listEntities: InternalListEntities = async (context, user, entityTypes, args = {}) => {
    299 324   const { indices = READ_ENTITIES_INDICES } = args;
    300 325   // TODO Reactivate this test after global migration to typescript
    301 326   // if (connectionFormat !== false) {
    skipped 13 lines
    315 340   return elPaginate(context, user, indices, paginateArgs);
    316 341  };
    317 342   
     343 +export const internalFindByIds: InternalFindByIds = async (context, user, ids, args = {}) => {
     344 + return await elFindByIds(context, user, ids, args) as unknown as BasicStoreObject[];
     345 +};
     346 + 
     347 +export const internalLoadById = async <T extends BasicStoreObject>(
     348 + context: AuthContext,
     349 + user: AuthUser,
     350 + id: string | undefined,
     351 + args: { type?: string } & Record<string, string> = {}
     352 +): Promise<T> => {
     353 + const { type } = args;
     354 + // TODO Remove when all Typescript
     355 + return await elLoadById(context, user, id, type as unknown as null) as unknown as T;
     356 +};
     357 +export const storeLoadById = async <T extends BasicStoreObject>(context: AuthContext, user: AuthUser, id: string, type: string, args: Record<string, string> = {}): Promise<T> => {
     358 + if (R.isNil(type) || R.isEmpty(type)) {
     359 + throw FunctionalError('You need to specify a type when loading a element');
     360 + }
     361 + const loadArgs = R.assoc<string, Record<string, string>, string>('type', type, args);
     362 + return internalLoadById<T>(context, user, id, loadArgs);
     363 +};
     364 + 
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/database/middleware.js
    skipped 38 lines
    39 39   elHistogramCount,
    40 40   elIndexElements,
    41 41   elList,
    42  - elLoadById,
    43 42   elPaginate,
    44 43   elUpdateElement,
    45 44   elUpdateEntityConnections,
    skipped 164 lines
    210 209  import { buildFilters } from './repository';
    211 210  import { createEntityAutoEnrichment } from '../domain/enrichment';
    212 211  import { convertStoreToStix, isTrustedStixId } from './stix-converter';
    213  -import { listAllRelations, listEntities, listRelations } from './middleware-loader';
     212 +import {
     213 + internalFindByIds,
     214 + internalLoadById,
     215 + listAllRelations,
     216 + listEntities,
     217 + listRelations,
     218 + storeLoadById
     219 +} from './middleware-loader';
    214 220  import { getEntitiesFromCache } from '../manager/cacheManager';
    215 221  import { checkRelationConsistency, isRelationConsistent } from '../utils/modelConsistency';
    216 222   
    skipped 196 lines
    413 419  // endregion
    414 420   
    415 421  // region Loader element
    416  -export const internalFindByIds = (context, user, ids, args = {}) => {
    417  - return elFindByIds(context, user, ids, args);
    418  -};
    419  -export const internalLoadById = (context, user, id, args = {}) => {
    420  - const { type } = args;
    421  - return elLoadById(context, user, id, type);
    422  -};
    423  -export const storeLoadById = async (context, user, id, type, args = {}) => {
    424  - if (R.isNil(type) || R.isEmpty(type)) {
    425  - throw FunctionalError('You need to specify a type when loading a element');
    426  - }
    427  - const loadArgs = R.assoc('type', type, args);
    428  - return internalLoadById(context, user, id, loadArgs);
    429  -};
    430 422  const loadElementMetaDependencies = async (context, user, element, args = {}) => {
    431 423   const { onlyMarking = true } = args;
    432 424   const elementId = element.internal_id;
    skipped 2659 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/attackPattern.js
    1  -import { batchListThroughGetFrom, createEntity, batchListThroughGetTo, storeLoadById } from '../database/middleware';
    2  -import { BUS_TOPICS } from '../config/conf';
    3  -import { notify } from '../database/redis';
    4  -import { ENTITY_TYPE_ATTACK_PATTERN, ENTITY_TYPE_COURSE_OF_ACTION } from '../schema/stixDomainObject';
    5  -import { ABSTRACT_STIX_DOMAIN_OBJECT } from '../schema/general';
    6  -import { RELATION_MITIGATES, RELATION_SUBTECHNIQUE_OF } from '../schema/stixCoreRelationship';
    7  -import { listEntities } from '../database/middleware-loader';
    8  - 
    9  -export const findById = (context, user, attackPatternId) => {
    10  - return storeLoadById(context, user, attackPatternId, ENTITY_TYPE_ATTACK_PATTERN);
    11  -};
    12  - 
    13  -export const findAll = (context, user, args) => {
    14  - return listEntities(context, user, [ENTITY_TYPE_ATTACK_PATTERN], args);
    15  -};
    16  - 
    17  -export const addAttackPattern = async (context, user, attackPattern) => {
    18  - const created = await createEntity(context, user, attackPattern, ENTITY_TYPE_ATTACK_PATTERN);
    19  - return notify(BUS_TOPICS[ABSTRACT_STIX_DOMAIN_OBJECT].ADDED_TOPIC, created, user);
    20  -};
    21  - 
    22  -export const batchCoursesOfAction = (context, user, attackPatternIds) => {
    23  - return batchListThroughGetFrom(context, user, attackPatternIds, RELATION_MITIGATES, ENTITY_TYPE_COURSE_OF_ACTION);
    24  -};
    25  - 
    26  -export const batchParentAttackPatterns = (context, user, attackPatternIds) => {
    27  - return batchListThroughGetTo(context, user, attackPatternIds, RELATION_SUBTECHNIQUE_OF, ENTITY_TYPE_ATTACK_PATTERN);
    28  -};
    29  - 
    30  -export const batchSubAttackPatterns = (context, user, attackPatternIds) => {
    31  - return batchListThroughGetFrom(context, user, attackPatternIds, RELATION_SUBTECHNIQUE_OF, ENTITY_TYPE_ATTACK_PATTERN);
    32  -};
    33  - 
    34  -export const batchIsSubAttackPattern = async (context, user, attackPatternIds) => {
    35  - const batchAttackPatterns = await batchListThroughGetTo(
    36  - context,
    37  - user,
    38  - attackPatternIds,
    39  - RELATION_SUBTECHNIQUE_OF,
    40  - ENTITY_TYPE_ATTACK_PATTERN,
    41  - { paginate: false }
    42  - );
    43  - return batchAttackPatterns.map((b) => b.length > 0);
    44  -};
    45  - 
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/attackPattern.ts
     1 +import { batchListThroughGetFrom, batchListThroughGetTo, createEntity } from '../database/middleware';
     2 +import { BUS_TOPICS } from '../config/conf';
     3 +import { notify } from '../database/redis';
     4 +import { ENTITY_TYPE_ATTACK_PATTERN, ENTITY_TYPE_COURSE_OF_ACTION } from '../schema/stixDomainObject';
     5 +import { ABSTRACT_STIX_DOMAIN_OBJECT } from '../schema/general';
     6 +import { RELATION_MITIGATES, RELATION_SUBTECHNIQUE_OF } from '../schema/stixCoreRelationship';
     7 +import { listEntities, storeLoadById } from '../database/middleware-loader';
     8 +import type { BatchByIds, CreateEntity, DomainFindAll, DomainFindById } from './domainTypes';
     9 + 
     10 +export const findById: DomainFindById = async (context, user, attackPatternId) => {
     11 + return storeLoadById(context, user, attackPatternId, ENTITY_TYPE_ATTACK_PATTERN);
     12 +};
     13 + 
     14 +export const findAll: DomainFindAll = (context, user, args) => listEntities(context, user, [ENTITY_TYPE_ATTACK_PATTERN], args);
     15 + 
     16 +export const addAttackPattern: CreateEntity = async (context, user, attackPattern) => {
     17 + const created = await createEntity(context, user, attackPattern, ENTITY_TYPE_ATTACK_PATTERN);
     18 + return notify(BUS_TOPICS[ABSTRACT_STIX_DOMAIN_OBJECT].ADDED_TOPIC, created, user);
     19 +};
     20 + 
     21 +export const batchCoursesOfAction: BatchByIds = (context, user, attackPatternIds) => {
     22 + return batchListThroughGetFrom(context, user, attackPatternIds, RELATION_MITIGATES, ENTITY_TYPE_COURSE_OF_ACTION);
     23 +};
     24 + 
     25 +export const batchParentAttackPatterns: BatchByIds = (context, user, attackPatternIds) => {
     26 + return batchListThroughGetTo(context, user, attackPatternIds, RELATION_SUBTECHNIQUE_OF, ENTITY_TYPE_ATTACK_PATTERN);
     27 +};
     28 + 
     29 +export const batchSubAttackPatterns: BatchByIds = (context, user, attackPatternIds) => {
     30 + return batchListThroughGetFrom(context, user, attackPatternIds, RELATION_SUBTECHNIQUE_OF, ENTITY_TYPE_ATTACK_PATTERN);
     31 +};
     32 + 
     33 +export const batchIsSubAttackPattern: BatchByIds = async (context, user, attackPatternIds) => {
     34 + const batchAttackPatterns = await batchListThroughGetTo(
     35 + context,
     36 + user,
     37 + attackPatternIds,
     38 + RELATION_SUBTECHNIQUE_OF,
     39 + ENTITY_TYPE_ATTACK_PATTERN,
     40 + { paginate: false }
     41 + );
     42 + return batchAttackPatterns.map((b) => b.length > 0);
     43 +};
     44 + 
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/campaign.js
    1 1  import { assoc, pipe, isNil } from 'ramda';
    2  -import { createEntity, storeLoadById, timeSeriesEntities } from '../database/middleware';
     2 +import { createEntity, timeSeriesEntities } from '../database/middleware';
    3 3  import { BUS_TOPICS } from '../config/conf';
    4 4  import { notify } from '../database/redis';
    5 5  import { ENTITY_TYPE_CAMPAIGN } from '../schema/stixDomainObject';
    6 6  import { ABSTRACT_STIX_DOMAIN_OBJECT } from '../schema/general';
    7 7  import { FROM_START, UNTIL_END } from '../utils/format';
    8  -import { listEntities } from '../database/middleware-loader';
     8 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    9 9   
    10 10  export const findById = (context, user, campaignId) => {
    11 11   return storeLoadById(context, user, campaignId, ENTITY_TYPE_CAMPAIGN);
    skipped 26 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/city.js
    1 1  import { assoc } from 'ramda';
    2  -import { batchLoadThroughGetTo, createEntity, storeLoadById } from '../database/middleware';
     2 +import { batchLoadThroughGetTo, createEntity } from '../database/middleware';
    3 3  import { BUS_TOPICS } from '../config/conf';
    4 4  import { notify } from '../database/redis';
    5 5  import { ENTITY_TYPE_LOCATION_CITY, ENTITY_TYPE_LOCATION_COUNTRY } from '../schema/stixDomainObject';
    6 6  import { RELATION_LOCATED_AT } from '../schema/stixCoreRelationship';
    7 7  import { ABSTRACT_STIX_DOMAIN_OBJECT } from '../schema/general';
    8  -import { listEntities } from '../database/middleware-loader';
     8 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    9 9   
    10 10  export const findById = (context, user, cityId) => {
    11 11   return storeLoadById(context, user, cityId, ENTITY_TYPE_LOCATION_CITY);
    skipped 16 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/connector.js
    skipped 3 lines
    4 4   deleteElementById,
    5 5   internalDeleteElementById,
    6 6   patchAttribute,
    7  - storeLoadById,
    8 7   updateAttribute
    9 8  } from '../database/middleware';
    10 9  import { completeConnector, connectors, connectorsFor } from '../database/repository';
    skipped 8 lines
    19 18  import { delEditContext, notify, setEditContext } from '../database/redis';
    20 19  import { BUS_TOPICS, logApp } from '../config/conf';
    21 20  import { deleteWorkForConnector } from './work';
    22  -import { listEntities } from '../database/middleware-loader';
     21 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    23 22   
    24 23  // region connectors
    25 24  export const loadConnectorById = (context, user, id) => {
    skipped 172 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/container.js
    1 1  import * as R from 'ramda';
    2 2  import { RELATION_OBJECT } from '../schema/stixMetaRelationship';
    3  -import { paginateAllThings, listThings, storeLoadById, listAllThings } from '../database/middleware';
    4  -import { listEntities, listRelations } from '../database/middleware-loader';
     3 +import { paginateAllThings, listThings, listAllThings } from '../database/middleware';
     4 +import { listEntities, listRelations, storeLoadById } from '../database/middleware-loader';
    5 5  import { buildRefRelationKey, ENTITY_TYPE_CONTAINER, ID_INFERRED, ID_INTERNAL } from '../schema/general';
    6 6  import { isStixDomainObjectContainer } from '../schema/stixDomainObject';
    7 7  import { buildPagination } from '../database/utils';
    skipped 72 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/country.js
    1 1  import { assoc } from 'ramda';
    2  -import { createEntity, storeLoadById, batchLoadThroughGetTo } from '../database/middleware';
    3  -import { listEntities } from '../database/middleware-loader';
     2 +import { createEntity, batchLoadThroughGetTo } from '../database/middleware';
     3 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    4 4  import { BUS_TOPICS } from '../config/conf';
    5 5  import { notify } from '../database/redis';
    6 6  import { ENTITY_TYPE_LOCATION_COUNTRY, ENTITY_TYPE_LOCATION_REGION } from '../schema/stixDomainObject';
    skipped 25 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/courseOfAction.js
    1  -import { createEntity, batchListThroughGetTo, storeLoadById } from '../database/middleware';
    2  -import { listEntities } from '../database/middleware-loader';
     1 +import { createEntity, batchListThroughGetTo } from '../database/middleware';
     2 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    3 3  import { BUS_TOPICS } from '../config/conf';
    4 4  import { notify } from '../database/redis';
    5 5  import { ENTITY_TYPE_ATTACK_PATTERN, ENTITY_TYPE_COURSE_OF_ACTION } from '../schema/stixDomainObject';
    skipped 20 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/domainTypes.ts
     1 +import type { BasicStoreObject } from '../types/store';
     2 +import type { AuthContext, AuthUser } from '../types/user';
     3 +import type { EntityOptions } from '../database/middleware-loader';
     4 + 
     5 +export type DomainFindAll = (context: AuthContext, user: AuthUser, args: EntityOptions<BasicStoreObject>) => Promise<BasicStoreObject[]>;
     6 +export type DomainFindById<T = BasicStoreObject> = (context: AuthContext, user: AuthUser, id: string) => Promise<T>;
     7 +export type BatchByIds = (context: AuthContext, user: AuthUser, ids: string[]) => any;
     8 +export type CreateEntity = (context: AuthContext, user: AuthUser, input: { objects: never[] }) => any;
     9 + 
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/externalReference.js
    1  -import { assoc } from 'ramda';
    2 1  import * as R from 'ramda';
     2 +import { assoc } from 'ramda';
    3 3  import { delEditContext, notify, setEditContext } from '../database/redis';
    4 4  import {
    5 5   createEntity,
    6 6   createRelation,
    7 7   deleteElementById,
    8 8   deleteRelationsByFromAndTo,
    9  - internalLoadById,
    10 9   listThings,
    11  - storeLoadById,
    12 10   paginateAllThings,
    13 11   updateAttribute,
    14 12  } from '../database/middleware';
    15  -import { listEntities } from '../database/middleware-loader';
     13 +import { internalLoadById, listEntities, storeLoadById } from '../database/middleware-loader';
    16 14  import conf, { BUS_TOPICS } from '../config/conf';
    17 15  import { ForbiddenAccess, FunctionalError, ValidationError } from '../config/errors';
    18 16  import { ENTITY_TYPE_EXTERNAL_REFERENCE } from '../schema/stixMetaObject';
    skipped 99 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/feed.ts
    1 1  /* eslint-disable camelcase */
    2 2  import { ENTITY_TYPE_FEED } from '../schema/internalObject';
    3  -import { createEntity, deleteElementById, storeLoadById } from '../database/middleware';
    4  -import { listEntitiesPaginated } from '../database/middleware-loader';
    5  -import type { AuthUser, AuthContext } from '../types/user';
     3 +import { createEntity, deleteElementById } from '../database/middleware';
     4 +import { listEntitiesPaginated, storeLoadById } from '../database/middleware-loader';
     5 +import type { AuthContext, AuthUser } from '../types/user';
    6 6  import type { FeedAddInput, QueryFeedsArgs } from '../generated/graphql';
    7 7  import type { StoreEntityFeed } from '../types/store';
    8 8  import { elReplace } from '../database/engine';
    skipped 1 lines
    10 10  import { FunctionalError, UnsupportedError, ValidationError } from '../config/errors';
    11 11  import { isStixCyberObservable } from '../schema/stixCyberObservable';
    12 12  import { isStixDomainObject } from '../schema/stixDomainObject';
     13 +import type { DomainFindById } from './domainTypes';
    13 14   
    14 15  const checkFeedIntegrity = (input: FeedAddInput) => {
    15 16   if (input.separator.length > 1) {
    skipped 23 lines
    39 40   checkFeedIntegrity(input);
    40 41   return createEntity(context, user, input, ENTITY_TYPE_FEED);
    41 42  };
    42  -export const findById = async (context: AuthContext, user: AuthUser, feedId: string): Promise<StoreEntityFeed> => {
    43  - return storeLoadById(context, user, feedId, ENTITY_TYPE_FEED) as unknown as StoreEntityFeed;
     43 +export const findById: DomainFindById<StoreEntityFeed> = async (context: AuthContext, user: AuthUser, feedId: string) => {
     44 + return storeLoadById<StoreEntityFeed>(context, user, feedId, ENTITY_TYPE_FEED);
    44 45  };
    45 46  export const editFeed = async (context: AuthContext, user: AuthUser, id: string, input: FeedAddInput): Promise<StoreEntityFeed> => {
    46 47   checkFeedIntegrity(input);
    skipped 15 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/group.js
    skipped 6 lines
    7 7   deleteElementById,
    8 8   deleteRelationsByFromAndTo,
    9 9   listThroughGetFrom,
    10  - storeLoadById,
    11 10   updateAttribute,
    12 11  } from '../database/middleware';
    13  -import { listEntities } from '../database/middleware-loader';
     12 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    14 13  import { BUS_TOPICS } from '../config/conf';
    15 14  import { delEditContext, notify, setEditContext } from '../database/redis';
    16 15  import { ENTITY_TYPE_GROUP, ENTITY_TYPE_USER } from '../schema/internalObject';
    skipped 89 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/identity.js
    1 1  import { pipe, assoc, dissoc, filter } from 'ramda';
    2  -import { createEntity, storeLoadById } from '../database/middleware';
     2 +import { createEntity } from '../database/middleware';
    3 3  import { BUS_TOPICS } from '../config/conf';
    4 4  import { notify } from '../database/redis';
    5 5  import { ABSTRACT_STIX_DOMAIN_OBJECT, ENTITY_TYPE_IDENTITY } from '../schema/general';
    6 6  import { ENTITY_TYPE_IDENTITY_SECTOR, isStixDomainObjectIdentity } from '../schema/stixDomainObject';
    7  -import { listEntities } from '../database/middleware-loader';
     7 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    8 8   
    9 9  export const findById = async (context, user, identityId) => {
    10 10   return storeLoadById(context, user, identityId, ENTITY_TYPE_IDENTITY);
    skipped 20 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/incident.js
    1 1  import { assoc, pipe } from 'ramda';
    2  -import { createEntity, storeLoadById, timeSeriesEntities } from '../database/middleware';
    3  -import { listEntities } from '../database/middleware-loader';
     2 +import { createEntity, timeSeriesEntities } from '../database/middleware';
     3 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    4 4  import { BUS_TOPICS } from '../config/conf';
    5 5  import { notify } from '../database/redis';
    6 6  import { ENTITY_TYPE_INCIDENT } from '../schema/stixDomainObject';
    skipped 32 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/indicator.js
    skipped 4 lines
    5 5   createEntity,
    6 6   createRelation,
    7 7   batchListThroughGetTo,
    8  - storeLoadById,
    9 8   timeSeriesEntities,
    10 9   distributionEntities, storeLoadByIdWithRefs,
    11 10  } from '../database/middleware';
    12  -import { listEntities } from '../database/middleware-loader';
     11 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    13 12  import { BUS_TOPICS } from '../config/conf';
    14 13  import { notify } from '../database/redis';
    15 14  import { findById as findMarkingDefinitionById } from './markingDefinition';
    skipped 260 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/individual.js
    1 1  import { assoc } from 'ramda';
    2  -import { createEntity, batchListThroughGetTo, storeLoadById } from '../database/middleware';
    3  -import { listEntities } from '../database/middleware-loader';
     2 +import { createEntity, batchListThroughGetTo } from '../database/middleware';
     3 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    4 4  import { BUS_TOPICS } from '../config/conf';
    5 5  import { notify } from '../database/redis';
    6 6  import { ENTITY_TYPE_IDENTITY_INDIVIDUAL, ENTITY_TYPE_IDENTITY_ORGANIZATION } from '../schema/stixDomainObject';
    skipped 25 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/infrastructure.js
    1  -import { createEntity, storeLoadById } from '../database/middleware';
    2  -import { listEntities } from '../database/middleware-loader';
     1 +import { createEntity } from '../database/middleware';
     2 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    3 3  import { BUS_TOPICS } from '../config/conf';
    4 4  import { notify } from '../database/redis';
    5 5  import { ENTITY_TYPE_INFRASTRUCTURE } from '../schema/stixDomainObject';
    skipped 15 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/intrusionSet.js
    1 1  import { assoc, pipe, isNil } from 'ramda';
    2  -import { createEntity, storeLoadById, batchListThroughGetTo } from '../database/middleware';
    3  -import { listEntities } from '../database/middleware-loader';
     2 +import { createEntity, batchListThroughGetTo } from '../database/middleware';
     3 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    4 4  import { BUS_TOPICS } from '../config/conf';
    5 5  import { notify } from '../database/redis';
    6 6  import { ENTITY_TYPE_INTRUSION_SET } from '../schema/stixDomainObject';
    skipped 25 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/killChainPhase.js
    1 1  import { pipe, assoc } from 'ramda';
    2 2  import { delEditContext, notify, setEditContext } from '../database/redis';
    3  -import { createEntity, createRelation, deleteElementById, storeLoadById, updateAttribute } from '../database/middleware';
    4  -import { listEntities } from '../database/middleware-loader';
     3 +import { createEntity, createRelation, deleteElementById, updateAttribute } from '../database/middleware';
     4 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    5 5  import { BUS_TOPICS } from '../config/conf';
    6 6  import { ENTITY_TYPE_KILL_CHAIN_PHASE } from '../schema/stixMetaObject';
    7 7  import { RELATION_KILL_CHAIN_PHASE } from '../schema/stixMetaRelationship';
    skipped 56 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/label.js
    1 1  import { assoc, pipe } from 'ramda';
    2 2  import { delEditContext, notify, setEditContext } from '../database/redis';
    3  -import { createEntity, deleteElementById, storeLoadById, updateAttribute } from '../database/middleware';
    4  -import { listEntities } from '../database/middleware-loader';
     3 +import { createEntity, deleteElementById, updateAttribute } from '../database/middleware';
     4 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    5 5  import { BUS_TOPICS } from '../config/conf';
    6 6  import { ENTITY_TYPE_LABEL } from '../schema/stixMetaObject';
    7 7  import { generateStandardId, normalizeName } from '../schema/identifier';
    skipped 58 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/location.js
    1 1  import { pipe, assoc, dissoc, filter } from 'ramda';
    2  -import { createEntity, storeLoadById } from '../database/middleware';
    3  -import { listEntities } from '../database/middleware-loader';
     2 +import { createEntity } from '../database/middleware';
     3 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    4 4  import { BUS_TOPICS } from '../config/conf';
    5 5  import { notify } from '../database/redis';
    6 6  import { ABSTRACT_STIX_DOMAIN_OBJECT, ENTITY_TYPE_LOCATION } from '../schema/general';
    skipped 23 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/log.js
    skipped 2 lines
    3 3  import { elPaginate } from '../database/engine';
    4 4  import conf, { booleanConf } from '../config/conf';
    5 5  import { findById } from './user';
    6  -import { storeLoadById, timeSeriesEntities } from '../database/middleware';
     6 +import { timeSeriesEntities } from '../database/middleware';
    7 7  import { EVENT_TYPE_CREATE, INDEX_HISTORY, READ_INDEX_HISTORY } from '../database/utils';
    8 8  import { SYSTEM_USER } from '../utils/access';
     9 +import { storeLoadById } from '../database/middleware-loader';
    9 10   
    10 11  export const findAll = (context, user, args) => {
    11 12   const finalArgs = R.pipe(
    skipped 45 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/malware.js
    1 1  import { assoc, isNil, pipe } from 'ramda';
    2  -import { createEntity, storeLoadById } from '../database/middleware';
    3  -import { listEntities } from '../database/middleware-loader';
     2 +import { createEntity } from '../database/middleware';
     3 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    4 4  import { BUS_TOPICS } from '../config/conf';
    5 5  import { notify } from '../database/redis';
    6 6  import { ENTITY_TYPE_MALWARE } from '../schema/stixDomainObject';
    skipped 20 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/markingDefinition.js
    1 1  import * as R from 'ramda';
    2 2  import { delEditContext, notify, setEditContext } from '../database/redis';
    3  -import { createEntity, deleteElementById, storeLoadById, updateAttribute } from '../database/middleware';
    4  -import { listEntities } from '../database/middleware-loader';
     3 +import { createEntity, deleteElementById, updateAttribute } from '../database/middleware';
     4 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    5 5  import { BUS_TOPICS } from '../config/conf';
    6 6  import { ENTITY_TYPE_MARKING_DEFINITION } from '../schema/stixMetaObject';
    7 7  import { ENTITY_TYPE_GROUP } from '../schema/internalObject';
    skipped 55 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/note.js
    skipped 1 lines
    2 2  import {
    3 3   createEntity,
    4 4   distributionEntities,
    5  - internalLoadById,
    6  - storeLoadById,
    7 5   timeSeriesEntities,
    8 6  } from '../database/middleware';
    9  -import { listEntities } from '../database/middleware-loader';
     7 +import { internalLoadById, listEntities, storeLoadById } from '../database/middleware-loader';
    10 8  import { findAll as findIndividuals, addIndividual } from './individual';
    11 9  import { BUS_TOPICS } from '../config/conf';
    12 10  import { notify } from '../database/redis';
    skipped 110 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/observedData.js
    skipped 1 lines
    2 2  import {
    3 3   createEntity,
    4 4   distributionEntities,
    5  - internalLoadById,
    6  - storeLoadById,
    7 5   timeSeriesEntities,
    8 6  } from '../database/middleware';
    9  -import { listEntities } from '../database/middleware-loader';
     7 +import { internalLoadById, listEntities, storeLoadById } from '../database/middleware-loader';
    10 8  import { BUS_TOPICS } from '../config/conf';
    11 9  import { notify } from '../database/redis';
    12 10  import { ENTITY_TYPE_CONTAINER_OBSERVED_DATA, isStixDomainObject } from '../schema/stixDomainObject';
    skipped 122 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/opinion.js
    skipped 2 lines
    3 3  import {
    4 4   createEntity,
    5 5   distributionEntities,
    6  - internalLoadById,
    7  - storeLoadById,
    8 6   timeSeriesEntities,
    9 7  } from '../database/middleware';
    10  -import { listEntities } from '../database/middleware-loader';
     8 +import { internalLoadById, listEntities, storeLoadById } from '../database/middleware-loader';
    11 9  import { BUS_TOPICS } from '../config/conf';
    12 10  import { notify } from '../database/redis';
    13 11  import { ENTITY_TYPE_CONTAINER_OPINION } from '../schema/stixDomainObject';
    skipped 133 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/organization.js
    1 1  import { assoc } from 'ramda';
    2  -import { createEntity, batchListThroughGetTo, storeLoadById } from '../database/middleware';
    3  -import { listEntities } from '../database/middleware-loader';
     2 +import { createEntity, batchListThroughGetTo } from '../database/middleware';
     3 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    4 4  import { BUS_TOPICS } from '../config/conf';
    5 5  import { notify } from '../database/redis';
    6 6  import { ENTITY_TYPE_IDENTITY_ORGANIZATION, ENTITY_TYPE_IDENTITY_SECTOR } from '../schema/stixDomainObject';
    skipped 25 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/position.js
    1 1  import { assoc } from 'ramda';
    2  -import { createEntity, storeLoadById, batchLoadThroughGetTo } from '../database/middleware';
    3  -import { listEntities } from '../database/middleware-loader';
     2 +import { createEntity, batchLoadThroughGetTo } from '../database/middleware';
     3 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    4 4  import { BUS_TOPICS } from '../config/conf';
    5 5  import { notify } from '../database/redis';
    6 6  import { ENTITY_TYPE_LOCATION_CITY, ENTITY_TYPE_LOCATION_POSITION } from '../schema/stixDomainObject';
    skipped 25 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/region.js
    skipped 2 lines
    3 3   createEntity,
    4 4   batchListThroughGetFrom,
    5 5   batchListThroughGetTo,
    6  - storeLoadById,
    7 6   batchLoadThroughGetTo,
    8 7  } from '../database/middleware';
    9  -import { listEntities } from '../database/middleware-loader';
     8 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    10 9  import { BUS_TOPICS } from '../config/conf';
    11 10  import { notify } from '../database/redis';
    12 11  import { ENTITY_TYPE_LOCATION_COUNTRY, ENTITY_TYPE_LOCATION_REGION } from '../schema/stixDomainObject';
    skipped 38 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/report.js
    skipped 1 lines
    2 2  import {
    3 3   createEntity,
    4 4   distributionEntities,
    5  - internalLoadById,
    6  - storeLoadById,
    7 5   timeSeriesEntities,
    8 6  } from '../database/middleware';
    9  -import { listEntities } from '../database/middleware-loader';
     7 +import { internalLoadById, listEntities, storeLoadById } from '../database/middleware-loader';
    10 8  import { BUS_TOPICS } from '../config/conf';
    11 9  import { notify } from '../database/redis';
    12 10  import { ENTITY_TYPE_CONTAINER_REPORT } from '../schema/stixDomainObject';
    skipped 118 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/retentionRule.js
    1  -import { deleteElementById, storeLoadById, updateAttribute } from '../database/middleware';
    2  -import { listEntities } from '../database/middleware-loader';
     1 +import { deleteElementById, updateAttribute } from '../database/middleware';
     2 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    3 3  import { ENTITY_TYPE_RETENTION_RULE } from '../schema/internalObject';
    4 4  import { generateInternalId, generateStandardId } from '../schema/identifier';
    5 5  import { elIndex, elPaginate } from '../database/engine';
    skipped 60 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/sector.js
    skipped 2 lines
    3 3   createEntity,
    4 4   batchListThroughGetFrom,
    5 5   batchListThroughGetTo,
    6  - storeLoadById,
    7 6   listThroughGetFrom,
    8 7   batchLoadThroughGetTo,
    9 8  } from '../database/middleware';
    10  -import { listEntities, listRelations } from '../database/middleware-loader';
     9 +import { listEntities, listRelations, storeLoadById } from '../database/middleware-loader';
    11 10  import { BUS_TOPICS } from '../config/conf';
    12 11  import { notify } from '../database/redis';
    13 12  import { ENTITY_TYPE_IDENTITY_ORGANIZATION, ENTITY_TYPE_IDENTITY_SECTOR } from '../schema/stixDomainObject';
    skipped 42 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/settings.js
    1 1  import { getHeapStatistics } from 'v8';
    2  -import { createEntity, storeLoadById, updateAttribute, loadEntity } from '../database/middleware';
     2 +import { createEntity, updateAttribute, loadEntity } from '../database/middleware';
    3 3  import conf, {
    4 4   BUS_TOPICS,
    5 5   ENABLED_EXPIRED_MANAGER,
    skipped 10 lines
    16 16  import { getRabbitMQVersion } from '../database/rabbitmq';
    17 17  import { ENTITY_TYPE_SETTINGS } from '../schema/internalObject';
    18 18  import { SYSTEM_USER } from '../utils/access';
     19 +import { storeLoadById } from '../database/middleware-loader';
    19 20   
    20 21  export const getMemoryStatistics = () => {
    21 22   return { ...process.memoryUsage(), ...getHeapStatistics() };
    skipped 60 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/status.ts
    1 1  import { ENTITY_TYPE_STATUS, ENTITY_TYPE_STATUS_TEMPLATE } from '../schema/internalObject';
    2 2  import {
    3 3   createEntity,
    4  - deleteElementById,
    5  - internalDeleteElementById,
    6  - storeLoadById,
     4 + deleteElementById, internalDeleteElementById,
    7 5   updateAttribute
    8 6  } from '../database/middleware';
    9  -import { listEntitiesPaginated } from '../database/middleware-loader';
     7 +import { listEntitiesPaginated, storeLoadById } from '../database/middleware-loader';
    10 8  import { findById as findSubTypeById } from './subType';
    11 9  import { ABSTRACT_INTERNAL_OBJECT } from '../schema/general';
    12 10  import type {
    skipped 67 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/stix.js
    1 1  import mime from 'mime-types';
    2 2  import { assoc, invertObj, map, pipe, propOr } from 'ramda';
    3  -import { deleteElementById, internalLoadById } from '../database/middleware';
     3 +import { deleteElementById } from '../database/middleware';
    4 4  import { isStixObject } from '../schema/stixCoreObject';
    5 5  import { isStixRelationship } from '../schema/stixRelationship';
    6 6  import { FunctionalError, UnsupportedError } from '../config/errors';
    skipped 2 lines
    9 9  import { now, observableValue } from '../utils/format';
    10 10  import { createWork } from './work';
    11 11  import { pushToConnector } from '../database/rabbitmq';
     12 +import { internalLoadById } from '../database/middleware-loader';
    12 13   
    13 14  export const stixDelete = async (context, user, id) => {
    14 15   const element = await internalLoadById(context, user, id);
    skipped 111 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/stixCoreObject.js
    1 1  import * as R from 'ramda';
    2 2  import { map } from 'ramda';
    3 3  import {
     4 + batchListThroughGetFrom,
    4 5   batchListThroughGetTo,
     6 + batchLoadThroughGetTo,
    5 7   createRelation,
    6 8   createRelations,
    7 9   deleteElementById,
    8 10   deleteRelationsByFromAndTo,
    9  - internalLoadById,
    10  - batchListThroughGetFrom,
    11  - storeLoadById,
    12 11   mergeEntities,
    13  - batchLoadThroughGetTo,
    14 12   storeLoadByIdWithRefs,
    15 13  } from '../database/middleware';
    16  -import { listEntities } from '../database/middleware-loader';
     14 +import { internalLoadById, listEntities, storeLoadById } from '../database/middleware-loader';
    17 15  import { findAll as relationFindAll } from './stixCoreRelationship';
    18 16  import { lockResource, notify, storeUpdateEvent } from '../database/redis';
    19 17  import { BUS_TOPICS } from '../config/conf';
    skipped 10 lines
    30 28   RELATION_OBJECT_MARKING,
    31 29  } from '../schema/stixMetaRelationship';
    32 30  import {
    33  - ENTITY_TYPE_CONTAINER_NOTE, ENTITY_TYPE_CONTAINER_OBSERVED_DATA,
     31 + ENTITY_TYPE_CONTAINER_NOTE,
     32 + ENTITY_TYPE_CONTAINER_OBSERVED_DATA,
    34 33   ENTITY_TYPE_CONTAINER_OPINION,
    35 34   ENTITY_TYPE_CONTAINER_REPORT
    36 35  } from '../schema/stixDomainObject';
    skipped 217 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/stixCoreRelationship.js
    skipped 6 lines
    7 7   deleteRelationsByFromAndTo,
    8 8   batchListThroughGetFrom,
    9 9   batchListThroughGetTo,
    10  - storeLoadById,
    11  - updateAttribute, internalLoadById
     10 + updateAttribute,
    12 11  } from '../database/middleware';
    13 12  import { BUS_TOPICS } from '../config/conf';
    14 13  import { FunctionalError } from '../config/errors';
    skipped 25 lines
    40 39   ENTITY_TYPE_LABEL,
    41 40   ENTITY_TYPE_MARKING_DEFINITION,
    42 41  } from '../schema/stixMetaObject';
    43  -import { listRelations } from '../database/middleware-loader';
     42 +import { internalLoadById, listRelations, storeLoadById } from '../database/middleware-loader';
    44 43  import { askEntityExport, askListExport, exportTransformFilters } from './stix';
    45 44  import { workToExportFile } from './work';
    46 45  import { upload } from '../database/file-storage';
    skipped 214 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/stixCyberObservable.js
    skipped 11 lines
    12 12   deleteElementById,
    13 13   deleteRelationsByFromAndTo,
    14 14   distributionEntities,
    15  - internalLoadById,
    16 15   listThroughGetFrom,
    17  - storeLoadById,
    18 16   storeLoadByIdWithRefs,
    19 17   timeSeriesEntities,
    20 18   updateAttribute
    21 19  } from '../database/middleware';
    22  -import { listEntities } from '../database/middleware-loader';
     20 +import { internalLoadById, listEntities, storeLoadById } from '../database/middleware-loader';
    23 21  import { BUS_TOPICS, logApp } from '../config/conf';
    24 22  import { elCount } from '../database/engine';
    25 23  import { isNotEmptyField, READ_INDEX_STIX_CYBER_OBSERVABLES } from '../database/utils';
    skipped 423 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/stixCyberObservableRelationship.js
    1 1  import { propOr } from 'ramda';
    2 2  import { stixCoreRelationshipCleanContext, stixCoreRelationshipEditContext } from './stixCoreRelationship';
    3  -import { batchListThroughGetFrom, createRelation, deleteElementById, storeLoadById, updateAttribute } from '../database/middleware';
     3 +import { batchListThroughGetFrom, createRelation, deleteElementById, updateAttribute } from '../database/middleware';
    4 4  import { BUS_TOPICS } from '../config/conf';
    5 5  import { notify } from '../database/redis';
    6 6  import { ABSTRACT_STIX_CYBER_OBSERVABLE_RELATIONSHIP } from '../schema/general';
    7 7  import { FunctionalError } from '../config/errors';
    8 8  import { isStixCyberObservableRelationship } from '../schema/stixCyberObservableRelationship';
    9  -import { listRelations } from '../database/middleware-loader';
     9 +import { listRelations, storeLoadById } from '../database/middleware-loader';
    10 10  import { RELATION_OBJECT } from '../schema/stixMetaRelationship';
    11 11  import { ENTITY_TYPE_CONTAINER_NOTE, ENTITY_TYPE_CONTAINER_OPINION, ENTITY_TYPE_CONTAINER_REPORT } from '../schema/stixDomainObject';
    12 12   
    skipped 47 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/stixDomainObject.js
    skipped 7 lines
    8 8   deleteElementById,
    9 9   deleteRelationsByFromAndTo,
    10 10   distributionEntities,
    11  - internalLoadById,
    12 11   listThroughGetTo,
    13  - storeLoadById,
    14 12   timeSeriesEntities,
    15 13   updateAttribute,
    16 14  } from '../database/middleware';
    17  -import { listEntities } from '../database/middleware-loader';
     15 +import { internalLoadById, listEntities, storeLoadById } from '../database/middleware-loader';
    18 16  import { elCount } from '../database/engine';
    19 17  import { upload } from '../database/file-storage';
    20 18  import { workToExportFile } from './work';
    skipped 206 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/stixMetaRelationship.js
    skipped 2 lines
    3 3  import { ABSTRACT_STIX_META_RELATIONSHIP } from '../schema/general';
    4 4  import { isStixMetaRelationship } from '../schema/stixMetaRelationship';
    5 5  import { READ_INDEX_STIX_META_RELATIONSHIPS } from '../database/utils';
    6  -import { storeLoadById } from '../database/middleware';
    7  -import { listRelations } from '../database/middleware-loader';
     6 +import { listRelations, storeLoadById } from '../database/middleware-loader';
    8 7   
    9 8  export const findAll = async (context, user, args) => {
    10 9   return listRelations(context, user, propOr(ABSTRACT_STIX_META_RELATIONSHIP, 'relationship_type', args), args);
    skipped 23 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/stixRelationship.js
    1 1  import { propOr } from 'ramda';
    2  -import { deleteElementById, storeLoadById } from '../database/middleware';
     2 +import { deleteElementById } from '../database/middleware';
    3 3  import { ABSTRACT_STIX_RELATIONSHIP } from '../schema/general';
    4  -import { listRelations } from '../database/middleware-loader';
     4 +import { listRelations, storeLoadById } from '../database/middleware-loader';
    5 5   
    6 6  export const findAll = async (context, user, args) => {
    7 7   return listRelations(context, user, propOr(ABSTRACT_STIX_RELATIONSHIP, 'relationship_type', args), args);
    skipped 10 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/stixSightingRelationship.js
    skipped 5 lines
    6 6   deleteRelationsByFromAndTo,
    7 7   batchListThroughGetFrom,
    8 8   batchListThroughGetTo,
    9  - storeLoadById,
    10 9   updateAttribute,
    11 10   batchLoadThroughGetTo,
    12 11  } from '../database/middleware';
    skipped 21 lines
    34 33  } from '../schema/stixMetaObject';
    35 34  import { elCount } from '../database/engine';
    36 35  import { READ_INDEX_STIX_SIGHTING_RELATIONSHIPS } from '../database/utils';
    37  -import { listRelations } from '../database/middleware-loader';
     36 +import { listRelations, storeLoadById } from '../database/middleware-loader';
    38 37   
    39 38  export const findAll = async (context, user, args) => {
    40 39   return listRelations(context, user, STIX_SIGHTING_RELATIONSHIP, args);
    skipped 120 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/stream.js
    skipped 9 lines
    10 10   deleteElementById,
    11 11   deleteRelationsByFromAndTo,
    12 12   listThroughGetFrom,
    13  - storeLoadById,
    14 13   updateAttribute,
    15 14  } from '../database/middleware';
    16  -import { listEntities } from '../database/middleware-loader';
     15 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    17 16  import { delEditContext, notify, setEditContext } from '../database/redis';
    18 17  import { BUS_TOPICS } from '../config/conf';
    19 18  import { ABSTRACT_INTERNAL_RELATIONSHIP, BASE_TYPE_ENTITY } from '../schema/general';
    skipped 65 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/system.js
    1 1  import { assoc } from 'ramda';
    2  -import { createEntity, batchListThroughGetTo, storeLoadById } from '../database/middleware';
    3  -import { listEntities } from '../database/middleware-loader';
     2 +import { createEntity, batchListThroughGetTo } from '../database/middleware';
     3 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    4 4  import { BUS_TOPICS } from '../config/conf';
    5 5  import { notify } from '../database/redis';
    6 6  import { ENTITY_TYPE_IDENTITY_SYSTEM, ENTITY_TYPE_IDENTITY_ORGANIZATION } from '../schema/stixDomainObject';
    skipped 25 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/task.js
    skipped 3 lines
    4 4  import { elIndex, elPaginate } from '../database/engine';
    5 5  import { INDEX_INTERNAL_OBJECTS, READ_DATA_INDICES, READ_STIX_INDICES } from '../database/utils';
    6 6  import { ENTITY_TYPE_TASK } from '../schema/internalObject';
    7  -import { deleteElementById, storeLoadById, patchAttribute } from '../database/middleware';
     7 +import { deleteElementById, patchAttribute } from '../database/middleware';
    8 8  import { buildFilters } from '../database/repository';
    9 9  import { adaptFiltersFrontendFormat, GlobalFilters, TYPE_FILTER } from '../utils/filtering';
    10 10  import { ForbiddenAccess } from '../config/errors';
    11 11  import { BYPASS, SYSTEM_USER } from '../utils/access';
    12 12  import { RULE_PREFIX, KNOWLEDGE_DELETE } from '../schema/general';
    13  -import { listEntities } from '../database/middleware-loader';
     13 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    14 14   
    15 15  export const MAX_TASK_ELEMENTS = 500;
    16 16   
    skipped 132 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/taxii.js
    skipped 8 lines
    9 9  } from '../database/utils';
    10 10  import { generateInternalId, generateStandardId } from '../schema/identifier';
    11 11  import { ENTITY_TYPE_TAXII_COLLECTION } from '../schema/internalObject';
    12  -import { deleteElementById, storeLoadById, updateAttribute, stixLoadByIds } from '../database/middleware';
    13  -import { listEntities } from '../database/middleware-loader';
     12 +import { deleteElementById, updateAttribute, stixLoadByIds } from '../database/middleware';
     13 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    14 14  import { FunctionalError, ResourceNotFoundError } from '../config/errors';
    15 15  import { delEditContext, notify, setEditContext } from '../database/redis';
    16 16  import { BUS_TOPICS } from '../config/conf';
    skipped 130 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/threatActor.js
    1  -import { createEntity, batchListThroughGetFrom, storeLoadById } from '../database/middleware';
    2  -import { listEntities } from '../database/middleware-loader';
     1 +import { createEntity, batchListThroughGetFrom } from '../database/middleware';
     2 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    3 3  import { BUS_TOPICS } from '../config/conf';
    4 4  import { notify } from '../database/redis';
    5 5  import { ENTITY_TYPE_THREAT_ACTOR } from '../schema/stixDomainObject';
    skipped 20 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/tool.js
    1  -import { createEntity, storeLoadById } from '../database/middleware';
    2  -import { listEntities } from '../database/middleware-loader';
     1 +import { createEntity } from '../database/middleware';
     2 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    3 3  import { BUS_TOPICS } from '../config/conf';
    4 4  import { notify } from '../database/redis';
    5 5  import { ENTITY_TYPE_TOOL } from '../schema/stixDomainObject';
    skipped 15 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/user.js
    skipped 14 lines
    15 15   listThroughGetFrom,
    16 16   listThroughGetTo,
    17 17   patchAttribute,
    18  - storeLoadById,
    19 18   updateAttribute,
    20 19  } from '../database/middleware';
    21  -import { listEntities } from '../database/middleware-loader';
     20 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    22 21  import {
    23 22   ENTITY_TYPE_CAPABILITY,
    24 23   ENTITY_TYPE_GROUP,
    skipped 707 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/userSubscription.js
    skipped 5 lines
    6 6  import { ENTITY_TYPE_USER_SUBSCRIPTION } from '../schema/internalObject';
    7 7  import {
    8 8   deleteElementById,
    9  - internalLoadById,
    10  - storeLoadById,
    11 9   updateAttribute,
    12 10   storeLoadByIdWithRefs
    13 11  } from '../database/middleware';
    14  -import { listEntities } from '../database/middleware-loader';
     12 +import { internalLoadById, listEntities, storeLoadById } from '../database/middleware-loader';
    15 13  import { delEditContext, notify, setEditContext } from '../database/redis';
    16 14  import { baseUrl, BUS_TOPICS } from '../config/conf';
    17 15  import { FROM_START_STR, hoursAgo, minutesAgo, prepareDate } from '../utils/format';
    skipped 341 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/vulnerability.js
    1  -import { batchListThroughGetFrom, createEntity, storeLoadById } from '../database/middleware';
    2  -import { listEntities } from '../database/middleware-loader';
     1 +import { batchListThroughGetFrom, createEntity } from '../database/middleware';
     2 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    3 3  import { BUS_TOPICS } from '../config/conf';
    4 4  import { notify } from '../database/redis';
    5 5  import { ENTITY_TYPE_VULNERABILITY } from '../schema/stixDomainObject';
    skipped 21 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/domain/workspace.js
    skipped 4 lines
    5 5   createRelations,
    6 6   deleteElementById,
    7 7   deleteRelationsByFromAndTo,
    8  - internalLoadById,
    9 8   paginateAllThings,
    10 9   listThings,
    11  - storeLoadById,
    12 10   updateAttribute,
    13 11  } from '../database/middleware';
    14  -import { listEntities } from '../database/middleware-loader';
     12 +import { internalLoadById, listEntities, storeLoadById } from '../database/middleware-loader';
    15 13  import { BUS_TOPICS } from '../config/conf';
    16 14  import { delEditContext, notify, setEditContext } from '../database/redis';
    17 15  import { ENTITY_TYPE_WORKSPACE } from '../schema/internalObject';
    skipped 106 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/graphql/sseMiddleware.js
    skipped 6 lines
    7 7  import { createStreamProcessor, EVENT_CURRENT_VERSION, STREAM_BATCH_TIME } from '../database/redis';
    8 8  import { generateInternalId, generateStandardId } from '../schema/identifier';
    9 9  import { findById, streamCollectionGroups } from '../domain/stream';
    10  -import { internalLoadById, stixLoadById, stixLoadByIds, storeLoadByIdWithRefs } from '../database/middleware';
     10 +import { stixLoadById, stixLoadByIds, storeLoadByIdWithRefs } from '../database/middleware';
    11 11  import { elList, ES_MAX_CONCURRENCY, MAX_SPLIT } from '../database/engine';
    12 12  import {
    13 13   EVENT_TYPE_CREATE,
    skipped 26 lines
    40 40  import { adaptFiltersFrontendFormat, convertFiltersToQueryOptions, TYPE_FILTER } from '../utils/filtering';
    41 41  import { getParentTypes } from '../schema/schemaUtils';
    42 42  import { STIX_EXT_OCTI, STIX_EXT_OCTI_SCO } from '../types/stix-extensions';
    43  -import { listAllRelations } from '../database/middleware-loader';
     43 +import { internalLoadById, listAllRelations } from '../database/middleware-loader';
    44 44   
    45 45  const broadcastClients = {};
    46 46  const queryIndices = [...READ_STIX_INDICES, READ_INDEX_STIX_META_OBJECTS];
    skipped 662 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/manager/ruleManager.ts
    skipped 6 lines
    7 7  import conf, { ENABLED_RULE_ENGINE, logApp } from '../config/conf';
    8 8  import {
    9 9   createEntity,
    10  - internalLoadById,
    11 10   patchAttribute,
    12 11   stixLoadById,
    13 12   storeLoadByIdWithRefs
    skipped 15 lines
    29 28  import { getParentTypes } from '../schema/schemaUtils';
    30 29  import { isBasicRelationship } from '../schema/stixRelationship';
    31 30  import { isStixSightingRelationship } from '../schema/stixSightingRelationship';
    32  -import { elList } from '../database/middleware-loader';
     31 +import { elList, internalLoadById } from '../database/middleware-loader';
    33 32  import type { RuleDefinition, RuleRuntime, RuleScope } from '../types/rules';
    34 33  import type { BasicManagerEntity, BasicStoreCommon, BasicStoreEntity, StoreObject } from '../types/store';
    35 34  import type { AuthContext, AuthUser } from '../types/user';
    skipped 352 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/manager/syncManager.js
    skipped 4 lines
    5 5  import * as jsonpatch from 'fast-json-patch';
    6 6  import https from 'node:https';
    7 7  import conf, { logApp } from '../config/conf';
    8  -import { storeLoadById } from '../database/middleware';
    9 8  import { executionContext, SYSTEM_USER } from '../utils/access';
    10 9  import { TYPE_LOCK_ERROR } from '../config/errors';
    11 10  import Queue from '../utils/queue';
    skipped 2 lines
    14 13  import { EVENT_CURRENT_VERSION, lockResource } from '../database/redis';
    15 14  import { STIX_EXT_OCTI } from '../types/stix-extensions';
    16 15  import { utcDate } from '../utils/format';
    17  -import { listEntities } from '../database/middleware-loader';
     16 +import { listEntities, storeLoadById } from '../database/middleware-loader';
    18 17  import { wait } from '../database/utils';
    19 18  import { pushToSync } from '../database/rabbitmq';
    20 19  import { OPENCTI_SYSTEM_UUID } from '../schema/general';
    skipped 230 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/manager/taskManager.js
    skipped 27 lines
    28 28   createRelation,
    29 29   deleteElementById,
    30 30   deleteRelationsByFromAndTo,
    31  - internalFindByIds,
    32  - internalLoadById,
    33 31   mergeEntities,
    34 32   patchAttribute,
    35 33   stixLoadById,
    skipped 15 lines
    51 49  import { buildInternalEvent, rulesApplyHandler, rulesCleanHandler } from './ruleManager';
    52 50  import { RULE_MANAGER_USER } from '../rules/rules';
    53 51  import { buildFilters } from '../database/repository';
    54  -import { listAllRelations } from '../database/middleware-loader';
     52 +import { internalFindByIds, internalLoadById, listAllRelations } from '../database/middleware-loader';
    55 53  import { getActivatedRules, getRule } from '../domain/rules';
    56 54  import { isStixRelationship } from '../schema/stixRelationship';
    57 55  import { isStixObject } from '../schema/stixCoreObject';
    skipped 368 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/migrations/1613641570630-taxii-capabilities.js
    1 1  import { createCapabilities, TAXII_CAPABILITIES } from '../initialization';
    2  -import { deleteElementById, storeLoadById } from '../database/middleware';
     2 +import { deleteElementById } from '../database/middleware';
    3 3  import { ENTITY_TYPE_CAPABILITY } from '../schema/internalObject';
    4 4  import { generateStandardId } from '../schema/identifier';
    5 5  import { executionContext, SYSTEM_USER } from '../utils/access';
     6 +import { storeLoadById } from '../database/middleware-loader';
    6 7   
    7 8  export const up = async (next) => {
    8 9   const context = executionContext('migration');
    skipped 15 lines
  • ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/migrations/1652125339035-files_database.js
    skipped 2 lines
    3 3  import { deleteFiles, rawFilesListing, storeFileConverter } from '../database/file-storage';
    4 4  import { executionContext, SYSTEM_USER } from '../utils/access';
    5 5  import { elUpdate, ES_MAX_CONCURRENCY } from '../database/engine';
    6  -import { internalLoadById } from '../database/middleware';
    7 6  import { logApp } from '../config/conf';
     7 +import { internalLoadById } from '../database/middleware-loader';
    8 8   
    9 9  export const up = async (next) => {
    10 10   const context = executionContext('migration');
    skipped 28 lines
  • ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/migrations/1661196127751-artifacts.js
    skipped 2 lines
    3 3  import { deleteFiles, rawFilesListing, storeFileConverter } from '../database/file-storage';
    4 4  import { executionContext, SYSTEM_USER } from '../utils/access';
    5 5  import { elUpdate, ES_MAX_CONCURRENCY } from '../database/engine';
    6  -import { internalLoadById } from '../database/middleware';
    7 6  import { logApp } from '../config/conf';
     7 +import { internalLoadById } from '../database/middleware-loader';
    8 8   
    9 9  export const up = async (next) => {
    10 10   const context = executionContext('migration');
    skipped 34 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/migrations/1661470342448-tlpv2.js
    1 1  import { executionContext, SYSTEM_USER } from '../utils/access';
    2  -import { internalLoadById, patchAttribute } from '../database/middleware';
     2 +import { patchAttribute } from '../database/middleware';
    3 3  import { ENTITY_TYPE_MARKING_DEFINITION } from '../schema/stixMetaObject';
    4 4  import { addMarkingDefinition } from '../domain/markingDefinition';
    5 5  import { MARKING_TLP_CLEAR } from '../schema/identifier';
     6 +import { internalLoadById } from '../database/middleware-loader';
    6 7   
    7 8  export const up = async (next) => {
    8 9   const context = executionContext('migration');
    skipped 18 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/modules/channel/channel-domain.ts
    1 1  import type { AuthUser, AuthContext } from '../../types/user';
    2  -import { createEntity, storeLoadById } from '../../database/middleware';
     2 +import { createEntity } from '../../database/middleware';
    3 3  import { notify } from '../../database/redis';
    4 4  import { BUS_TOPICS } from '../../config/conf';
    5 5  import { ABSTRACT_STIX_DOMAIN_OBJECT } from '../../schema/general';
    6 6  import type { ChannelAddInput, QueryChannelsArgs } from '../../generated/graphql';
    7  -import { listEntitiesPaginated } from '../../database/middleware-loader';
     7 +import { listEntitiesPaginated, storeLoadById } from '../../database/middleware-loader';
    8 8  import { BasicStoreEntityChannel, ENTITY_TYPE_CHANNEL } from './channel-types';
    9 9   
    10 10  export const findById = (context: AuthContext, user: AuthUser, channelId: string): BasicStoreEntityChannel => {
    skipped 12 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/modules/event/event-domain.ts
    1 1  import type { AuthUser, AuthContext } from '../../types/user';
    2  -import { createEntity, storeLoadById } from '../../database/middleware';
     2 +import { createEntity } from '../../database/middleware';
    3 3  import { notify } from '../../database/redis';
    4 4  import { BUS_TOPICS } from '../../config/conf';
    5 5  import { ABSTRACT_STIX_DOMAIN_OBJECT } from '../../schema/general';
    6 6  import type { EventAddInput, QueryEventsArgs } from '../../generated/graphql';
    7  -import { listEntitiesPaginated } from '../../database/middleware-loader';
     7 +import { listEntitiesPaginated, storeLoadById } from '../../database/middleware-loader';
    8 8  import { BasicStoreEntityEvent, ENTITY_TYPE_EVENT } from './event-types';
    9 9   
    10 10  export const findById = (context: AuthContext, user: AuthUser, channelId: string): BasicStoreEntityEvent => {
    skipped 12 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/modules/grouping/grouping-domain.ts
    1 1  import * as R from 'ramda';
    2  -import type { AuthUser, AuthContext } from '../../types/user';
    3  -import {
    4  - createEntity,
    5  - distributionEntities,
    6  - internalLoadById,
    7  - storeLoadById,
    8  - timeSeriesEntities
    9  -} from '../../database/middleware';
     2 +import type { AuthContext, AuthUser } from '../../types/user';
     3 +import { createEntity, distributionEntities, timeSeriesEntities } from '../../database/middleware';
    10 4  import { notify } from '../../database/redis';
    11 5  import { BUS_TOPICS } from '../../config/conf';
    12 6  import { ABSTRACT_STIX_DOMAIN_OBJECT, buildRefRelationKey } from '../../schema/general';
    skipped 3 lines
    16 10   QueryGroupingsNumberArgs,
    17 11   QueryGroupingsTimeSeriesArgs,
    18 12  } from '../../generated/graphql';
    19  -import { EntityOptions, listEntitiesPaginated } from '../../database/middleware-loader';
     13 +import {
     14 + EntityOptions,
     15 + internalLoadById,
     16 + listEntitiesPaginated,
     17 + storeLoadById
     18 +} from '../../database/middleware-loader';
    20 19  import { BasicStoreEntityGrouping, ENTITY_TYPE_CONTAINER_GROUPING, GroupingNumberResult } from './grouping-types';
    21 20  import { isStixId } from '../../schema/schemaUtils';
    22 21  import { RELATION_CREATED_BY, RELATION_OBJECT } from '../../schema/stixMetaRelationship';
    23 22  import { elCount } from '../../database/engine';
    24 23  import { READ_INDEX_STIX_DOMAIN_OBJECTS } from '../../database/utils';
    25 24  import type { BasicStoreCommon } from '../../types/store';
     25 +import type { DomainFindById } from '../../domain/domainTypes';
    26 26   
    27  -export const findById = (context: AuthContext, user: AuthUser, channelId: string): BasicStoreEntityGrouping => {
    28  - return storeLoadById(context, user, channelId, ENTITY_TYPE_CONTAINER_GROUPING) as unknown as BasicStoreEntityGrouping;
     27 +export const findById: DomainFindById<BasicStoreEntityGrouping> = (context: AuthContext, user: AuthUser, channelId: string) => {
     28 + return storeLoadById<BasicStoreEntityGrouping>(context, user, channelId, ENTITY_TYPE_CONTAINER_GROUPING);
    29 29  };
    30 30   
    31 31  export const findAll = (context: AuthContext, user: AuthUser, opts: EntityOptions<BasicStoreEntityGrouping>) => {
    skipped 107 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/modules/language/language-domain.ts
    1 1  import type { AuthUser, AuthContext } from '../../types/user';
    2  -import { createEntity, storeLoadById } from '../../database/middleware';
     2 +import { createEntity } from '../../database/middleware';
    3 3  import { notify } from '../../database/redis';
    4 4  import { BUS_TOPICS } from '../../config/conf';
    5 5  import { ABSTRACT_STIX_DOMAIN_OBJECT } from '../../schema/general';
    6 6  import type { LanguageAddInput, QueryLanguagesArgs } from '../../generated/graphql';
    7  -import { listEntitiesPaginated } from '../../database/middleware-loader';
     7 +import { listEntitiesPaginated, storeLoadById } from '../../database/middleware-loader';
    8 8  import { BasicStoreEntityLanguage, ENTITY_TYPE_LANGUAGE } from './language-types';
    9 9   
    10 10  export const findById = (context: AuthContext, user: AuthUser, languageId: string): BasicStoreEntityLanguage => {
    skipped 12 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/modules/narrative/narrative-domain.ts
    1 1  import type { AuthUser, AuthContext } from '../../types/user';
    2  -import { batchListThroughGetFrom, batchListThroughGetTo, createEntity, storeLoadById } from '../../database/middleware';
     2 +import { batchListThroughGetFrom, batchListThroughGetTo, createEntity } from '../../database/middleware';
    3 3  import { notify } from '../../database/redis';
    4 4  import { BUS_TOPICS } from '../../config/conf';
    5 5  import { ABSTRACT_STIX_DOMAIN_OBJECT } from '../../schema/general';
    6 6  import type { NarrativeAddInput, QueryNarrativesArgs } from '../../generated/graphql';
    7  -import { listEntitiesPaginated } from '../../database/middleware-loader';
     7 +import { listEntitiesPaginated, storeLoadById } from '../../database/middleware-loader';
    8 8  import { BasicStoreEntityNarrative, ENTITY_TYPE_NARRATIVE } from './narrative-types';
    9 9  import { RELATION_SUBNARRATIVE_OF, RELATION_SUBTECHNIQUE_OF } from '../../schema/stixCoreRelationship';
    10 10  import { ENTITY_TYPE_ATTACK_PATTERN } from '../../schema/stixDomainObject';
    skipped 34 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/resolvers/attackPattern.js
    1 1  import {
    2 2   addAttackPattern,
    3  - findAll,
    4  - findById,
    5 3   batchCoursesOfAction,
     4 + batchIsSubAttackPattern,
    6 5   batchParentAttackPatterns,
    7 6   batchSubAttackPatterns,
    8  - batchIsSubAttackPattern,
     7 + findAll,
     8 + findById,
    9 9  } from '../domain/attackPattern';
    10 10  import {
    11 11   stixDomainObjectAddRelation,
    skipped 51 lines
  • ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/resolvers/file.js
    skipped 2 lines
    3 3  import { askJobImport, uploadImport, uploadPending } from '../domain/file';
    4 4  import { worksForSource } from '../domain/work';
    5 5  import { stixCoreObjectImportDelete } from '../domain/stixCoreObject';
    6  -import { internalLoadById } from '../database/middleware';
    7 6  import { ABSTRACT_STIX_DOMAIN_OBJECT } from '../schema/general';
     7 +import { internalLoadById } from '../database/middleware-loader';
    8 8   
    9 9  const fileResolvers = {
    10 10   Query: {
    skipped 33 lines
  • ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/resolvers/internalRelationship.js
    1  -import { storeLoadById } from '../database/middleware';
     1 +import { storeLoadById } from '../database/middleware-loader';
    2 2   
    3 3  const internalRelationshipResolvers = {
    4 4   InternalRelationship: {
    skipped 7 lines
  • ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/resolvers/log.js
    1 1  import { findAll, logsTimeSeries, logsWorkerConfig } from '../domain/log';
    2 2  import { findById } from '../domain/user';
    3 3  import { RETENTION_MANAGER_USER, SYSTEM_USER } from '../utils/access';
    4  -import { storeLoadById } from '../database/middleware';
     4 +import { storeLoadById } from '../database/middleware-loader';
    5 5  import { ENTITY_TYPE_EXTERNAL_REFERENCE } from '../schema/stixMetaObject';
    6 6  import { RULE_MANAGER_USER } from '../rules/rules';
    7 7   
    skipped 29 lines
  • ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/resolvers/rule.js
    1 1  import { cleanRuleManager, getManagerInfo } from '../manager/ruleManager';
    2  -import { internalLoadById } from '../database/middleware';
    3 2  import { getRules, setRuleActivation, getRule } from '../domain/rules';
     3 +import { internalLoadById } from '../database/middleware-loader';
    4 4   
    5 5  const ruleResolvers = {
    6 6   Query: {
    skipped 16 lines
  • ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/resolvers/userSubscription.js
    skipped 6 lines
    7 7   userSubscriptionEditContext,
    8 8   userSubscriptionCleanContext,
    9 9  } from '../domain/userSubscription';
    10  -import { internalLoadById } from '../database/middleware';
     10 +import { internalLoadById } from '../database/middleware-loader';
    11 11   
    12 12  const userSubscriptionResolvers = {
    13 13   Query: {
    skipped 22 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/rules/containerWithRefsBuilder.ts
    skipped 4 lines
    5 5  import {
    6 6   createInferredRelation,
    7 7   deleteInferredRuleElement,
    8  - internalFindByIds,
    9 8   storeLoadByIdWithRefs,
    10 9  } from '../database/middleware';
    11 10   
    skipped 1 lines
    13 12  import { createRuleContent, RULE_MANAGER_USER } from './rules';
    14 13  import { INPUT_OBJECTS } from '../schema/general';
    15 14  import { generateInternalType } from '../schema/schemaUtils';
    16  -import type { RuleDefinition, RelationTypes, RuleRuntime } from '../types/rules';
     15 +import type { RelationTypes, RuleDefinition, RuleRuntime } from '../types/rules';
    17 16  import type { StixId, StixObject } from '../types/stix-common';
    18 17  import type { StixReport } from '../types/stix-sdo';
    19 18  import type { StixRelation } from '../types/stix-sro';
    20 19  import type { BasicStoreRelation, StoreEntity, StoreObject } from '../types/store';
    21 20  import { STIX_EXT_OCTI } from '../types/stix-extensions';
    22  -import { listAllRelations } from '../database/middleware-loader';
     21 +import { internalFindByIds, listAllRelations } from '../database/middleware-loader';
    23 22  import type { DependenciesDeleteEvent, Event, RelationCreation, RuleEvent, UpdateEvent } from '../types/event';
    24 23  import {
    25 24   generateUpdateMessage,
    skipped 205 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/rules/localization-of-targets/LocalizationOfTargetsRule.ts
    1 1  /* eslint-disable camelcase */
    2  -import { createInferredRelation, deleteInferredRuleElement, internalLoadById } from '../../database/middleware';
     2 +import { createInferredRelation, deleteInferredRuleElement } from '../../database/middleware';
    3 3  import { buildPeriodFromDates, computeRangeIntersection } from '../../utils/format';
    4 4  import { RELATION_TARGETS } from '../../schema/stixCoreRelationship';
    5 5  import def from './LocalizationOfTargetsDefinition';
    skipped 5 lines
    11 11  import type { BasicStoreObject, BasicStoreRelation, StoreObject } from '../../types/store';
    12 12  import { RELATION_OBJECT_MARKING } from '../../schema/stixMetaRelationship';
    13 13  import { executionContext } from '../../utils/access';
     14 +import { internalLoadById } from '../../database/middleware-loader';
    14 15   
    15 16  const ruleLocalizationOfTargetsBuilder = () => {
    16 17   // Execution
    skipped 54 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/rules/observed-sighting/ObserveSightingRule.ts
    skipped 1 lines
    2 2  import {
    3 3   createInferredRelation,
    4 4   deleteInferredRuleElement,
    5  - internalLoadById,
    6 5   stixLoadById,
    7 6  } from '../../database/middleware';
    8 7  import { RELATION_BASED_ON } from '../../schema/stixCoreRelationship';
    skipped 10 lines
    19 18  import type { StixRelation } from '../../types/stix-sro';
    20 19  import type { BasicStoreEntity, BasicStoreRelation, StoreObject } from '../../types/store';
    21 20  import { STIX_EXT_OCTI } from '../../types/stix-extensions';
    22  -import { listAllRelations } from '../../database/middleware-loader';
     21 +import { internalLoadById, listAllRelations } from '../../database/middleware-loader';
    23 22  import type { Event, RelationCreation } from '../../types/event';
    24 23  import { executionContext } from '../../utils/access';
    25 24  import type { AuthContext } from '../../types/user';
    skipped 167 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/types/stix-sco.d.ts
    skipped 3 lines
    4 4  import { StixInternalExternalReference } from './stix-smo';
    5 5   
    6 6  // Artifact Object Specific Properties
    7  -interface ArtifactExtension extends CyberObjectExtension {
     7 +export interface ArtifactExtension extends CyberObjectExtension {
    8 8   additional_names: Array<string>;
    9 9  }
    10 10  // mime_type, payload_bin, url, hashes, encryption_algorithm, decryption_key
    11  -interface StixArtifact extends StixCyberObject {
     11 +export interface StixArtifact extends StixCyberObject {
    12 12   mime_type: string; // optional
    13 13   payload_bin: string; // optional
    14 14   url: string; // optional
    skipped 8 lines
    23 23   
    24 24  // AS Object Specific Properties
    25 25  // number, name, rir
    26  -interface StixAutonomousSystem extends StixCyberObject {
     26 +export interface StixAutonomousSystem extends StixCyberObject {
    27 27   number: number;
    28 28   name: string; // optional
    29 29   rir: string; // optional
    skipped 1 lines
    31 31   
    32 32  // Directory Object Specific Properties
    33 33  // path, path_enc, ctime, mtime, atime, contains_refs
    34  -interface StixDirectory extends StixCyberObject {
     34 +export interface StixDirectory extends StixCyberObject {
    35 35   path: string;
    36 36   path_enc: string; // optional
    37 37   ctime: Date; // optional
    skipped 4 lines
    42 42   
    43 43  // Domain Name Object Specific Properties
    44 44  // value, resolves_to_refs
    45  -interface StixDomainName extends StixCyberObject {
     45 +export interface StixDomainName extends StixCyberObject {
    46 46   value: string;
    47 47   resolves_to_refs: Array<StixId>; // optional
    48 48  }
    49 49   
    50 50  // Email Address Object Specific Properties
    51 51  // value, display_name, belongs_to_ref
    52  -interface StixEmailAddress extends StixCyberObject {
     52 +export interface StixEmailAddress extends StixCyberObject {
    53 53   value: string;
    54 54   display_name: string; // optional
    55 55   belongs_to_ref: StixId; // optional
    56 56  }
    57 57   
    58 58  // Email Message Object Specific Properties
    59  -interface StixInternalEmailBodyMultipart {
     59 +export interface StixInternalEmailBodyMultipart {
    60 60   content_type: string;
    61 61   content_disposition: string;
    62 62   body: string;
    63 63   body_raw_ref: StixId | undefined;
    64 64  }
    65 65   
    66  -interface StixEmailBodyMultipart extends StixInternalEmailBodyMultipart, StixCyberObject {
     66 +export interface StixEmailBodyMultipart extends StixInternalEmailBodyMultipart, StixCyberObject {
    67 67   labels: Array<string>;
    68 68   description: string;
    69 69   score: number;
    skipped 7 lines
    77 77   
    78 78  // is_multipart, date, content_type, from_ref, sender_ref, to_refs, cc_refs, bcc_refs,
    79 79  // subject, received_lines, additional_header_fields, body, body_multipart, raw_email_ref
    80  -interface StixEmailMessage extends StixCyberObject {
     80 +export interface StixEmailMessage extends StixCyberObject {
    81 81   is_multipart: boolean;
    82 82   date: Date; // optional - attribute_date
    83 83   content_type: string; // optional
    skipped 12 lines
    96 96  }
    97 97   
    98 98  // File Object Specific Properties
    99  -interface FileExtension extends CyberObjectExtension {
     99 +export interface FileExtension extends CyberObjectExtension {
    100 100   additional_names: Array<string>;
    101 101  }
    102 102  // hashes, size, name, name_enc, magic_number_hex, mime_type, ctime, mtime, atime,
    103 103  // parent_directory_ref, contains_refs, content_ref
    104  -interface StixFile extends StixCyberObject {
     104 +export interface StixFile extends StixCyberObject {
    105 105   hashes: object; // optional
    106 106   size: number; // optional
    107 107   name: string; // optional
    skipped 54 lines
    162 162   
    163 163  // Custom object extension - Cryptocurrency Wallet
    164 164  // value
    165  -interface StixCryptocurrencyWallet extends StixCyberObject {
     165 +export interface StixCryptocurrencyWallet extends StixCyberObject {
    166 166   value: string;
    167 167   description: string;
    168 168   score: number;
    skipped 10 lines
    179 179  // Simple custom object extension
    180 180  // Custom object extension - Cryptographic Key
    181 181  // value
    182  -interface StixCryptographicKey extends StixCyberObject {
     182 +export interface StixCryptographicKey extends StixCyberObject {
    183 183   value: string;
    184 184   description: string;
    185 185   score: number;
    skipped 9 lines
    195 195   
    196 196  // Custom object extension - Hostname
    197 197  // value
    198  -interface StixHostname extends StixCyberObject {
     198 +export interface StixHostname extends StixCyberObject {
    199 199   value: string;
    200 200   description: string;
    201 201   score: number;
    skipped 9 lines
    211 211   
    212 212  // Custom object extension - Text
    213 213  // value
    214  -interface StixText extends StixCyberObject {
     214 +export interface StixText extends StixCyberObject {
    215 215   value: string;
    216 216   description: string;
    217 217   score: number;
    skipped 9 lines
    227 227   
    228 228  // Custom object extension - User Agent
    229 229  // value
    230  -interface StixUserAgent extends StixCyberObject {
     230 +export interface StixUserAgent extends StixCyberObject {
    231 231   value: string;
    232 232   description: string;
    233 233   score: number;
    skipped 9 lines
    243 243   
    244 244  // Custom object extension - Bank Account
    245 245  // iban, bic, number
    246  -interface StixBankAccount extends StixCyberObject {
     246 +export interface StixBankAccount extends StixCyberObject {
    247 247   iban: string;
    248 248   bic: string;
    249 249   account_number: string;
    skipped 11 lines
    261 261   
    262 262  // Custom object extension - Phone number
    263 263  // value
    264  -interface StixPhoneNumber extends StixCyberObject {
     264 +export interface StixPhoneNumber extends StixCyberObject {
    265 265   value: string;
    266 266   description: string;
    267 267   score: number;
    skipped 9 lines
    277 277   
    278 278  // Custom object extension - Credit Card
    279 279  // number, expiration_date, cvv, holder_name
    280  -interface StixPaymentCard extends StixCyberObject {
     280 +export interface StixPaymentCard extends StixCyberObject {
    281 281   card_number: string;
    282 282   expiration_date: Date;
    283 283   cvv: number;
    skipped 14 lines
    298 298   
    299 299  // IPv4 Address Object Specific Properties
    300 300  // value, resolves_to_refs, belongs_to_refs
    301  -interface StixIPv4Address extends StixCyberObject {
     301 +export interface StixIPv4Address extends StixCyberObject {
    302 302   value: string;
    303 303   resolves_to_refs: Array<StixId>; // optional
    304 304   belongs_to_refs: Array<StixId>; // optional
    skipped 1 lines
    306 306   
    307 307  // IPv6 Address Object Specific Properties
    308 308  // value, resolves_to_refs, belongs_to_refs
    309  -interface StixIPv6Address extends StixCyberObject {
     309 +export interface StixIPv6Address extends StixCyberObject {
    310 310   value: string;
    311 311   resolves_to_refs: Array<StixId>; // optional
    312 312   belongs_to_refs: Array<StixId>; // optional
    skipped 1 lines
    314 314   
    315 315  // MAC Address Object Specific Properties
    316 316  // value
    317  -interface StixMacAddress extends StixCyberObject {
     317 +export interface StixMacAddress extends StixCyberObject {
    318 318   value: string;
    319 319  }
    320 320   
    321 321  // Mutex Object Specific Properties
    322 322  // name
    323  -interface StixMutex extends StixCyberObject {
     323 +export interface StixMutex extends StixCyberObject {
    324 324   name: string;
    325 325  }
    326 326   
    skipped 4 lines
    331 331  // http-request-ext | icmp-ext | socket-ext | tcp-ext
    332 332  type network_socket_address_family_enum = 'AF_UNSPEC' | 'AF_INET' | 'AF_IPX' | 'AF_APPLETALK' | 'AF_NETBIOS' | 'AF_INET6' | 'AF_IRDA' | 'AF_BTH';
    333 333  type network_socket_type_enum = 'SOCK_STREAM' | 'AF_ISOCK_DGRAMNET' | 'SOCK_RAW' | 'SOCK_RDM' | 'SOCK_SEQPACKET';
    334  -interface StixNetworkTraffic extends StixCyberObject {
     334 +export interface StixNetworkTraffic extends StixCyberObject {
    335 335   start: Date; // optional
    336 336   end: Date; // optional
    337 337   is_active: boolean; // optional
    skipped 54 lines
    392 392  type windows_service_start_type_enum = 'SERVICE_AUTO_START' | 'SERVICE_BOOT_START' | 'SERVICE_DEMAND_START' | 'SERVICE_DISABLED' | 'SERVICE_SYSTEM_ALERT';
    393 393  type windows_service_type_enum = 'SERVICE_KERNEL_DRIVER' | 'SERVICE_FILE_SYSTEM_DRIVER' | 'SERVICE_WIN32_OWN_PROCESS' | 'SERVICE_WIN32_SHARE_PROCESS';
    394 394  type windows_service_status_enum = 'SERVICE_CONTINUE_PENDING' | 'SERVICE_PAUSE_PENDING' | 'SERVICE_PAUSED' | 'SERVICE_RUNNING' | 'SERVICE_START_PENDING' | 'SERVICE_STOP_PENDING' | 'SERVICE_STOPPED';
    395  -interface StixProcess extends StixCyberObject {
     395 +export interface StixProcess extends StixCyberObject {
    396 396   is_hidden: boolean; // optional
    397 397   pid: number; // optional
    398 398   created_time: Date; // optional
    skipped 34 lines
    433 433   
    434 434  // Software Object Specific Properties
    435 435  // name, cpe, swid, languages, vendor, version
    436  -interface StixSoftware extends StixCyberObject {
     436 +export interface StixSoftware extends StixCyberObject {
    437 437   name: string;
    438 438   cpe: string; // optional
    439 439   swid: string; // optional
    skipped 4 lines
    444 444   
    445 445  // URL Object Specific Properties
    446 446  // value
    447  -interface StixURL extends StixCyberObject {
     447 +export interface StixURL extends StixCyberObject {
    448 448   score: number;
    449 449   value: string; // optional
    450 450  }
    skipped 3 lines
    454 454  // can_escalate_privs, is_disabled, account_created, account_expires, credential_last_changed,
    455 455  // account_first_login, account_last_login
    456 456  // unix-account-ext
    457  -interface StixUserAccount extends StixCyberObject {
     457 +export interface StixUserAccount extends StixCyberObject {
    458 458   user_id: string; // optional
    459 459   credential: string; // optional
    460 460   account_login: string; // optional
    skipped 22 lines
    483 483  }
    484 484   
    485 485  // Windows™ Registry Value Type
    486  -interface StixInternalWindowsRegistryValueType {
     486 +export interface StixInternalWindowsRegistryValueType {
    487 487   name: string;
    488 488   data: string;
    489 489   data_type: string;
    490 490  }
    491  -interface StixWindowsRegistryValueType extends StixInternalWindowsRegistryValueType, StixCyberObject {
     491 +export interface StixWindowsRegistryValueType extends StixInternalWindowsRegistryValueType, StixCyberObject {
    492 492   labels: Array<string>;
    493 493   description: string;
    494 494   score: number;
    skipped 7 lines
    502 502   
    503 503  // WindowsTM Registry Key Object Specific Properties
    504 504  // key, values, modified_time, creator_user_ref, number_of_subkeys
    505  -interface StixWindowsRegistryKey extends StixCyberObject {
     505 +export interface StixWindowsRegistryKey extends StixCyberObject {
    506 506   key: string; // optional
    507 507   values: Array<StixInternalWindowsRegistryValueType>; // optional
    508 508   modified_time: Date; // optional
    skipped 4 lines
    513 513  // is_self_signed, hashes, version, serial_number, signature_algorithm, issuer, validity_not_before,
    514 514  // validity_not_after, subject, subject_public_key_algorithm, subject_public_key_modulus,
    515 515  // subject_public_key_exponent, x509_v3_extensions
    516  -interface StixX509Certificate extends StixCyberObject {
     516 +export interface StixX509Certificate extends StixCyberObject {
    517 517   is_self_signed: boolean; // optional
    518 518   hashes: object; // optional
    519 519   version: string; // optional
    skipped 28 lines
    548 548   
    549 549  // Custom object extension - Media Content
    550 550  // value
    551  -interface StixMediaContent extends StixCyberObject {
     551 +export interface StixMediaContent extends StixCyberObject {
    552 552   title: string;
    553 553   description: string;
    554 554   content: string;
    skipped 14 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/types/stix-sdo.d.ts
    skipped 3 lines
    4 4   
    5 5  // Attack Pattern Specific Properties
    6 6  // name, description, aliases, kill_chain_phases
    7  -interface StixAttackPattern extends StixDomainObject {
     7 +export interface StixAttackPattern extends StixDomainObject {
    8 8   name: string; // optional
    9 9   description: string; // optional
    10 10   aliases: Array<string>; // optional
    skipped 6 lines
    17 17   
    18 18  // Campaign Specific Properties
    19 19  // name, description, aliases, first_seen, last_seen, objective
    20  -interface StixCampaign extends StixDomainObject {
     20 +export interface StixCampaign extends StixDomainObject {
    21 21   name: string;
    22 22   description: string; // optional
    23 23   aliases: Array<string>; // optional
    skipped 4 lines
    28 28   
    29 29  // Course of Action Specific Properties
    30 30  // name, description, action
    31  -interface StixCourseOfAction extends StixDomainObject {
     31 +export interface StixCourseOfAction extends StixDomainObject {
    32 32   name: string; // optional
    33 33   description: string; // optional
    34 34   // action - RESERVED
    skipped 6 lines
    41 41  // TODO Add support for Grouping
    42 42  // Grouping Specific Properties
    43 43  // name, description, context, object_refs
    44  -interface StixGrouping extends StixDomainObject {
     44 +export interface StixGrouping extends StixDomainObject {
    45 45   name: string; // optional
    46 46   description: string; // optional
    47 47   context: string; // grouping-context-ov
    skipped 1 lines
    49 49  }
    50 50   
    51 51  // Identity Specific Properties
    52  -interface StixIdentityExtension extends StixOpenctiExtension {
     52 +export interface StixIdentityExtension extends StixOpenctiExtension {
    53 53   firstname: string;
    54 54   lastname: string;
    55 55   organization_type: string;
    56 56   reliability: OrganizationReliability;
    57 57  }
    58 58  // name, description, roles, identity_class, sectors, contact_information
    59  -interface StixIdentity extends StixDomainObject {
     59 +export interface StixIdentity extends StixDomainObject {
    60 60   name: string; // optional
    61 61   description: string; // optional
    62 62   roles: Array<string>; // optional
    skipped 8 lines
    71 71  // Incident Specific Properties
    72 72  // name, description
    73 73  // Not in https://docs.oasis-open.org/cti/stix/v2.1
    74  -interface StixIncident extends StixDomainObject {
     74 +export interface StixIncident extends StixDomainObject {
    75 75   name: string;
    76 76   description: string; // optional
    77 77   first_seen: Date;
    skipped 6 lines
    84 84  }
    85 85   
    86 86  // Indicator Specific Properties
    87  -interface StixIndicatorExtension extends StixOpenctiExtension {
     87 +export interface StixIndicatorExtension extends StixOpenctiExtension {
    88 88   detection: boolean;
    89 89   score: number;
    90 90   main_observable_type: string;
    91 91  }
    92 92  // name, description, indicator_types, pattern, pattern_type, pattern_version, valid_from, valid_until, kill_chain_phases
    93  -interface StixIndicator extends StixDomainObject {
     93 +export interface StixIndicator extends StixDomainObject {
    94 94   name: string; // optional
    95 95   description: string; // optional
    96 96   indicator_types : Array<string>; // optional
    skipped 11 lines
    108 108   
    109 109  // infrastructure Specific Properties
    110 110  // name, description, infrastructure_types, aliases, kill_chain_phases, first_seen, last_seen
    111  -interface StixInfrastructure extends StixDomainObject {
     111 +export interface StixInfrastructure extends StixDomainObject {
    112 112   name: string;
    113 113   description: string; // optional
    114 114   infrastructure_types: Array<string>; // infrastructure-type-ov - optional
    skipped 5 lines
    120 120   
    121 121  // Intrusion Set Specific Properties
    122 122  // name, description, aliases, first_seen, last_seen, goals, resource_level, primary_motivation, secondary_motivations
    123  -interface StixIntrusionSet extends StixDomainObject {
     123 +export interface StixIntrusionSet extends StixDomainObject {
    124 124   name: string;
    125 125   description: string; // optional
    126 126   aliases: Array<string>; // optional
    skipped 7 lines
    134 134   
    135 135  // Location Specific Properties
    136 136  // name, description, latitude, longitude, precision, region, country, administrative_area, city, street_address, postal_code
    137  -interface StixLocation extends StixDomainObject {
     137 +export interface StixLocation extends StixDomainObject {
    138 138   name: string; // optional
    139 139   description: string; // optional
    140 140   latitude: number; // optional
    skipped 10 lines
    151 151  // Malware Specific Properties
    152 152  // name, description, malware_types, is_family, aliases, kill_chain_phases, first_seen, last_seen,
    153 153  // operating_system_refs, architecture_execution_envs, implementation_languages, capabilities, sample_refs
    154  -interface StixMalware extends StixDomainObject {
     154 +export interface StixMalware extends StixDomainObject {
    155 155   name: string; // optional
    156 156   description: string; // optional
    157 157   malware_types: Array<string>; // optional
    skipped 14 lines
    172 172  // product, version, host_vm_ref, operating_system_ref, installed_software_refs, configuration_version,
    173 173  // modules, analysis_engine_version, analysis_definition_version, submitted, analysis_started,
    174 174  // analysis_ended, result_name, result, analysis_sco_refs, sample_ref
    175  -interface StixMalwareAnalysis extends StixDomainObject {
     175 +export interface StixMalwareAnalysis extends StixDomainObject {
    176 176   product: string;
    177 177   version: string; // optional
    178 178   host_vm_ref: StixId; // optional
    skipped 18 lines
    197 197   
    198 198  // Note Specific Properties
    199 199  // abstract, content, authors, object_refs
    200  -interface StixNote extends StixDomainObject {
     200 +export interface StixNote extends StixDomainObject {
    201 201   abstract: string;
    202 202   content: string;
    203 203   authors: Array<string>;
    skipped 5 lines
    209 209   
    210 210  // Observed Data Specific Properties
    211 211  // first_observed, last_observed, number_observed, objects, object_refs
    212  -interface StixObservedData extends StixDomainObject {
     212 +export interface StixObservedData extends StixDomainObject {
    213 213   first_observed: Date;
    214 214   last_observed: Date;
    215 215   number_observed: number;
    skipped 5 lines
    221 221   
    222 222  // Opinion Specific Properties
    223 223  // explanation, authors, opinion, object_refs
    224  -interface StixOpinion extends StixDomainObject {
     224 +export interface StixOpinion extends StixDomainObject {
    225 225   explanation: string; // optional
    226 226   authors: Array<string>; // optional
    227 227   opinion: 'strongly-disagree' | 'disagree' | 'neutral' | 'agree' | 'strongly-agree';
    skipped 5 lines
    233 233   
    234 234  // Report Specific Properties
    235 235  // name, description, report_types, published, object_refs
    236  -interface StixReport extends StixDomainObject {
     236 +export interface StixReport extends StixDomainObject {
    237 237   name: string;
    238 238   description: string;
    239 239   report_types: Array<string>;
    skipped 16 lines
    256 256  // Threat Actor Specific Properties
    257 257  // name, description, threat_actor_types, aliases, first_seen, last_seen, roles, goals,
    258 258  // sophistication, resource_level, primary_motivation, secondary_motivations, personal_motivations
    259  -interface StixThreatActor extends StixDomainObject {
     259 +export interface StixThreatActor extends StixDomainObject {
    260 260   name: string;
    261 261   description: string; // optional
    262 262   threat_actor_types : Array<string>; // threat-actor-type-ov - optional
    skipped 11 lines
    274 274   
    275 275  // Tool Specific Properties
    276 276  // name, description, tool_types, aliases, kill_chain_phases, tool_version
    277  -interface StixTool extends StixDomainObject {
     277 +export interface StixTool extends StixDomainObject {
    278 278   name: string;
    279 279   description: string; // optional
    280 280   tool_types : Array<string>; // tool-type-ov - optional
    skipped 3 lines
    284 284  }
    285 285   
    286 286  // Vulnerability Specific Properties
    287  -interface StixVulnerabilityExtension extends StixOpenctiExtension {
     287 +export interface StixVulnerabilityExtension extends StixOpenctiExtension {
    288 288   attack_vector: string;
    289 289   availability_impact: string;
    290 290   base_score: number;
    skipped 2 lines
    293 293   integrity_impact: string;
    294 294  }
    295 295  // name, description
    296  -interface StixVulnerability extends StixDomainObject {
     296 +export interface StixVulnerability extends StixDomainObject {
    297 297   name: string;
    298 298   description: string; // optional
    299 299   extensions: {
    skipped 4 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/types/stix-smo.d.ts
    skipped 1 lines
    2 2  import { STIX_EXT_OCTI } from './stix-extensions';
    3 3   
    4 4  // Extensions
    5  -interface StixExtension {
     5 +export interface StixExtension {
    6 6   id: StixId;
    7 7   type: 'extension-definition';
    8 8   spec_version: string;
    skipped 9 lines
    18 18   
    19 19  // Marking Definition Specific Properties
    20 20  // name, definition_type, definition
    21  -interface MarkingDefinitionExtension extends StixOpenctiExtension {
     21 +export interface MarkingDefinitionExtension extends StixOpenctiExtension {
    22 22   color: string;
    23 23   order: number;
    24 24  }
    25  -interface StixMarkingDefinition extends StixMarkingsObject {
     25 +export interface StixMarkingDefinition extends StixMarkingsObject {
    26 26   name: string;
    27 27   definition_type: string;
    28 28   extensions: {
    skipped 2 lines
    31 31  }
    32 32   
    33 33  // Label
    34  -// interface StixInternalLabel = string
    35  -interface StixLabel extends StixObject {
     34 +// export interface StixInternalLabel = string
     35 +export interface StixLabel extends StixObject {
    36 36   value: string;
    37 37   color: string;
    38 38   extensions: {
    skipped 2 lines
    41 41  }
    42 42   
    43 43  // Kill chain
    44  -interface StixInternalKillChainPhase {
     44 +export interface StixInternalKillChainPhase {
    45 45   kill_chain_name: string;
    46 46   phase_name: string;
    47 47  }
    48  -interface StixKillChainPhase extends StixInternalKillChainPhase, StixObject {
     48 +export interface StixKillChainPhase extends StixInternalKillChainPhase, StixObject {
    49 49   order: number;
    50 50   extensions: {
    51 51   [STIX_EXT_OCTI] : StixOpenctiExtensionSDO
    skipped 1 lines
    53 53  }
    54 54   
    55 55  // External reference
    56  -interface StixInternalExternalReference {
     56 +export interface StixInternalExternalReference {
    57 57   source_name: string;
    58 58   description: string;
    59 59   url: string;
    60 60   hashes: object;
    61 61   external_id: string;
    62 62  }
    63  -interface StixExternalReference extends StixInternalExternalReference, StixObject {
     63 +export interface StixExternalReference extends StixInternalExternalReference, StixObject {
    64 64   extensions: {
    65 65   [STIX_EXT_OCTI] : StixOpenctiExtensionSDO
    66 66   };
    skipped 2 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/types/stix-sro.d.ts
    skipped 4 lines
    5 5   
    6 6  // Relationship Specific Properties
    7 7  // relationship_type, description, source_ref, target_ref, start_time, stop_time
    8  -interface RelationExtension extends StixOpenctiExtension {
     8 +export interface RelationExtension extends StixOpenctiExtension {
    9 9   extension_type : 'property-extension' | 'new-sro';
    10 10   source_ref: string;
    11 11   source_ref_object_marking_refs: Array<string>;
    skipped 3 lines
    15 15   target_type: string;
    16 16   kill_chain_phases: Array<StixKillChainPhase>;
    17 17  }
    18  -interface StixRelation extends StixRelationshipObject {
     18 +export interface StixRelation extends StixRelationshipObject {
    19 19   relationship_type: string;
    20 20   description: string;
    21 21   source_ref: string;
    skipped 7 lines
    29 29   
    30 30  // Sighting Specific Properties
    31 31  // description, first_seen, last_seen, count, sighting_of_ref, observed_data_refs, where_sighted_refs, summary
    32  -interface SightingExtension extends StixOpenctiExtension {
     32 +export interface SightingExtension extends StixOpenctiExtension {
    33 33   sighting_of_ref: StixId;
    34 34   sighting_of_ref_object_marking_refs: Array<string>;
    35 35   sighting_of_type: string;
    skipped 2 lines
    38 38   where_sighted_refs_object_marking_refs: Array<string>;
    39 39   negative: boolean;
    40 40  }
    41  -interface StixSighting extends StixRelationshipObject {
     41 +export interface StixSighting extends StixRelationshipObject {
    42 42   description: string;
    43 43   first_seen: string | undefined;
    44 44   last_seen: string | undefined;
    skipped 10 lines
  • ■ ■ ■ ■
    opencti-platform/opencti-graphql/src/types/store.d.ts
    1  -import { SortResults } from '@elastic/elasticsearch/api/types';
     1 +import type { SortResults } from '@elastic/elasticsearch/lib/api/types';
    2 2  import {
    3 3   INPUT_BCC,
    4 4   INPUT_BELONGS_TO,
    skipped 523 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/tests/02-integration/01-database/middleware-test.js
    skipped 4 lines
    5 5   deleteRelationsByFromAndTo,
    6 6   distributionEntities,
    7 7   distributionRelations,
    8  - internalLoadById,
    9  - storeLoadById,
    10 8   mergeEntities,
    11 9   patchAttribute,
    12 10   querySubTypes,
    skipped 41 lines
    54 52  import { executionContext, SYSTEM_USER } from '../../../src/utils/access';
    55 53  import { checkObservableSyntax } from '../../../src/utils/syntax';
    56 54  import { FunctionalError } from '../../../src/config/errors';
    57  -import { listAllRelations, listEntities, listRelations } from '../../../src/database/middleware-loader';
     55 +import {
     56 + internalLoadById,
     57 + listAllRelations,
     58 + listEntities,
     59 + listRelations, storeLoadById
     60 +} from '../../../src/database/middleware-loader';
    58 61  import { addThreatActor } from '../../../src/domain/threatActor';
    59 62  import { addMalware } from '../../../src/domain/malware';
    60 63  import { addIntrusionSet } from '../../../src/domain/intrusionSet';
    skipped 1005 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/tests/02-integration/02-resolvers/connector-test.js
    skipped 170 lines
    171 171   });
    172 172   it('should delete connector', async () => {
    173 173   // Delete the connector
    174  - await queryAsAdmin({ query: DELETE_CONNECTOR_QUERY, variables: { id: "5ed680de-75e2-4aa0-bec0-4e8e5a0d1695" } });
     174 + await queryAsAdmin({ query: DELETE_CONNECTOR_QUERY, variables: { id: '5ed680de-75e2-4aa0-bec0-4e8e5a0d1695' } });
    175 175   // Verify is no longer found
    176  - const queryResult = await queryAsAdmin({ query: READ_CONNECTOR_QUERY, variables: { id: "5ed680de-75e2-4aa0-bec0-4e8e5a0d1695" } });
     176 + const queryResult = await queryAsAdmin({ query: READ_CONNECTOR_QUERY, variables: { id: '5ed680de-75e2-4aa0-bec0-4e8e5a0d1695' } });
    177 177   expect(queryResult).not.toBeNull();
    178 178   expect(queryResult.data.connector).toBeNull();
    179 179   });
    skipped 2 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/tests/04-sync/sync-test.js
    skipped 7 lines
    8 8   API_URI,
    9 9   executeExternalQuery,
    10 10   FIFTEEN_MINUTES,
    11  - PYTHON_PATH, RAW_EVENTS_SIZE,
     11 + PYTHON_PATH,
     12 + RAW_EVENTS_SIZE,
    12 13   SYNC_DIRECT_START_REMOTE_URI,
    13 14   SYNC_LIVE_EVENTS_SIZE,
    14 15   SYNC_LIVE_START_REMOTE_URI,
    15 16   SYNC_RAW_START_REMOTE_URI,
    16 17   SYNC_RESTORE_START_REMOTE_URI,
    17  - SYNC_TEST_REMOTE_URI, testContext,
     18 + SYNC_TEST_REMOTE_URI,
     19 + testContext,
    18 20  } from '../utils/testQuery';
    19 21  import { elAggregationCount } from '../../src/database/engine';
    20 22  import { execChildPython } from '../../src/python/pythonBridge';
    skipped 5 lines
    26 28  import { convertStoreToStix } from '../../src/database/stix-converter';
    27 29  import { wait } from '../../src/database/utils';
    28 30  import { storeLoadByIdWithRefs } from '../../src/database/middleware';
     31 +import { logAudit } from '../../src/config/conf';
    29 32   
    30 33  const STAT_QUERY = `query stats {
    31 34   about {
    skipped 90 lines
    122 125   };
    123 126   const diffElements = await checkInstanceDiff(initStixReport, stixReport, idLoader);
    124 127   if (diffElements.length > 0) {
    125  - console.log(JSON.stringify(diffElements));
     128 + logAudit.info(JSON.stringify(diffElements));
    126 129   }
    127 130   expect(diffElements.length).toBe(0);
    128 131   };
    skipped 184 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/tests/05-rules/located-at-located-test.js
    1 1  import { shutdownModules, startModules } from '../../src/modules';
    2 2  import { FIVE_MINUTES, testContext, TEN_SECONDS } from '../utils/testQuery';
    3  -import { createRelation, internalDeleteElementById, internalLoadById } from '../../src/database/middleware';
     3 +import { createRelation, internalDeleteElementById } from '../../src/database/middleware';
    4 4  import { SYSTEM_USER } from '../../src/utils/access';
    5 5  import { RELATION_LOCATED_AT } from '../../src/schema/stixCoreRelationship';
    6 6  import LocatedAtLocatedRule from '../../src/rules/located-at-located/LocatedAtLocatedRule';
    skipped 3 lines
    10 10  import { activateRule, disableRule, getInferences, inferenceLookup } from '../utils/rule-utils';
    11 11  import { RELATION_OBJECT_MARKING } from '../../src/schema/stixMetaRelationship';
    12 12  import { wait } from '../../src/database/utils';
     13 +import { internalLoadById } from '../../src/database/middleware-loader';
    13 14   
    14 15  const RULE = RULE_PREFIX + LocatedAtLocatedRule.id;
    15 16  const FRANCE = 'location--b8d0549f-de06-5ebd-a6e9-d31a581dba5d';
    skipped 114 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/tests/05-rules/sighting-incident-test.js
    skipped 5 lines
    6 6  import { FIVE_MINUTES, testContext, TEN_SECONDS } from '../utils/testQuery';
    7 7  import { shutdownModules, startModules } from '../../src/modules';
    8 8  import { activateRule, disableRule, getInferences } from '../utils/rule-utils';
    9  -import { internalLoadById, patchAttribute } from '../../src/database/middleware';
     9 +import { patchAttribute } from '../../src/database/middleware';
    10 10  import { SYSTEM_USER } from '../../src/utils/access';
    11 11  import { ENTITY_TYPE_INCIDENT, ENTITY_TYPE_INDICATOR } from '../../src/schema/stixDomainObject';
    12 12  import RuleSightingIncident from '../../src/rules/sighting-incident/SightingIncidentRule';
    13 13  import { RELATION_RELATED_TO, RELATION_TARGETS } from '../../src/schema/stixCoreRelationship';
    14  -import { listRelations } from '../../src/database/middleware-loader';
     14 +import { internalLoadById, listRelations } from '../../src/database/middleware-loader';
    15 15  import { RELATION_OBJECT_MARKING } from '../../src/schema/stixMetaRelationship';
    16 16  import { wait } from '../../src/database/utils';
    17 17   
    skipped 52 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-graphql/tests/utils/rule-utils.js
    1  -import { internalLoadById, listThings } from '../../src/database/middleware';
     1 +import { listThings } from '../../src/database/middleware';
    2 2  import { SYSTEM_USER } from '../../src/utils/access';
    3 3  import { READ_INDEX_INFERRED_ENTITIES, READ_INDEX_INFERRED_RELATIONSHIPS, wait } from '../../src/database/utils';
    4 4  import { ENTITY_TYPE_TASK } from '../../src/schema/internalObject';
    5 5  import { setRuleActivation } from '../../src/domain/rules';
    6  -import { listEntities } from '../../src/database/middleware-loader';
     6 +import { internalLoadById, listEntities } from '../../src/database/middleware-loader';
    7 7  import { testContext } from './testQuery';
    8 8   
    9 9  export const inferenceLookup = async (inferences, fromStandardId, toStandardId, type) => {
    skipped 39 lines
  • ■ ■ ■ ■
    opencti-platform/opencti-graphql/tests/utils/testStream.js
    skipped 1 lines
    2 2  import * as R from 'ramda';
    3 3  import { validate as isUuid } from 'uuid';
    4 4  import { ADMIN_USER, generateBasicAuth, testContext } from './testQuery';
    5  -import { internalLoadById } from '../../src/database/middleware';
    6 5  import { isStixId } from '../../src/schema/schemaUtils';
    7 6  import { isStixRelationship } from '../../src/schema/stixRelationship';
    8 7  import { STIX_EXT_OCTI } from '../../src/types/stix-extensions';
    9 8  import { EVENT_TYPE_UPDATE } from '../../src/database/utils';
     9 +import { internalLoadById } from '../../src/database/middleware-loader';
    10 10   
    11 11  export const fetchStreamEvents = (uri, { from } = {}) => {
    12 12   const opts = {
    skipped 112 lines
Please wait...
Page is in error, reload to recover