Skip to content

Commit

Permalink
[backend] add label and isFilterable in schema/attributes (#4939)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit committed Dec 21, 2023
1 parent af8e9c5 commit 2dd260d
Show file tree
Hide file tree
Showing 10 changed files with 496 additions and 662 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const basicRelationshipAttributes: Array<AttributeDefinition> = [
entityType,
createdAt,
updatedAt,
{ name: 'i_inference_weight', type: 'numeric', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false },
{ name: 'i_inference_weight', label: 'Inference weight', type: 'numeric', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: true },
creators,
];
schemaAttributesDefinition.registerAttributes(ABSTRACT_BASIC_RELATIONSHIP, basicRelationshipAttributes);

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { RELATION_ALLOWED_BY, RELATION_PARTICIPATE_TO } from '../../schema/inter

export const internalRelationshipsAttributes: { [k: string]: Array<AttributeDefinition> } = {
[RELATION_PARTICIPATE_TO]: [
{ name: 'start_time', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false },
{ name: 'stop_time', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false },
{ name: 'confidence', type: 'numeric', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false },
{ name: 'start_time', label: 'First observation', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: true },
{ name: 'stop_time', label: 'Last observation', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: true },
{ name: 'confidence', label: 'Confidence', type: 'numeric', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: true },
],
[RELATION_ALLOWED_BY]: [
{ name: 'grant', type: 'string', mandatoryType: 'no', editDefault: false, multiple: true, upsert: false }
{ name: 'grant', label: 'Grant', type: 'string', mandatoryType: 'no', editDefault: false, multiple: true, upsert: false, isFilterable: true }
],
};
R.forEachObjIndexed((value, key) => schemaAttributesDefinition.registerAttributes(key as string, value), internalRelationshipsAttributes);
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { schemaAttributesDefinition } from '../../schema/schema-attributes';
import { STIX_CORE_RELATIONSHIPS } from '../../schema/stixCoreRelationship';

export const stixCoreRelationshipsAttributes: Array<AttributeDefinition> = [
{ name: 'start_time', type: 'date', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: false, label: 'first obs.' },
{ name: 'stop_time', type: 'date', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: false, label: 'last obs.' },
{ name: 'description', type: 'string', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true },
{ name: 'x_opencti_workflow_id', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false },
{ name: 'start_time', label: 'First observation', type: 'date', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'stop_time', label: 'Last observation', type: 'date', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'description', label: 'Description', type: 'string', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'x_opencti_workflow_id', label: 'Workflow status', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: true },
];
schemaAttributesDefinition.registerAttributes(ABSTRACT_STIX_CORE_RELATIONSHIP, stixCoreRelationshipsAttributes);
STIX_CORE_RELATIONSHIPS.map((type) => schemaAttributesDefinition.registerAttributes(type, stixCoreRelationshipsAttributes));

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ import { ENTITY_TYPE_EXTERNAL_REFERENCE, ENTITY_TYPE_KILL_CHAIN_PHASE, ENTITY_TY

const stixMetaObjectsAttributes: { [k: string]: Array<AttributeDefinition> } = {
[ENTITY_TYPE_MARKING_DEFINITION]: [
{ name: 'definition_type', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, label: 'Type' },
{ name: 'definition', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, label: 'Definition' },
{ name: 'x_opencti_order', type: 'numeric', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, label: 'Order' },
{ name: 'x_opencti_color', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, label: 'Color' },
{ name: 'definition_type', label: 'Type', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'definition', label: 'Definition', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'x_opencti_order', label: 'Order', type: 'numeric', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'x_opencti_color', label: 'Color', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: false },
],
[ENTITY_TYPE_LABEL]: [
{ name: 'value', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true },
{ name: 'color', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true },
{ name: 'value', label: 'Value', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'color', label: 'Color', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, isFilterable: false },
],
[ENTITY_TYPE_EXTERNAL_REFERENCE]: [
{ name: 'source_name', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, label: 'Source name' },
{ name: 'description', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true },
{ name: 'url', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false },
{ name: 'hash', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false },
{ name: 'external_id', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false },
{ name: 'source_name', label: 'Source name', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'description', label: 'Description', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'url', label: 'URL', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: true },
{ name: 'hash', label: 'Hash', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: true },
{ name: 'external_id', label: 'External id', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: false },
],
[ENTITY_TYPE_KILL_CHAIN_PHASE]: [
{ name: 'kill_chain_name', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, label: 'Kill chain name' },
{ name: 'phase_name', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, label: 'Phase name' },
{ name: 'x_opencti_order', type: 'numeric', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, label: 'Order' },
{ name: 'kill_chain_name', label: 'Kill chain name', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'phase_name', label: 'Phase name', type: 'string', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'x_opencti_order', label: 'Order', type: 'numeric', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, isFilterable: true },
],
};
R.forEachObjIndexed((value, key) => schemaAttributesDefinition.registerAttributes(key as string, value), stixMetaObjectsAttributes);
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { ABSTRACT_STIX_REF_RELATIONSHIP } from '../../schema/general';
// -- ATTRIBUTES -

const stixRefRelationshipsAttributes: AttributeDefinition[] = [
{ name: 'start_time', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false },
{ name: 'stop_time', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false },
{ name: 'start_time', label: 'Start date', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: true },
{ name: 'stop_time', label: 'End date', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: true },
];

schemaAttributesDefinition.registerAttributes(ABSTRACT_STIX_REF_RELATIONSHIP, stixRefRelationshipsAttributes);
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { STIX_SIGHTING_RELATIONSHIP } from '../../schema/stixSightingRelationshi

export const stixSightingRelationshipsAttributes: { [k: string]: Array<AttributeDefinition> } = {
[STIX_SIGHTING_RELATIONSHIP]: [
{ name: 'attribute_count', type: 'numeric', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, label: 'count' },
{ name: 'first_seen', type: 'date', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: false, label: 'first seen' },
{ name: 'last_seen', type: 'date', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: false, label: 'last seen' },
{ name: 'description', type: 'string', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true },
{ name: 'x_opencti_negative', type: 'boolean', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: false, label: 'False positive' },
{ name: 'x_opencti_workflow_id', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false },
{ name: 'attribute_count', label: 'Count', type: 'numeric', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'first_seen', label: 'First seen', type: 'date', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'last_seen', label: 'Last seen', type: 'date', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'description', label: 'Description', type: 'string', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'x_opencti_negative', label: 'Negative', type: 'boolean', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'x_opencti_workflow_id', label: 'Workflow status', type: 'string', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: true },
],
};
R.forEachObjIndexed((value, key) => schemaAttributesDefinition.registerAttributes(key as string, value), stixSightingRelationshipsAttributes);
62 changes: 48 additions & 14 deletions opencti-platform/opencti-graphql/src/schema/attribute-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ export interface AttributeDefinition {
scalable?: boolean
schemaDef?: Record<string, any>
attributes?: Array<AttributeDefinition>
isFilterable?: boolean
}

// -- GLOBAL --

export const internalId: AttributeDefinition = {
name: 'internal_id',
label: 'Internal id',
type: 'string',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: false
upsert: false,
isFilterable: false,
};

export const creators: AttributeDefinition = {
Expand All @@ -34,7 +37,8 @@ export const creators: AttributeDefinition = {
mandatoryType: 'no',
editDefault: false,
multiple: true,
upsert: false
upsert: false,
isFilterable: true,
};

export const standardId: AttributeDefinition = {
Expand All @@ -45,6 +49,7 @@ export const standardId: AttributeDefinition = {
editDefault: false,
multiple: false,
upsert: false,
isFilterable: false,
};

export const iAliasedIds: AttributeDefinition = {
Expand All @@ -55,27 +60,32 @@ export const iAliasedIds: AttributeDefinition = {
editDefault: false,
multiple: true,
upsert: false,
isFilterable: true,
};

export const files: AttributeDefinition = {
name: 'x_opencti_files',
label: 'Files',
type: 'object',
mandatoryType: 'no',
editDefault: false,
multiple: true,
upsert: false,
update: false,
isFilterable: false,
};

// -- ENTITY TYPE --

export const entityType: AttributeDefinition = {
name: 'entity_type',
label: 'Entity type',
type: 'string',
mandatoryType: 'internal',
editDefault: false,
multiple: false,
upsert: false
upsert: false,
isFilterable: true,
};

export const entityLocationType: AttributeDefinition = {
Expand All @@ -85,25 +95,30 @@ export const entityLocationType: AttributeDefinition = {
mandatoryType: 'internal',
editDefault: false,
multiple: false,
upsert: false
upsert: false,
isFilterable: true,
};

export const relationshipType: AttributeDefinition = {
name: 'relationship_type',
label: 'Relationship type',
type: 'string',
mandatoryType: 'internal',
editDefault: false,
multiple: false,
upsert: false
upsert: false,
isFilterable: true,
};

export const xOpenctiType: AttributeDefinition = {
name: 'x_opencti_type',
label: 'Type',
type: 'string',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: false
upsert: false,
isFilterable: true,
};

// -- STIX DOMAIN OBJECT --
Expand All @@ -118,6 +133,7 @@ export const xOpenctiStixIds: AttributeDefinition = {
editDefault: false,
multiple: true,
upsert: false,
isFilterable: false,
};

// ALIASES
Expand All @@ -130,6 +146,7 @@ export const xOpenctiAliases: AttributeDefinition = {
editDefault: false,
multiple: true,
upsert: true,
isFilterable: true,
};

export const aliases: AttributeDefinition = {
Expand All @@ -140,34 +157,41 @@ export const aliases: AttributeDefinition = {
editDefault: false,
multiple: true,
upsert: true,
isFilterable: true,
};

// OTHERS

export const specVersion: AttributeDefinition = {
name: 'spec_version',
label: 'Version', // TODO check
type: 'string',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: false
upsert: false,
isFilterable: true,
};

export const created: AttributeDefinition = {
name: 'created',
label: 'Created',
type: 'date',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: false
upsert: false,
isFilterable: true,
};
export const modified: AttributeDefinition = {
name: 'modified',
label: 'Modified',
type: 'date',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: false
upsert: false,
isFilterable: true,
};

export const createdAt: AttributeDefinition = {
Expand All @@ -177,7 +201,8 @@ export const createdAt: AttributeDefinition = {
mandatoryType: 'internal',
editDefault: false,
multiple: false,
upsert: false
upsert: false,
isFilterable: true,
};
export const updatedAt: AttributeDefinition = {
name: 'updated_at',
Expand All @@ -186,52 +211,61 @@ export const updatedAt: AttributeDefinition = {
mandatoryType: 'internal',
editDefault: false,
multiple: false,
upsert: false
upsert: false,
isFilterable: true,
};

export const revoked: AttributeDefinition = {
name: 'revoked',
label: 'Revoked',
type: 'boolean',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: true,
isFilterable: true,
};

export const confidence: AttributeDefinition = {
name: 'confidence',
label: 'Confidence',
type: 'numeric',
mandatoryType: 'no',
editDefault: true,
multiple: false,
scalable: true,
upsert: true,
isFilterable: true,
};

export const xOpenctiReliability: AttributeDefinition = {
name: 'x_opencti_reliability',
label: 'Reliability',
type: 'string',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: false,
label: 'Reliability'
isFilterable: true,
};

export const lang: AttributeDefinition = {
name: 'lang',
name: 'lang', // TODO add label
type: 'string',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: false,
isFilterable: true,
};

export const identityClass: AttributeDefinition = {
name: 'identity_class',
label: 'Identity class',
type: 'string',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: false
upsert: false,
isFilterable: true,
};

0 comments on commit 2dd260d

Please sign in to comment.