Skip to content

Commit

Permalink
[backend] no longer send x_opencti_files with resolved markings to el…
Browse files Browse the repository at this point in the history
…astic (#9149)
  • Loading branch information
JeremyCloarec authored Nov 28, 2024
1 parent 3b1ad45 commit eb3462f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export const loadElementsWithDependencies = async (context, user, elements, opts
}
});
}
const deps = depsElementsMap.get(element.id);
const deps = depsElementsMap.get(element.id) ?? {};
if (isNotEmptyField(files)) {
deps.x_opencti_files = files;
}
Expand Down
14 changes: 12 additions & 2 deletions opencti-platform/opencti-graphql/src/domain/stixCoreObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,17 @@ export const stixCoreObjectImportPush = async (context, user, id, file, args = {
// Patch the updated_at to force live stream evolution
const eventFile = storeFileConverter(user, up);
const files = [...(previous.x_opencti_files ?? []).filter((f) => f.id !== up.id), eventFile];
const nonResolvedFiles = files.map((f) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { [INPUT_MARKINGS]: markingInput, ...nonResolvedFile } = f;
return nonResolvedFile;
});
await elUpdateElement(context, user, {
_index: previous._index,
internal_id: internalId,
entity_type: previous.entity_type, // required for schema validation
updated_at: now(),
x_opencti_files: files
x_opencti_files: nonResolvedFiles
});
// Stream event generation
const fileMarkings = R.uniq(R.flatten(files.map((f) => f.file_markings)));
Expand Down Expand Up @@ -753,11 +758,16 @@ export const stixCoreObjectImportDelete = async (context, user, fileId) => {
await deleteFile(context, user, fileId);
// Patch the updated_at to force live stream evolution
const files = (previous.x_opencti_files ?? []).filter((f) => f.id !== fileId);
const nonResolvedFiles = files.map((f) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { [INPUT_MARKINGS]: markingInput, ...nonResolvedFile } = f;
return nonResolvedFile;
});
await elUpdateElement(context, user, {
_index: previous._index,
internal_id: entityId,
updated_at: now(),
x_opencti_files: files,
x_opencti_files: nonResolvedFiles,
entity_type: previous.entity_type, // required for schema validation
});
// Stream event generation
Expand Down

0 comments on commit eb3462f

Please sign in to comment.