Skip to content

Commit

Permalink
[frontend/backend] filters list modification #1 (#4939)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit committed Jan 26, 2024
1 parent b932a80 commit 4433a8c
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,15 @@ class ListLines extends Component {
inline,
} = this.props;
const entityType = exportContext?.entity_type ?? this.props.entityType;
const exportEntityType = exportContext?.entity_type;
const exportDisabled = numberOfElements
&& ((selectedIds.length > export_max_size
&& numberOfElements.number > export_max_size)
|| (selectedIds.length === 0
&& numberOfElements.number > export_max_size));
const searchContextFinal = {
...(searchContext ?? {}),
entityTypes: entityType ? [entityType] : [],
entityTypes: exportEntityType ? [exportEntityType] : [],
};
return (
<div className={noPadding ? classes.containerNoPadding : classes.container}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const ExternalReferences: FunctionComponent<ExternalReferencesProps> = () => {
iconExtension={true}
paginationOptions={queryPaginationOptions}
numberOfElements={numberOfElements}
entityType={'External-Reference'}
>
{queryRef && (
<React.Suspense
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Reports: FunctionComponent = () => {
const isRuntimeSort = isRuntimeFieldEnable() ?? false;
const dataColumns = {
name: {
label: 'Title',
label: 'Name',
width: '25%',
isSortable: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const TaskFragment = graphql`

export const tasksDataColumns: DataColumns = {
name: {
label: 'Title',
label: 'Name',
width: '35%',
isSortable: true,
render: (task: TasksLine_node$data) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ class StixDomainObjectAttackPatternsKillChainComponent extends Component {
>
<Tooltip
title={
currentModeOnlyActive
? t('Display the whole matrix')
: t('Display only used techniques')
}
currentModeOnlyActive
? t('Display the whole matrix')
: t('Display only used techniques')
}
>
<span>
<IconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ const Notifiers = () => {
isSortable: true,
},
name: {
label: 'name',
label: 'Name',
width: '20%',
isSortable: true,
},
description: {
label: 'description',
label: 'Description',
width: '60%',
isSortable: false,
},
Expand Down
68 changes: 40 additions & 28 deletions opencti-platform/opencti-graphql/src/domain/filterKeysSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import type {
} from '../schema/attribute-definition';
import { schemaRelationsRefDefinition } from '../schema/schema-relationsRef';
import { isStixCoreObject } from '../schema/stixCoreObject';
import { SOURCE_RELIABILITY_FILTER, WORKFLOW_FILTER } from '../utils/filtering/filtering-constants';
import { SOURCE_RELIABILITY_FILTER, TYPE_FILTER, WORKFLOW_FILTER } from '../utils/filtering/filtering-constants';
import { isAbstract } from '../schema/general';

type FilterDefinition = {
filterKey: string
Expand Down Expand Up @@ -160,33 +161,46 @@ const completeFilterDefinitionMapForType = (
};

const completeFilterDefinitionMapWithStixCoreObjectsSpecialKeys = (
type: string,
filterDefinitionsMap: Map<string, FilterDefinition>, // filter definition map to complete
subEntityTypes: string[],
) => {
filterDefinitionsMap.set('regardingOf', {
filterKey: 'regardingOf',
type: 'nested',
label: 'In regards of',
multiple: true,
subEntityTypes,
elementsForFilterValuesSearch: [],
});
filterDefinitionsMap.set(SOURCE_RELIABILITY_FILTER, {
filterKey: SOURCE_RELIABILITY_FILTER,
type: 'vocabulary',
label: 'Reliability of author',
multiple: false,
subEntityTypes,
elementsForFilterValuesSearch: ['reliability_ov'],
});
filterDefinitionsMap.set(WORKFLOW_FILTER, {
filterKey: WORKFLOW_FILTER,
type: 'special',
label: 'Workflow status',
multiple: false,
subEntityTypes,
elementsForFilterValuesSearch: [],
});
if (isStixCoreObject(type)) {
filterDefinitionsMap.set('regardingOf', {
filterKey: 'regardingOf',
type: 'nested',
label: 'In regards of',
multiple: true,
subEntityTypes,
elementsForFilterValuesSearch: [],
});
filterDefinitionsMap.set(SOURCE_RELIABILITY_FILTER, {
filterKey: SOURCE_RELIABILITY_FILTER,
type: 'vocabulary',
label: 'Reliability of author',
multiple: false,
subEntityTypes,
elementsForFilterValuesSearch: ['reliability_ov'],
});
filterDefinitionsMap.set(WORKFLOW_FILTER, {
filterKey: WORKFLOW_FILTER,
type: 'special',
label: 'Workflow status',
multiple: false,
subEntityTypes,
elementsForFilterValuesSearch: [],
});
if (isAbstract(type)) {
filterDefinitionsMap.set(TYPE_FILTER, {
filterKey: TYPE_FILTER,
type: 'string',
label: 'Entity type',
multiple: false,
subEntityTypes,
elementsForFilterValuesSearch: [],
});
}
}
};

export const generateFilterKeysSchema = () => {
Expand All @@ -197,9 +211,7 @@ export const generateFilterKeysSchema = () => {
// 01. add attributes and relations refs of type
completeFilterDefinitionMapForType(filterDefinitionsMap, type);
// 02. for stix-core-objects, also add some special keys
if (isStixCoreObject(type)) {
completeFilterDefinitionMapWithStixCoreObjectsSpecialKeys(filterDefinitionsMap, subTypes.concat([type]));
}
completeFilterDefinitionMapWithStixCoreObjectsSpecialKeys(type, filterDefinitionsMap, subTypes.concat([type]));
// 03. handle the attributes and relations refs of the subtypes
if (subTypes.length > 0) {
subTypes.forEach((subType) => completeFilterDefinitionMapForType(filterDefinitionsMap, subType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ const basicRelationshipAttributes: Array<AttributeDefinition> = [
standardId,
parentTypes,
baseType,
relationshipType,
{ ...relationshipType, isFilterable: false },
entityType,
createdAt,
updatedAt,
creators,
{ name: 'i_inference_weight', label: 'Inference weight', type: 'numeric', precision: 'integer', editDefault: false, mandatoryType: 'no', multiple: false, upsert: false, isFilterable: true },
{ name: 'i_inference_weight', label: 'Inference weight', type: 'numeric', precision: 'integer', editDefault: false, mandatoryType: 'no', multiple: false, upsert: false, isFilterable: false },
{
name: 'connections',
label: 'Relations connections',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const stixCoreRelationshipsAttributes: Array<AttributeDefinition> = [
{ name: 'start_time', label: 'First observation', type: 'date', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'stop_time', label: 'Last observation', type: 'date', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'description', label: 'Description', type: 'string', format: 'text', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'x_opencti_workflow_id', label: 'Workflow status', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: false },
{ name: 'x_opencti_workflow_id', label: 'Status', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: false },
];
schemaAttributesDefinition.registerAttributes(ABSTRACT_STIX_CORE_RELATIONSHIP, stixCoreRelationshipsAttributes);
STIX_CORE_RELATIONSHIPS.map((type) => schemaAttributesDefinition.registerAttributes(type, stixCoreRelationshipsAttributes));
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const hashDefinition: AttributeDefinition = {
{ name: 'SHA-1', label: 'SHA-1', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'SHA-256', label: 'SHA-256', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'SHA-512', label: 'SHA-512', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'SHA3-256', label: 'SHA3-256', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'SHA3-512', label: 'SHA3-512', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'SHA3-256', label: 'SHA3-256', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: false },
{ name: 'SHA3-512', label: 'SHA3-512', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: false },
{ name: 'SSDEEP', label: 'SSDEEP', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'SDHASH', label: 'SDHASH', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'TLSH', label: 'TLSH', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
Expand Down Expand Up @@ -181,7 +181,7 @@ const stixCyberObservablesAttributes: { [k: string]: Array<AttributeDefinition>
{ name: 'extensions', label: 'Extensions', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'is_hidden', label: 'Hidden', type: 'boolean', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'pid', label: 'PID', type: 'numeric', precision: 'long', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'created_time', label: 'Creation date', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'created_time', label: 'Process creation date', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'cwd', label: 'CWD', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'command_line', label: 'Command line', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'environment_variables', label: 'Environment variables', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: true, upsert: true, isFilterable: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const stixDomainObjectAttributes: Array<AttributeDefinition> = [
confidence,
revoked,
{ ...files, update: true },
{ name: 'x_opencti_graph_data', label: 'Graph data', type: 'string', format: 'text', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: true },
{ name: 'x_opencti_workflow_id', label: 'Workflow status', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: false }
{ name: 'x_opencti_graph_data', label: 'Graph data', type: 'string', format: 'text', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: false },
{ name: 'x_opencti_workflow_id', label: 'Status', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: false }
];
schemaAttributesDefinition.registerAttributes(ABSTRACT_STIX_DOMAIN_OBJECT, stixDomainObjectAttributes);

Expand Down Expand Up @@ -95,21 +95,21 @@ const stixDomainObjectsAttributes: { [k: string]: Array<AttributeDefinition> } =
{ name: 'authors', label: 'Authors', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: true, upsert: false, isFilterable: true },
{ name: 'note_types', label: 'Note types', type: 'string', format: 'vocabulary', vocabularyCategory: 'note_types_ov', mandatoryType: 'customizable', editDefault: true, multiple: true, upsert: true, isFilterable: true },
{ name: 'likelihood', label: 'Likelihood', type: 'numeric', precision: 'integer', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'content_mapping', label: 'Content mapping', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'content_mapping', label: 'Content mapping', type: 'string', format: 'text', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: false },
],
[ENTITY_TYPE_CONTAINER_OBSERVED_DATA]: [
{ name: 'first_observed', label: 'First observed', type: 'date', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'last_observed', label: 'Last observed', type: 'date', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'number_observed', label: 'Number observed', type: 'numeric', precision: 'integer', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'content', label: 'Content', type: 'string', format: 'short', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'content_mapping', label: 'Content mapping', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'content_mapping', label: 'Content mapping', type: 'string', format: 'text', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: false },
],
[ENTITY_TYPE_CONTAINER_OPINION]: [
{ name: 'explanation', label: 'Explanation', type: 'string', format: 'short', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'authors', label: 'Authors', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: true, upsert: false, isFilterable: true },
{ name: 'opinion', label: 'Opinion', type: 'string', format: 'vocabulary', vocabularyCategory: 'opinion_ov', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'content', label: 'Content', type: 'string', format: 'short', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'content_mapping', label: 'Content mapping', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'content_mapping', label: 'Content mapping', type: 'string', format: 'text', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: false },
],
[ENTITY_TYPE_CONTAINER_REPORT]: [
{ name: 'name', label: 'Name', type: 'string', format: 'short', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, isFilterable: true },
Expand All @@ -118,7 +118,7 @@ const stixDomainObjectsAttributes: { [k: string]: Array<AttributeDefinition> } =
xOpenctiReliability,
{ name: 'published', label: 'Publication date', type: 'date', mandatoryType: 'external', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'content', label: 'Content', type: 'string', format: 'short', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'content_mapping', label: 'Content mapping', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'content_mapping', label: 'Content mapping', type: 'string', format: 'text', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: false },
],
[ENTITY_TYPE_COURSE_OF_ACTION]: [
xOpenctiAliases,
Expand Down Expand Up @@ -244,7 +244,7 @@ const stixDomainObjectsAttributes: { [k: string]: Array<AttributeDefinition> } =
{ name: 'source', label: 'Source', type: 'string', format: 'short', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'first_seen', label: 'First seen', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'last_seen', label: 'Last seen', type: 'date', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'objective', label: 'Obective', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'objective', label: 'Objective', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
],
};
R.forEachObjIndexed((value, key) => schemaAttributesDefinition.registerAttributes(key as string, value), stixDomainObjectsAttributes);
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const stixSightingRelationshipsAttributes: { [k: string]: Array<Attribute
{ name: 'last_seen', label: 'Last seen', type: 'date', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'description', label: 'Description', type: 'string', format: 'text', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'x_opencti_negative', label: 'False positive', type: 'boolean', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: false, isFilterable: true },
{ name: 'x_opencti_workflow_id', label: 'Workflow status', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: false },
{ name: 'x_opencti_workflow_id', label: 'Status', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: false, isFilterable: false },
],
};
R.forEachObjIndexed((value, key) => schemaAttributesDefinition.registerAttributes(key as string, value), stixSightingRelationshipsAttributes);
2 changes: 1 addition & 1 deletion opencti-platform/opencti-graphql/src/modules/case/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const CASE_DEFINITION: ModuleDefinition<StoreEntityCase, StixCase> = {
{ name: 'name', label: 'Name', type: 'string', format: 'short', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'description', label: 'Description', type: 'string', format: 'text', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'content', label: 'Content', type: 'string', format: 'short', mandatoryType: 'customizable', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'content_mapping', label: 'Content mapping', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'content_mapping', label: 'Content mapping', type: 'string', format: 'text', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: false },
{ name: 'caseTemplate', label: 'Case template', type: 'string', format: 'short', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
],
relations: [],
Expand Down
Loading

0 comments on commit 4433a8c

Please sign in to comment.