Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend] optionnal STIX_EXT_OCTI_SCO #9088

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1257,13 +1257,13 @@
if (indicator.object_marking_refs) {
stixObservable.object_marking_refs = indicator.object_marking_refs;
}
if (indicator.created_by_ref) {
if (indicator.created_by_ref && stixObservable.extensions[STIX_EXT_OCTI_SCO]) {

Check warning on line 1260 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#L1260

Added line #L1260 was not covered by tests
stixObservable.extensions[STIX_EXT_OCTI_SCO].created_by_ref = indicator.created_by_ref;
}
if (indicator.labels) {
if (indicator.labels && stixObservable.extensions[STIX_EXT_OCTI_SCO]) {

Check warning on line 1263 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#L1263

Added line #L1263 was not covered by tests
stixObservable.extensions[STIX_EXT_OCTI_SCO].labels = indicator.labels;
}
if (indicator.external_references) {
if (indicator.external_references && stixObservable.extensions[STIX_EXT_OCTI_SCO]) {

Check warning on line 1266 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#L1266

Added line #L1266 was not covered by tests
stixObservable.extensions[STIX_EXT_OCTI_SCO].external_references = indicator.external_references;
}
if (granted_refs) {
Expand Down
14 changes: 7 additions & 7 deletions opencti-platform/opencti-graphql/src/types/stix-common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ interface StixRelationshipObject extends StixObject {

// SCO
interface CyberObjectExtension {
extension_type : 'property-extension',
labels: Array<string>;
description: string;
score: number;
created_by_ref: StixId | undefined;
external_references: Array<StixInternalExternalReference>;
extension_type? : 'property-extension';
labels?: Array<string>;
description?: string;
score?: number;
created_by_ref?: StixId;
external_references?: Array<StixInternalExternalReference>;
}

interface StixCyberObject extends StixObject {
Expand All @@ -119,7 +119,7 @@ interface StixCyberObject extends StixObject {
x_opencti_score?: number; // optional
extensions: {
[STIX_EXT_OCTI]: StixOpenctiExtension;
[STIX_EXT_OCTI_SCO]: CyberObjectExtension
[STIX_EXT_OCTI_SCO]?: CyberObjectExtension
};
}

Expand Down
6 changes: 3 additions & 3 deletions opencti-platform/opencti-graphql/src/types/stix-sco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export interface StixNetworkTraffic extends StixCyberObject {
encapsulated_by_ref: StixId | undefined; // optional
extensions: {
[STIX_EXT_OCTI]: StixOpenctiExtension
[STIX_EXT_OCTI_SCO]: CyberObjectExtension
[STIX_EXT_OCTI_SCO]?: CyberObjectExtension
// HTTP Request Extension
'http-request-ext'?: {
request_method: string;
Expand Down Expand Up @@ -445,7 +445,7 @@ export interface StixProcess extends StixCyberObject {
child_refs: Array<StixId>; // optional
extensions: {
[STIX_EXT_OCTI]: StixOpenctiExtension
[STIX_EXT_OCTI_SCO]: CyberObjectExtension
[STIX_EXT_OCTI_SCO]?: CyberObjectExtension
// Windows™ Process Extension
'windows-process-ext': {
aslr_enabled: boolean; // optional
Expand Down Expand Up @@ -510,7 +510,7 @@ export interface StixUserAccount extends StixCyberObject {
account_last_login: StixDate; // optional
extensions: {
[STIX_EXT_OCTI]: StixOpenctiExtension
[STIX_EXT_OCTI_SCO]: CyberObjectExtension
[STIX_EXT_OCTI_SCO]?: CyberObjectExtension
// UNIX™ Account Extension
'unix-account-ext'?: {
gid: number; // optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ describe('CSV-PARSER with dynamic mapping (aka different entity on one file)', (

expect(firstIdentity.name).toBe('AlienVault');
expect(firstIp.value).toBe('91.200.148.232');
expect(firstIp.extensions[STIX_EXT_OCTI_SCO].score).toBe(41);
expect(firstIp.extensions[STIX_EXT_OCTI_SCO]?.score).toBe(41);
expect(firstUrl.value).toBe('http://requestrepo.com/r/2yxp98b3');
expect(firstUrl.extensions[STIX_EXT_OCTI_SCO].score).toBe(22);
expect(firstUrl.extensions[STIX_EXT_OCTI_SCO]?.score).toBe(22);
expect(firstIdentity.name).toBe('AlienVault');
expect(firstIdentity.identity_class).toBe('individual');
});
Expand Down