Skip to content

Commit

Permalink
[backend] fix file markings that could be undefined when building OCT…
Browse files Browse the repository at this point in the history
…I extensions (#9301)
  • Loading branch information
JeremyCloarec authored Dec 11, 2024
1 parent ac065c3 commit 0fbbd4f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export const loadElementsWithDependencies = async (context, user, elements, opts
if (isNotEmptyField(element.x_opencti_files) && isNotEmptyField(fileMarkingsMap)) {
element.x_opencti_files.forEach((f) => {
if (isNotEmptyField(f.file_markings)) {
files.push({ ...f, [INPUT_MARKINGS]: f.file_markings.map((m) => fileMarkingsMap[m]) });
files.push({ ...f, [INPUT_MARKINGS]: f.file_markings.map((m) => fileMarkingsMap[m]).filter((fm) => fm) });
} else {
files.push(f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const buildOCTIExtensions = (instance: StoreObject): S.StixOpenctiExtensi
uri: `/storage/get/${file.id}`,
version: file.version,
mime_type: file.mime_type,
object_marking_refs: (file[INPUT_MARKINGS] ?? []).map((f) => f.standard_id),
object_marking_refs: (file[INPUT_MARKINGS] ?? []).filter((f) => f).map((f) => f.standard_id),
})),
stix_ids: (instance.x_opencti_stix_ids ?? []).filter((stixId: string) => isTrustedStixId(stixId)),
is_inferred: instance._index ? isInferredIndex(instance._index) : undefined, // TODO Use case for empty _index?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ export const stixCoreObjectImportPush = async (context, user, id, file, args = {
const resolvedFiles = [];
files.forEach((f) => {
if (isNotEmptyField(f.file_markings)) {
resolvedFiles.push({ ...f, [INPUT_MARKINGS]: f.file_markings.map((m) => fileMarkingsMap[m]) });
resolvedFiles.push({ ...f, [INPUT_MARKINGS]: f.file_markings.map((m) => fileMarkingsMap[m]).filter((fm) => fm) });
} else {
resolvedFiles.push(f);
}
Expand Down

0 comments on commit 0fbbd4f

Please sign in to comment.