Skip to content

Commit

Permalink
[backend] Fix Promote observable component crashes (#6399)
Browse files Browse the repository at this point in the history
  • Loading branch information
SouadHadjiat committed Mar 21, 2024
1 parent 1e90cee commit 2d3ade3
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ const PLAYBOOK_CREATE_INDICATOR_COMPONENT: PlaybookComponent<CreateIndicatorConf
type = 'StixFile';
}
const pattern = await createStixPattern(context, AUTOMATION_MANAGER_USER, key, value);
const { score } = observable.extensions[STIX_EXT_OCTI_SCO];
const score = observable.extensions[STIX_EXT_OCTI_SCO]?.score;

Check warning on line 856 in opencti-platform/opencti-graphql/src/modules/playbook/playbook-components.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/modules/playbook/playbook-components.ts#L856

Added line #L856 was not covered by tests
const { granted_refs } = observable.extensions[STIX_EXT_OCTI];
if (pattern) {
const indicatorData = {
Expand Down Expand Up @@ -881,13 +881,13 @@ const PLAYBOOK_CREATE_INDICATOR_COMPONENT: PlaybookComponent<CreateIndicatorConf
if (observable.object_marking_refs) {
indicator.object_marking_refs = observable.object_marking_refs;
}
if (observable.extensions[STIX_EXT_OCTI_SCO].labels) {
if (observable.extensions[STIX_EXT_OCTI_SCO]?.labels) {

Check warning on line 884 in opencti-platform/opencti-graphql/src/modules/playbook/playbook-components.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/modules/playbook/playbook-components.ts#L884

Added line #L884 was not covered by tests
indicator.labels = observable.extensions[STIX_EXT_OCTI_SCO].labels;
}
if (observable.extensions[STIX_EXT_OCTI_SCO].created_by_ref) {
if (observable.extensions[STIX_EXT_OCTI_SCO]?.created_by_ref) {

Check warning on line 887 in opencti-platform/opencti-graphql/src/modules/playbook/playbook-components.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/modules/playbook/playbook-components.ts#L887

Added line #L887 was not covered by tests
indicator.created_by_ref = observable.extensions[STIX_EXT_OCTI_SCO].created_by_ref;
}
if (observable.extensions[STIX_EXT_OCTI_SCO].external_references) {
if (observable.extensions[STIX_EXT_OCTI_SCO]?.external_references) {

Check warning on line 890 in opencti-platform/opencti-graphql/src/modules/playbook/playbook-components.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/modules/playbook/playbook-components.ts#L890

Added line #L890 was not covered by tests
indicator.external_references = observable.extensions[STIX_EXT_OCTI_SCO].external_references;
}
if (granted_refs) {
Expand Down

0 comments on commit 2d3ade3

Please sign in to comment.