diff --git a/opencti-platform/opencti-front/src/components/ItemColor.ts b/opencti-platform/opencti-front/src/components/ItemColor.ts new file mode 100644 index 0000000000000..61893087a5855 --- /dev/null +++ b/opencti-platform/opencti-front/src/components/ItemColor.ts @@ -0,0 +1,544 @@ +import { useTheme } from '@mui/material'; +import useAuth from '../utils/hooks/useAuth'; +import { stringToColour } from '../utils/Colors'; + +/** + * itemColor function that uses hooks to determine monochrome label and theme mode + * Can only be used in functional components + * @param type type of the entity + * @param reversed is the relation reversed + * @returns color hexcode + */ +const itemColor = (type: string, reversed = false) => { + const { me: { monochrome_labels } } = useAuth(); + const theme = useTheme(); + const dark = theme.palette.mode === 'dark'; + + if (monochrome_labels) { + switch (type) { + // Analyses + case 'Report': + case 'Grouping': + case 'Malware-Analysis': + case 'Note': + case 'External-Reference': + case 'Opinion': + return dark ? '#679f38' : '#006064'; + // Cases + case 'Case-Incident': + case 'Case-Rfi': + case 'Case-Rft': + case 'Task': + case 'Case-Feedback': + return dark ? '#ea80fc' : '#d81b60'; + // Events + case 'Incident': + case 'Sighting': + case 'Observed-Data': + return dark ? '#ec407a' : '#880d4f'; + // Observations + case 'Stix-Cyber-Observable': + case 'Autonomous-System': + case 'Directory': + case 'Domain-Name': + case 'Email-Addr': + case 'Email-Message': + case 'Email-Mime-Part-Type': + case 'StixFile': + case 'X509-Certificate': + case 'IPv4-Addr': + case 'IPv6-Addr': + case 'Mac-Addr': + case 'Mutex': + case 'Network-Traffic': + case 'Process': + case 'Software': + case 'Url': + case 'User-Account': + case 'Windows-Registry-Key': + case 'Windows-Registry-Value-Type': + case 'Cryptographic-Key': + case 'Cryptocurrency-Wallet': + case 'Text': + case 'User-Agent': + case 'Bank-Account': + case 'Credential': + case 'Tracking-Number': + case 'Phone-Number': + case 'Payment-Card': + case 'Media-Content': + case 'Persona': + case 'Artifact': + case 'Indicator': + case 'Infrastructure': + return '#fe5622'; + // Threats + case 'Threat-Actor-Group': + case 'Threat-Actor-Individual': + case 'Intrusion-Set': + case 'Campaign': + return dark ? '#ff9800' : '#d68100'; + // Arsenal + case 'Malware': + case 'Channel': + case 'Tool': + case 'Vulnerability': + return dark ? '#ffc108' : '#b59005'; + // Techniques + case 'Attack-Pattern': + case 'Narrative': + case 'Course-Of-Action': + case 'Data-Component': + case 'Data-Source': + return dark ? '#d4e157' : '#817717'; + // Entities + case 'Sector': + case 'Event': + case 'Organization': + case 'System': + case 'Individual': + case 'User': + return dark ? '#9447ff' : '#512da8'; + // Locations + case 'Region': + case 'Country': + case 'Administrative-Area': + case 'City': + case 'Position': + return dark ? '#00acc1' : '#0675be'; + // Misc + case 'Language': + return dark ? '#afb42b' : '#d4e157'; + case 'Dashboard': + case 'Investigation': + return dark ? '#689f38' : '#33691e'; + case 'Session': + return dark ? '#5d4037' : '#795548'; + // Relationships + case 'Stix-Core-Relationship': + case 'Relationship': + case 'stix-core-relationship': + case 'targets': + case 'uses': + case 'located-at': + case 'related-to': + case 'mitigates': + case 'impersonates': + case 'indicates': + case 'comes-after': + case 'attributed-to': + case 'variant-of': + case 'part-of': + case 'employed-by': + case 'resides-in': + case 'citizen-of': + case 'national-of': + case 'drops': + case 'delivers': + case 'compromises': + case 'belongs-to': + case 'based-on': + case 'communicates-with': + case 'amplifies': + case 'analyses-of': + case 'authored-by': + case 'beacons-to': + case 'characterizes': + case 'consists-of': + case 'controls': + case 'cooperates-with': + case 'derived-from': + case 'downloads': + case 'has': + case 'bcc': + case 'cc': + case 'obs_belongs-to': + case 'owns': + case 'dst': + case 'from': + case 'hosts': + case 'image': + case 'publishes': + case 'duplicate-of': + case 'obs_content': + case 'service-dll': + case 'dynamic-analyses-of': + case 'contains': + case 'exfiltrates-to': + case 'exploits': + case 'investigates': + case 'originates-from': + case 'participates-in': + case 'body-multipart': + case 'body-raw': + case 'child': + case 'creator-user': + case 'detects': + case 'dst-payload': + case 'encapsulated-by': + case 'encapsulates': + case 'opened-connection': + case 'operating-system': + case 'parent': + case 'parent-directory': + case 'raw-email': + case 'src-payload': + case 'remediates': + case 'resolves-to': + case 'obs_resolves-to': + case 'revoked-by': + case 'sample': + case 'sender': + case 'src': + case 'to': + case 'values': + case 'static-analyses-of': + case 'subnarrative-of': + case 'subtechnique-of': + case 'numberOfConnectedElement': + case 'known-as': + return dark ? '#616161' : '#9e9e9e'; + default: + return stringToColour(type, reversed); + } + } + + switch (type) { + case 'Attack-Pattern': + if (dark) { + return '#d4e157'; + } + return '#827717'; + case 'Case-Incident': + if (dark) { + return '#ad1457'; + } + return '#ec407a'; + case 'Case-Rfi': + if (dark) { + return '#0c5c98'; + } + return '#3880b7'; + case 'Case-Rft': + if (dark) { + return '#ea80fc'; + } + return '#8e24aa'; + case 'Case-Feedback': + if (dark) { + return '#00acc1'; + } + return '#006064'; + case 'Task': + if (dark) { + return '#304ffe'; + } + return '#283593'; + case 'Campaign': + if (dark) { + return '#8e24aa'; + } + return '#ea80fc'; + case 'Note': + if (dark) { + return '#33691e'; + } + return '#689f38'; + case 'Observed-Data': + if (dark) { + return '#00acc1'; + } + return '#006064'; + case 'Opinion': + if (dark) { + return '#1565c0'; + } + return '#1976d2'; + case 'Report': + if (dark) { + return '#4a148c'; + } + return '#9c27b0'; + case 'Grouping': + if (dark) { + return '#689f38'; + } + return '#8bc34a'; + case 'Course-Of-Action': + if (dark) { + return '#8bc34a'; + } + return '#689f38'; + case 'Individual': + case 'User': + if (dark) { + return '#9c27b0'; + } + return '#4a148c'; + case 'Group': + if (dark) { + return '#006064'; + } + return '#00bcd4'; + case 'Capability': + if (dark) { + return '#424242'; + } + return '#757575'; + case 'Organization': + if (dark) { + return '#3880b7'; + } + return '#0c5c98'; + case 'Sector': + if (dark) { + return '#0d47a1'; + } + return '#2196f3'; + case 'System': + if (dark) { + return '#8bc34a'; + } + return '#689f38'; + case 'Event': + if (dark) { + return '#00acc1'; + } + return '#006064'; + case 'Indicator': + if (dark) { + return '#ffc107'; + } + return '#b69007'; + case 'Infrastructure': + if (dark) { + return '#512da8'; + } + return '#651fff'; + case 'Intrusion-Set': + if (dark) { + return '#bf360c'; + } + return '#ff5622'; + case 'City': + if (dark) { + return '#00acc1'; + } + return '#006064'; + case 'Country': + if (dark) { + return '#304ffe'; + } + return '#283593'; + case 'Region': + if (dark) { + return '#33691e'; + } + return '#689f38'; + case 'Administrative-Area': + if (dark) { + return '#ffc107'; + } + return '#b69007'; + case 'Position': + if (dark) { + return '#00acc1'; + } + return '#827717'; + case 'Malware': + if (dark) { + return '#ff9800'; + } + return '#d68100'; + case 'Malware-Analysis': + if (dark) { + return '#006064'; + } + return '#00acc1'; + case 'Threat-Actor-Group': + if (dark) { + return '#880e4f'; + } + return '#e91e63'; + case 'Threat-Actor-Individual': + if (dark) { + return '#4a148c'; + } + return '#9c27b0'; + case 'Tool': + if (dark) { + return '#986937'; + } + return '#986937'; + case 'Channel': + if (dark) { + return '#ad1457'; + } + return '#ec407a'; + case 'Narrative': + if (dark) { + return '#8bc34a'; + } + return '#689f38'; + case 'Language': + if (dark) { + return '#afb42b'; + } + return '#d4e157'; + case 'Vulnerability': + if (dark) { + return '#5d4037'; + } + return '#795548'; + case 'Incident': + if (dark) { + return '#f44336'; + } + return '#f44336'; + case 'Dashboard': + if (dark) { + return '#689f38'; + } + return '#33691e'; + case 'Investigation': + if (dark) { + return '#689f38'; + } + return '#33691e'; + case 'Session': + if (dark) { + return '#5d4037'; + } + return '#795548'; + case 'Artifact': + if (dark) { + return '#f2699c'; + } + return '#ff4081'; + case 'Stix-Cyber-Observable': + case 'Autonomous-System': + case 'Directory': + case 'Domain-Name': + case 'Email-Addr': + case 'Email-Message': + case 'Email-Mime-Part-Type': + case 'StixFile': + case 'X509-Certificate': + case 'IPv4-Addr': + case 'IPv6-Addr': + case 'Mac-Addr': + case 'Mutex': + case 'Network-Traffic': + case 'Process': + case 'Software': + case 'Url': + case 'User-Account': + case 'Windows-Registry-Key': + case 'Windows-Registry-Value-Type': + case 'Cryptographic-Key': + case 'Cryptocurrency-Wallet': + case 'Text': + case 'User-Agent': + case 'Bank-Account': + case 'Credential': + case 'Tracking-Number': + case 'Phone-Number': + case 'Payment-Card': + case 'Media-Content': + case 'Persona': + if (dark) { + return '#84ffff'; + } + return stringToColour(type); + case 'Stix-Core-Relationship': + case 'Relationship': + case 'stix-core-relationship': + case 'targets': + case 'uses': + case 'located-at': + case 'related-to': + case 'mitigates': + case 'impersonates': + case 'indicates': + case 'comes-after': + case 'attributed-to': + case 'variant-of': + case 'part-of': + case 'employed-by': + case 'resides-in': + case 'citizen-of': + case 'national-of': + case 'drops': + case 'delivers': + case 'compromises': + case 'belongs-to': + case 'based-on': + case 'communicates-with': + case 'amplifies': + case 'analyses-of': + case 'authored-by': + case 'beacons-to': + case 'characterizes': + case 'consists-of': + case 'controls': + case 'cooperates-with': + case 'derived-from': + case 'downloads': + case 'has': + case 'bcc': + case 'cc': + case 'obs_belongs-to': + case 'owns': + case 'dst': + case 'from': + case 'hosts': + case 'image': + case 'publishes': + case 'duplicate-of': + case 'obs_content': + case 'service-dll': + case 'dynamic-analyses-of': + case 'contains': + case 'exfiltrates-to': + case 'exploits': + case 'investigates': + case 'originates-from': + case 'participates-in': + case 'body-multipart': + case 'body-raw': + case 'child': + case 'creator-user': + case 'detects': + case 'dst-payload': + case 'encapsulated-by': + case 'encapsulates': + case 'opened-connection': + case 'operating-system': + case 'parent': + case 'parent-directory': + case 'raw-email': + case 'src-payload': + case 'remediates': + case 'resolves-to': + case 'obs_resolves-to': + case 'revoked-by': + case 'sample': + case 'sender': + case 'src': + case 'to': + case 'values': + case 'static-analyses-of': + case 'subnarrative-of': + case 'subtechnique-of': + case 'numberOfConnectedElement': + case 'known-as': + if (dark) { + return '#616161'; + } + return '#9e9e9e'; + default: + return stringToColour(type, reversed); + } +}; + +export default itemColor; diff --git a/opencti-platform/opencti-front/src/components/ItemEntityType.tsx b/opencti-platform/opencti-front/src/components/ItemEntityType.tsx index 918551180f0cb..c3a26de8d93b1 100644 --- a/opencti-platform/opencti-front/src/components/ItemEntityType.tsx +++ b/opencti-platform/opencti-front/src/components/ItemEntityType.tsx @@ -2,12 +2,12 @@ import Chip from '@mui/material/Chip'; import React, { FunctionComponent } from 'react'; import makeStyles from '@mui/styles/makeStyles'; import { useTheme } from '@mui/material'; -import { itemColor } from '../utils/Colors'; import { useFormatter } from './i18n'; import ThemeLight from './ThemeLight'; import ThemeDark from './ThemeDark'; import ItemIcon from './ItemIcon'; import { truncate } from '../utils/String'; +import itemColor from './ItemColor'; // Deprecated - https://mui.com/system/styles/basics/ // Do not use it for new code. diff --git a/opencti-platform/opencti-front/src/components/ItemIcon.jsx b/opencti-platform/opencti-front/src/components/ItemIcon.jsx index e840047a0388d..fdca1dd3df642 100644 --- a/opencti-platform/opencti-front/src/components/ItemIcon.jsx +++ b/opencti-platform/opencti-front/src/components/ItemIcon.jsx @@ -99,7 +99,7 @@ import { Target, } from 'mdi-material-ui'; import TableViewIcon from '@mui/icons-material/TableView'; -import { itemColor } from '../utils/Colors'; +import itemColor from './ItemColor'; const iconSelector = (type, variant, fontSize, color, isReversed) => { let style; diff --git a/opencti-platform/opencti-front/src/components/dashboard/WidgetTimeline.tsx b/opencti-platform/opencti-front/src/components/dashboard/WidgetTimeline.tsx index 65e86d4487a70..b37b27ecc6a24 100644 --- a/opencti-platform/opencti-front/src/components/dashboard/WidgetTimeline.tsx +++ b/opencti-platform/opencti-front/src/components/dashboard/WidgetTimeline.tsx @@ -12,8 +12,8 @@ import React from 'react'; import { getSecondaryRepresentative, getMainRepresentative } from '../../utils/defaultRepresentatives'; import MarkdownDisplay from '../MarkdownDisplay'; import ItemIcon from '../ItemIcon'; -import { itemColor } from '../../utils/Colors'; import { useFormatter } from '../i18n'; +import itemColor from '../ItemColor'; interface WidgetTimelineProps { // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/opencti-platform/opencti-front/src/private/components/SearchBulk.jsx b/opencti-platform/opencti-front/src/private/components/SearchBulk.jsx index 5596f1a890114..665f4e59ac03c 100644 --- a/opencti-platform/opencti-front/src/private/components/SearchBulk.jsx +++ b/opencti-platform/opencti-front/src/private/components/SearchBulk.jsx @@ -27,10 +27,11 @@ import { resolveLink } from '../../utils/Entity'; import StixCoreObjectLabels from './common/stix_core_objects/StixCoreObjectLabels'; import StixCoreObjectsExports from './common/stix_core_objects/StixCoreObjectsExports'; import useGranted, { KNOWLEDGE_KNGETEXPORT } from '../../utils/hooks/useGranted'; -import { hexToRGB, itemColor } from '../../utils/Colors'; +import { hexToRGB } from '../../utils/Colors'; import ItemMarkings from '../../components/ItemMarkings'; import { export_max_size } from '../../utils/utils'; import Breadcrumbs from '../../components/Breadcrumbs'; +import itemColor from '../../components/ItemColor'; const SEARCH$ = new Subject().pipe(debounce(() => timer(500))); @@ -532,6 +533,7 @@ const SearchBulk = () => { const inPlatform = entity.in_platform; const link = inPlatform && `${resolveLink(entity.type)}/${entity.id}`; const linkAnalyses = `${link}/analyses`; + const chipColor = itemColor(entity.type); return ( { classes={{ root: classes.chipInList }} style={{ backgroundColor: hexToRGB( - itemColor(entity.type), + chipColor, 0.08, ), - color: itemColor(entity.type), - border: `1px solid ${itemColor(entity.type)}`, + color: chipColor, + border: `1px solid ${chipColor}`, }} label={t_i18n(`entity_${entity.type}`)} /> diff --git a/opencti-platform/opencti-front/src/private/components/analyses/reports/ReportKnowledgeTimeLine.jsx b/opencti-platform/opencti-front/src/private/components/analyses/reports/ReportKnowledgeTimeLine.jsx index 4ee5bc40509be..1aaffa2e3e8df 100644 --- a/opencti-platform/opencti-front/src/private/components/analyses/reports/ReportKnowledgeTimeLine.jsx +++ b/opencti-platform/opencti-front/src/private/components/analyses/reports/ReportKnowledgeTimeLine.jsx @@ -15,8 +15,8 @@ import { getSecondaryRepresentative, getMainRepresentative } from '../../../../u import ItemIcon from '../../../../components/ItemIcon'; import { resolveLink } from '../../../../utils/Entity'; import { useFormatter } from '../../../../components/i18n'; -import { itemColor } from '../../../../utils/Colors'; import MarkdownDisplay from '../../../../components/MarkdownDisplay'; +import itemColor from '../../../../components/ItemColor'; export const reportKnowledgeTimeLineQuery = graphql` query ReportKnowledgeTimeLineQuery( diff --git a/opencti-platform/opencti-front/src/private/components/cases/case_incidents/IncidentKnowledgeTimeLine.jsx b/opencti-platform/opencti-front/src/private/components/cases/case_incidents/IncidentKnowledgeTimeLine.jsx index 4a1a4be3f6d75..08d26013c44a0 100644 --- a/opencti-platform/opencti-front/src/private/components/cases/case_incidents/IncidentKnowledgeTimeLine.jsx +++ b/opencti-platform/opencti-front/src/private/components/cases/case_incidents/IncidentKnowledgeTimeLine.jsx @@ -15,8 +15,8 @@ import { getSecondaryRepresentative, getMainRepresentative } from '../../../../u import ItemIcon from '../../../../components/ItemIcon'; import { resolveLink } from '../../../../utils/Entity'; import { useFormatter } from '../../../../components/i18n'; -import { itemColor } from '../../../../utils/Colors'; import MarkdownDisplay from '../../../../components/MarkdownDisplay'; +import itemColor from '../../../../components/ItemColor'; export const incidentKnowledgeTimeLineQuery = graphql` query IncidentKnowledgeTimeLineCaseQuery( diff --git a/opencti-platform/opencti-front/src/private/components/cases/case_rfis/CaseRfiKnowledgeTimeLine.jsx b/opencti-platform/opencti-front/src/private/components/cases/case_rfis/CaseRfiKnowledgeTimeLine.jsx index d4fb43045e36f..1f10164e1cf69 100644 --- a/opencti-platform/opencti-front/src/private/components/cases/case_rfis/CaseRfiKnowledgeTimeLine.jsx +++ b/opencti-platform/opencti-front/src/private/components/cases/case_rfis/CaseRfiKnowledgeTimeLine.jsx @@ -15,8 +15,8 @@ import { getSecondaryRepresentative, getMainRepresentative } from '../../../../u import ItemIcon from '../../../../components/ItemIcon'; import { resolveLink } from '../../../../utils/Entity'; import { useFormatter } from '../../../../components/i18n'; -import { itemColor } from '../../../../utils/Colors'; import MarkdownDisplay from '../../../../components/MarkdownDisplay'; +import itemColor from '../../../../components/ItemColor'; export const caseRfiKnowledgeTimeLineQuery = graphql` query CaseRfiKnowledgeTimeLineCaseQuery( diff --git a/opencti-platform/opencti-front/src/private/components/cases/case_rfts/CaseRftKnowledgeTimeLine.jsx b/opencti-platform/opencti-front/src/private/components/cases/case_rfts/CaseRftKnowledgeTimeLine.jsx index 1a10d6290ff6b..da1425e58ccf6 100644 --- a/opencti-platform/opencti-front/src/private/components/cases/case_rfts/CaseRftKnowledgeTimeLine.jsx +++ b/opencti-platform/opencti-front/src/private/components/cases/case_rfts/CaseRftKnowledgeTimeLine.jsx @@ -15,8 +15,8 @@ import { getSecondaryRepresentative, getMainRepresentative } from '../../../../u import ItemIcon from '../../../../components/ItemIcon'; import { resolveLink } from '../../../../utils/Entity'; import { useFormatter } from '../../../../components/i18n'; -import { itemColor } from '../../../../utils/Colors'; import MarkdownDisplay from '../../../../components/MarkdownDisplay'; +import itemColor from '../../../../components/ItemColor'; export const caseRftKnowledgeTimeLineQuery = graphql` query CaseRftKnowledgeTimeLineCaseQuery( diff --git a/opencti-platform/opencti-front/src/private/components/common/bulk/EntityRelationshipCard.tsx b/opencti-platform/opencti-front/src/private/components/common/bulk/EntityRelationshipCard.tsx index f27535b776a7a..8429f1a7e6ffa 100644 --- a/opencti-platform/opencti-front/src/private/components/common/bulk/EntityRelationshipCard.tsx +++ b/opencti-platform/opencti-front/src/private/components/common/bulk/EntityRelationshipCard.tsx @@ -1,9 +1,9 @@ import React, { FunctionComponent } from 'react'; import { useTheme } from '@mui/styles'; -import { itemColor } from 'src/utils/Colors'; import ItemIcon from '../../../../components/ItemIcon'; import type { Theme } from '../../../../components/Theme'; import { useFormatter } from '../../../../components/i18n'; +import itemColor from '../../../../components/ItemColor'; interface EntityRelationshipCardProps { entityName: string; diff --git a/opencti-platform/opencti-front/src/private/components/common/containers/ContainerStixCoreObjectsSuggestedMappingLine.tsx b/opencti-platform/opencti-front/src/private/components/common/containers/ContainerStixCoreObjectsSuggestedMappingLine.tsx index e2f9257049a48..c3609c9217bed 100644 --- a/opencti-platform/opencti-front/src/private/components/common/containers/ContainerStixCoreObjectsSuggestedMappingLine.tsx +++ b/opencti-platform/opencti-front/src/private/components/common/containers/ContainerStixCoreObjectsSuggestedMappingLine.tsx @@ -19,8 +19,9 @@ import { useFormatter } from '../../../../components/i18n'; import ItemIcon from '../../../../components/ItemIcon'; import { resolveLink } from '../../../../utils/Entity'; import ItemMarkings from '../../../../components/ItemMarkings'; -import { hexToRGB, itemColor } from '../../../../utils/Colors'; +import { hexToRGB } from '../../../../utils/Colors'; import { DataColumns } from '../../../../components/list_lines'; +import itemColor from '../../../../components/ItemColor'; // Deprecated - https://mui.com/system/styles/basics/ // Do not use it for new code. @@ -98,6 +99,7 @@ ContainerStixCoreObjectsSuggestedMappingLineComponentProps const { t_i18n } = useFormatter(); const mappedEntityData = useFragment(ContainerStixCoreObjectsSuggestedMappingFragment, node); const { matchedString, matchedEntity } = mappedEntityData; + const chipColor = itemColor(matchedEntity.entity_type); return ( diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectsMultiHorizontalBars.jsx b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectsMultiHorizontalBars.jsx index 8ea550d14c9d7..7e62720a3fb19 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectsMultiHorizontalBars.jsx +++ b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectsMultiHorizontalBars.jsx @@ -12,8 +12,8 @@ import { useFormatter } from '../../../../components/i18n'; import { horizontalBarsChartOptions } from '../../../../utils/Charts'; import { simpleNumberFormat } from '../../../../utils/Number'; import { getMainRepresentative, isFieldForIdentifier } from '../../../../utils/defaultRepresentatives'; -import { itemColor } from '../../../../utils/Colors'; import { buildFiltersAndOptionsForWidgets } from '../../../../utils/filters/filtersUtils'; +import itemColor from '../../../../components/ItemColor'; // Deprecated - https://mui.com/system/styles/basics/ // Do not use it for new code. diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_core_relationships/EntityStixCoreRelationshipsHorizontalBars.jsx b/opencti-platform/opencti-front/src/private/components/common/stix_core_relationships/EntityStixCoreRelationshipsHorizontalBars.jsx index 1e5db61ddb8a9..cd1dde9b5a565 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_core_relationships/EntityStixCoreRelationshipsHorizontalBars.jsx +++ b/opencti-platform/opencti-front/src/private/components/common/stix_core_relationships/EntityStixCoreRelationshipsHorizontalBars.jsx @@ -9,10 +9,10 @@ import { useTheme } from '@mui/styles'; import Chart from '../charts/Chart'; import { QueryRenderer } from '../../../../relay/environment'; import { useFormatter } from '../../../../components/i18n'; -import { itemColor } from '../../../../utils/Colors'; import { horizontalBarsChartOptions } from '../../../../utils/Charts'; import { simpleNumberFormat } from '../../../../utils/Number'; import { getMainRepresentative } from '../../../../utils/defaultRepresentatives'; +import itemColor from '../../../../components/ItemColor'; // Deprecated - https://mui.com/system/styles/basics/ // Do not use it for new code. diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_core_relationships/StixCoreRelationshipCreation.jsx b/opencti-platform/opencti-front/src/private/components/common/stix_core_relationships/StixCoreRelationshipCreation.jsx index 8d6613abfbd70..f9738783c0ff7 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_core_relationships/StixCoreRelationshipCreation.jsx +++ b/opencti-platform/opencti-front/src/private/components/common/stix_core_relationships/StixCoreRelationshipCreation.jsx @@ -387,6 +387,7 @@ class StixCoreRelationshipCreation extends Component { renderSelectRelation() { const { fsd, t, classes, fromObjects, toObjects, theme } = this.props; + const dark = theme.palette.mode === 'dark'; const { existingRelations } = this.state; return (
@@ -402,114 +403,145 @@ class StixCoreRelationshipCreation extends Component { {t('Select a relationship')}
- {existingRelations.map((relation) => ( -
-
+ + {({ monochrome_labels }) => { + existingRelations.map((relation) => (
-
- -
-
- {fromObjects[0].relationship_type - ? t('Relationship') - : t(`entity_${fromObjects[0].entity_type}`)} -
-
-
- - {fromObjects.length > 1 ? ( - {t('Multiple entities selected')} - ) : ( - truncate(fromObjects[0].name, 20) - )} - -
-
-
- -
-
- {t(`relationship_${relation.node.relationship_type}`)} -
- {t('First obs.')} {fsd(relation.node.start_time)} -
- {t('Last obs.')} {fsd(relation.node.stop_time)} +
+
+ +
+
+ {fromObjects[0].relationship_type + ? t('Relationship') + : t(`entity_${fromObjects[0].entity_type}`)} +
+
+
+ + {fromObjects.length > 1 ? ( + {t('Multiple entities selected')} + ) : ( + truncate(fromObjects[0].name, 20) + )} + +
-
-
-
-
-
- +
+ +
+ +
+ {t(`relationship_${relation.node.relationship_type}`)} +
+ {t('First obs.')} {fsd(relation.node.start_time)} +
+ {t('Last obs.')} {fsd(relation.node.stop_time)} +
+
-
- {toObjects[0].relationship_type - ? t('Relationship') - : t(`entity_${toObjects[0].entity_type}`)} +
+
+
+ +
+
+ {toObjects[0].relationship_type + ? t('Relationship') + : t(`entity_${toObjects[0].entity_type}`)} +
+
+
+ + {truncate(toObjects[0].name, 20)} + +
+
-
- - {truncate(toObjects[0].name, 20)} - -
-
-
-
- ))} + )); + } + } +
({ container: { @@ -188,10 +189,7 @@ class StixCoreRelationshipContainer extends Component { submitDelete() { this.setState({ deleting: true }); - const { - location, - stixCoreRelationship, - } = this.props; + const { location, stixCoreRelationship } = this.props; commitMutation({ mutation: stixCoreRelationshipEditionDeleteMutation, variables: { @@ -207,7 +205,16 @@ class StixCoreRelationshipContainer extends Component { } render() { - const { t, fldt, nsdt, classes, stixCoreRelationship, paddingRight } = this.props; + const { + t, + fldt, + nsdt, + classes, + stixCoreRelationship, + paddingRight, + theme, + } = this.props; + const dark = theme.palette.mode === 'dark'; const { expanded } = this.state; const { from } = stixCoreRelationship; const { to } = stixCoreRelationship; @@ -248,184 +255,220 @@ class StixCoreRelationshipContainer extends Component { style={{ position: 'relative' }} className={'paper-for-grid'} > - -
-
-
- -
-
- {/* eslint-disable-next-line no-nested-ternary */} - {!fromRestricted - ? from.relationship_type - ? t('Relationship') - : t(`entity_${from.entity_type}`) - : t('Restricted')} -
-
-
- - {!fromRestricted - ? truncate( - getMainRepresentative(from) !== 'Unknown' - ? getMainRepresentative(from) - : t(`relationship_${from.entity_type}`), - 50, - ) - : t('Restricted')} - -
-
- -
- -
- -
- -
-
-
- + {({ monochrome_labels }) => ( + <> + +
+
+
+ +
+
+ {/* eslint-disable-next-line no-nested-ternary */} + {!fromRestricted + ? from.relationship_type + ? t('Relationship') + : t(`entity_${from.entity_type}`) + : t('Restricted')} +
+
+
+ + {!fromRestricted + ? truncate( + getMainRepresentative(from) !== 'Unknown' + ? getMainRepresentative(from) + : t(`relationship_${from.entity_type}`), + 50, + ) + : t('Restricted')} + +
+
+ +
+ +
+
-
- { - // eslint-disable-next-line no-nested-ternary - !toRestricted - ? to.relationship_type - ? t('Relationship') - : t(`entity_${to.entity_type}`) - : t('Restricted') - } + +
+
+
+ +
+
+ { + // eslint-disable-next-line no-nested-ternary + !toRestricted + ? to.relationship_type + ? t('Relationship') + : t(`entity_${to.entity_type}`) + : t('Restricted') + } +
+
+
+ + {!toRestricted + ? truncate( + getMainRepresentative(to) !== 'Unknown' + ? getMainRepresentative(to) + : t(`relationship_${to.entity_type}`), + 50, + ) + : t('Restricted')} + +
+
+ + +
+ + + + {t('Marking')} + + + + {t('Start time')} + + {nsdt(stixCoreRelationship.start_time)} + + {t('Stop time')} + + {nsdt(stixCoreRelationship.stop_time)} + + + + + {t('Description')} + + + + +
-
-
- - {!toRestricted - ? truncate( - getMainRepresentative(to) !== 'Unknown' - ? getMainRepresentative(to) - : t(`relationship_${to.entity_type}`), - 50, - ) - : t('Restricted')} - -
-
- - -
- - - - {t('Marking')} - - - - {t('Start time')} - - {nsdt(stixCoreRelationship.start_time)} - - {t('Stop time')} - - {nsdt(stixCoreRelationship.stop_time)} - - - - - {t('Description')} - - - - - -
+ + )} + {t('Details')} - + @@ -529,7 +572,9 @@ class StixCoreRelationshipContainer extends Component { @@ -632,6 +677,7 @@ StixCoreRelationshipContainer.propTypes = { stixCoreRelationship: PropTypes.object, paddingRight: PropTypes.bool, classes: PropTypes.object, + theme: PropTypes.object, t: PropTypes.func, nsdt: PropTypes.func, match: PropTypes.object, diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectTimeline.jsx b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectTimeline.jsx index 9f27cc241bbfa..0bf11fdfb1133 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectTimeline.jsx +++ b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectTimeline.jsx @@ -22,6 +22,7 @@ import { stixDomainObjectThreatKnowledgeStixRelationshipsQuery } from './StixDom import { truncate } from '../../../../utils/String'; import { getSecondaryRepresentative, getMainRepresentative } from '../../../../utils/defaultRepresentatives'; import { itemColor } from '../../../../utils/Colors'; +import { UserContext } from '../../../../utils/hooks/useAuth'; const Transition = React.forwardRef((props, ref) => ( @@ -52,6 +53,7 @@ class StixDomainObjectTimelineComponent extends Component { timeField, t, } = this.props; + const dark = theme.palette.mode === 'dark'; const stixRelationships = pipe( map((n) => n.node), map((n) => (n.from && n.from.id === stixDomainObjectId @@ -89,66 +91,76 @@ class StixDomainObjectTimelineComponent extends Component { || stixRelationship.created_at, )} - - {link ? ( - - - - + {({ monochrome_labels }) => ( + + {link ? ( + + - - - - ) : ( - - - + + + + + + ) : ( + - - + > + + + + + )} + + )} - - + diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_nested_ref_relationships/StixNestedRefRelationshipCreation.jsx b/opencti-platform/opencti-front/src/private/components/common/stix_nested_ref_relationships/StixNestedRefRelationshipCreation.jsx index 9234e371aa94f..650130f251d12 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_nested_ref_relationships/StixNestedRefRelationshipCreation.jsx +++ b/opencti-platform/opencti-front/src/private/components/common/stix_nested_ref_relationships/StixNestedRefRelationshipCreation.jsx @@ -25,6 +25,7 @@ import ObjectMarkingField from '../form/ObjectMarkingField'; import ConfidenceField from '../form/ConfidenceField'; import DateTimePickerField from '../../../../components/DateTimePickerField'; import { fieldSpacingContainerStyle } from '../../../../utils/field'; +import { UserContext } from '../../../../utils/hooks/useAuth'; const styles = (theme) => ({ drawerPaper: { @@ -380,7 +381,9 @@ class StixNestedRefRelationshipCreation extends Component { startTime, stopTime, defaultMarkingDefinitions, + theme, } = this.props; + const dark = theme.palette.mode === 'dark'; const relationshipTypes = resolveEntityRef.from; // eslint-disable-next-line no-nested-ternary const defaultRelationshipType = R.head(relationshipTypes); @@ -424,106 +427,134 @@ class StixNestedRefRelationshipCreation extends Component { {t('Create a relationship')}
-
-
-
-
- -
-
- {fromObjects[0].relationship_type - ? t('Relationship') - : t(`entity_${fromObjects[0].entity_type}`)} + + {({ monochrome_labels }) => ( +
+
+
+
+ +
+
+ {fromObjects[0].relationship_type + ? t('Relationship') + : t(`entity_${fromObjects[0].entity_type}`)} +
+
+
+ + {/* eslint-disable-next-line no-nested-ternary */} + {fromObjects[0].relationship_type ? ( + t(`relationship_${fromObjects[0].relationship_type}`) + ) : fromObjects.length > 1 ? ( + {t('Multiple entities selected')} + ) : ( + truncate(fromObjects[0].name, 20) + )} + +
-
-
- - {/* eslint-disable-next-line no-nested-ternary */} - {fromObjects[0].relationship_type ? ( - t(`relationship_${fromObjects[0].relationship_type}`) - ) : fromObjects.length > 1 ? ( - {t('Multiple entities selected')} - ) : ( - truncate(fromObjects[0].name, 20) - )} - -
-
-
- -
- {canReverseRelation && } -
-
-
-
- + +
+ {canReverseRelation && }
-
- {toObjects[0].relationship_type - ? t('Relationship') - : t(`entity_${toObjects[0].entity_type}`)} +
+
+
+ +
+
+ {toObjects[0].relationship_type + ? t('Relationship') + : t(`entity_${toObjects[0].entity_type}`)} +
+
+
+ + {/* eslint-disable-next-line no-nested-ternary */} + {toObjects[0].relationship_type ? ( + t(`relationship_${toObjects[0].relationship_type}`) + ) : toObjects.length > 1 ? ( + {t('Multiple entities selected')} + ) : ( + truncate(toObjects[0].name, 20) + )} + +
-
- - {/* eslint-disable-next-line no-nested-ternary */} - {toObjects[0].relationship_type ? ( - t(`relationship_${toObjects[0].relationship_type}`) - ) : toObjects.length > 1 ? ( - {t('Multiple entities selected')} - ) : ( - truncate(toObjects[0].name, 20) - )} - -
-
-
+ )} + @@ -612,114 +644,145 @@ class StixNestedRefRelationshipCreation extends Component { {t('Select a relationship')}
- {existingRelations.map((relation) => ( -
-
+ + {({ monochrome_labels }) => { + existingRelations.map((relation) => (
-
- -
-
- {fromObjects[0].relationship_type - ? t('Relationship') - : t(`entity_${fromObjects[0].entity_type}`)} -
-
-
- - {fromObjects.length > 1 ? ( - {t('Multiple entities selected')} - ) : ( - truncate(fromObjects[0].name, 20) - )} - -
-
-
- -
-
- {t(`relationship_${relation.node.relationship_type}`)} -
- {t('First obs.')} {fsd(relation.node.start_time)} -
- {t('Last obs.')} {fsd(relation.node.stop_time)} +
+
+ +
+
+ {fromObjects[0].relationship_type + ? t('Relationship') + : t(`entity_${fromObjects[0].entity_type}`)} +
+
+
+ + {fromObjects.length > 1 ? ( + {t('Multiple entities selected')} + ) : ( + truncate(fromObjects[0].name, 20) + )} + +
-
-
-
-
-
- +
+ +
+ +
+ {t(`relationship_${relation.node.relationship_type}`)} +
+ {t('First obs.')} {fsd(relation.node.start_time)} +
+ {t('Last obs.')} {fsd(relation.node.stop_time)} +
+
-
- {toObjects[0].relationship_type - ? t('Relationship') - : t(`entity_${toObjects[0].entity_type}`)} +
+
+
+ +
+
+ {toObjects[0].relationship_type + ? t('Relationship') + : t(`entity_${toObjects[0].entity_type}`)} +
+
+
+ + {truncate(toObjects[0].name, 20)} + +
+
-
- - {truncate(toObjects[0].name, 20)} - -
-
-
-
- ))} + )); + } + } +
({ drawerPaper: { @@ -389,6 +390,7 @@ class StixSightingRelationshipCreation extends Component { renderSelectSighting() { const { fsd, t, classes, fromObjects, toObjects, theme } = this.props; + const dark = theme.palette.mode === 'dark'; const { existingSightings } = this.state; return (
@@ -404,114 +406,145 @@ class StixSightingRelationshipCreation extends Component { {t('Select a sighting')}
- {existingSightings.map((sighting) => ( -
-
+ + {({ monochrome_labels }) => { + existingSightings.map((sighting) => (
-
- -
-
- {fromObjects[0].relationship_type - ? t('Relationship') - : t(`entity_${fromObjects[0].entity_type}`)} -
-
-
- - {fromObjects.length > 1 ? ( - {t('Multiple entities selected')} - ) : ( - truncate(fromObjects[0].name, 20) - )} - -
-
-
- -
-
- {t('sig')} -
- {t('First obs.')} {fsd(sighting.node.first_seen)} -
- {t('Last obs.')} {fsd(sighting.node.last_seen)} +
+
+ +
+
+ {fromObjects[0].relationship_type + ? t('Relationship') + : t(`entity_${fromObjects[0].entity_type}`)} +
+
+
+ + {fromObjects.length > 1 ? ( + {t('Multiple entities selected')} + ) : ( + truncate(fromObjects[0].name, 20) + )} + +
-
-
-
-
-
- +
+ +
+ +
+ {t('sig')} +
+ {t('First obs.')} {fsd(sighting.node.first_seen)} +
+ {t('Last obs.')} {fsd(sighting.node.last_seen)} +
+
-
- {toObjects[0].relationship_type - ? t('Relationship') - : t(`entity_${toObjects[0].entity_type}`)} +
+
+
+ +
+
+ {toObjects[0].relationship_type + ? t('Relationship') + : t(`entity_${toObjects[0].entity_type}`)} +
+
+
+ + {truncate(getMainRepresentative(toObjects[0]), 20)} + +
+
-
- - {truncate(getMainRepresentative(toObjects[0]), 20)} - -
-
-
-
- ))} + )); + } + } +
({ container: { @@ -211,8 +212,10 @@ class StixSightingRelationshipContainer extends Component { classes, stixSightingRelationship, paddingRight, + theme, isFABReplaced = false, } = this.props; + const dark = theme.palette.mode === 'dark'; const { from } = stixSightingRelationship; const { to } = stixSightingRelationship; const fromRestricted = from === null; @@ -244,215 +247,237 @@ class StixSightingRelationshipContainer extends Component { {t('Relationship')} - - -
+ {({ monochrome_labels }) => ( + -
-
- +
-
-
- {/* eslint-disable-next-line no-nested-ternary */} - {!fromRestricted - ? from.relationship_type - ? t('Relationship') - : t(`entity_${from.entity_type}`) - : t('Restricted')} + dark, + undefined, + monochrome_labels, + )}`, + top: 20, + left: 20, + }} + > +
+
+ +
+
+ {/* eslint-disable-next-line no-nested-ternary */} + {!fromRestricted + ? from.relationship_type + ? t('Relationship') + : t(`entity_${from.entity_type}`) + : t('Restricted')} +
+
+
+ + {!fromRestricted + ? truncate( + from.name + || from.observable_value + || from.attribute_abstract + || from.content + || t(`relationship_${from.entity_type}`), + 50, + ) + : t('Restricted')} + +
+ +
+ +
+
-
- - {!fromRestricted - ? truncate( - from.name - || from.observable_value - || from.attribute_abstract - || from.content - || t(`relationship_${from.entity_type}`), - 50, - ) - : t('Restricted')} - -
-
- -
- -
- -
- -
-
-
- +
-
-
- {/* eslint-disable-next-line no-nested-ternary */} - {!toRestricted - ? to.relationship_type - ? t('Relationship') - : t(`entity_${to.entity_type}`) - : 'Restricted'} -
-
-
- - {!toRestricted - ? truncate( - to.name - || to.observable_value - || to.attribute_abstract - || to.content - || t(`relationship_${to.entity_type}`), - 50, - ) - : t('Restricted')} - -
-
- - -
- - - - {t('Marking')} - - - - {t('First seen')} - - {nsdt(stixSightingRelationship.first_seen)} - - {t('Last seen')} - - {nsdt(stixSightingRelationship.last_seen)} - - -
- - - {t('x_opencti_negative')} - - - - {t('Count')} - - - {n(stixSightingRelationship.attribute_count)} - - - {t('Description')} - - {t('Inferred knowledge')} - ) : ( - stixSightingRelationship.description +
+ +
+
+ {/* eslint-disable-next-line no-nested-ternary */} + {!toRestricted + ? to.relationship_type + ? t('Relationship') + : t(`entity_${to.entity_type}`) + : 'Restricted'} +
+
+
+ + {!toRestricted + ? truncate( + to.name + || to.observable_value + || to.attribute_abstract + || to.content + || t(`relationship_${to.entity_type}`), + 50, ) - } - remarkGfmPlugin={true} - commonmark={true} - /> + : t('Restricted')} + +
- - -
- + + +
+ + + + {t('Marking')} + + + + {t('First seen')} + + {nsdt(stixSightingRelationship.first_seen)} + + {t('Last seen')} + + {nsdt(stixSightingRelationship.last_seen)} + + +
+ + + {t('x_opencti_negative')} + + + + {t('Count')} + + + {n(stixSightingRelationship.attribute_count)} + + + {t('Description')} + + {t('Inferred knowledge')} + ) : ( + stixSightingRelationship.description + ) + } + remarkGfmPlugin={true} + commonmark={true} + /> +
+
+
+
+ + )} + diff --git a/opencti-platform/opencti-front/src/utils/Colors.js b/opencti-platform/opencti-front/src/utils/Colors.js index 5e2c56392f6d1..7d9d3bd03f924 100644 --- a/opencti-platform/opencti-front/src/utils/Colors.js +++ b/opencti-platform/opencti-front/src/utils/Colors.js @@ -31,7 +31,205 @@ export const stringToColour = (str, reversed = false) => { }; /* eslint-enable no-bitwise */ -export const itemColor = (type, dark = false, reversed = false) => { +/** + * Old itemColor function to get a color from an item's entity type + * Only use in class components, and use ItemColor for functional components + * @param {string} type + * @param {boolean} dark + * @param {boolean} reversed + * @param {boolean} monochrome_labels + * @returns + */ +export const itemColor = (type, dark = false, reversed = false, monochrome_labels = false) => { + if (monochrome_labels) { + switch (type) { + // Analyses + case 'Report': + case 'Grouping': + case 'Malware-Analysis': + case 'Note': + case 'External-Reference': + case 'Opinion': + return dark ? '#679f38' : '#006064'; + // Cases + case 'Case-Incident': + case 'Case-Rfi': + case 'Case-Rft': + case 'Task': + case 'Case-Feedback': + return dark ? '#ea80fc' : '#d81b60'; + // Events + case 'Incident': + case 'Sighting': + case 'Observed-Data': + return dark ? '#ec407a' : '#880d4f'; + // Observations + case 'Stix-Cyber-Observable': + case 'Autonomous-System': + case 'Directory': + case 'Domain-Name': + case 'Email-Addr': + case 'Email-Message': + case 'Email-Mime-Part-Type': + case 'StixFile': + case 'X509-Certificate': + case 'IPv4-Addr': + case 'IPv6-Addr': + case 'Mac-Addr': + case 'Mutex': + case 'Network-Traffic': + case 'Process': + case 'Software': + case 'Url': + case 'User-Account': + case 'Windows-Registry-Key': + case 'Windows-Registry-Value-Type': + case 'Cryptographic-Key': + case 'Cryptocurrency-Wallet': + case 'Text': + case 'User-Agent': + case 'Bank-Account': + case 'Credential': + case 'Tracking-Number': + case 'Phone-Number': + case 'Payment-Card': + case 'Media-Content': + case 'Persona': + case 'Artifact': + case 'Indicator': + case 'Infrastructure': + return '#fe5622'; + // Threats + case 'Threat-Actor-Group': + case 'Threat-Actor-Individual': + case 'Intrusion-Set': + case 'Campaign': + return dark ? '#ff9800' : '#d68100'; + // Arsenal + case 'Malware': + case 'Channel': + case 'Tool': + case 'Vulnerability': + return dark ? '#ffc108' : '#b59005'; + // Techniques + case 'Attack-Pattern': + case 'Narrative': + case 'Course-Of-Action': + case 'Data-Component': + case 'Data-Source': + return dark ? '#d4e157' : '#817717'; + // Entities + case 'Sector': + case 'Event': + case 'Organization': + case 'System': + case 'Individual': + case 'User': + return dark ? '#9447ff' : '#512da8'; + // Locations + case 'Region': + case 'Country': + case 'Administrative-Area': + case 'City': + case 'Position': + return dark ? '#00acc1' : '#0675be'; + // Misc + case 'Language': + return dark ? '#afb42b' : '#d4e157'; + case 'Dashboard': + case 'Investigation': + return dark ? '#689f38' : '#33691e'; + case 'Session': + return dark ? '#5d4037' : '#795548'; + // Relationships + case 'Stix-Core-Relationship': + case 'Relationship': + case 'stix-core-relationship': + case 'targets': + case 'uses': + case 'located-at': + case 'related-to': + case 'mitigates': + case 'impersonates': + case 'indicates': + case 'comes-after': + case 'attributed-to': + case 'variant-of': + case 'part-of': + case 'employed-by': + case 'resides-in': + case 'citizen-of': + case 'national-of': + case 'drops': + case 'delivers': + case 'compromises': + case 'belongs-to': + case 'based-on': + case 'communicates-with': + case 'amplifies': + case 'analyses-of': + case 'authored-by': + case 'beacons-to': + case 'characterizes': + case 'consists-of': + case 'controls': + case 'cooperates-with': + case 'derived-from': + case 'downloads': + case 'has': + case 'bcc': + case 'cc': + case 'obs_belongs-to': + case 'owns': + case 'dst': + case 'from': + case 'hosts': + case 'image': + case 'publishes': + case 'duplicate-of': + case 'obs_content': + case 'service-dll': + case 'dynamic-analyses-of': + case 'contains': + case 'exfiltrates-to': + case 'exploits': + case 'investigates': + case 'originates-from': + case 'participates-in': + case 'body-multipart': + case 'body-raw': + case 'child': + case 'creator-user': + case 'detects': + case 'dst-payload': + case 'encapsulated-by': + case 'encapsulates': + case 'opened-connection': + case 'operating-system': + case 'parent': + case 'parent-directory': + case 'raw-email': + case 'src-payload': + case 'remediates': + case 'resolves-to': + case 'obs_resolves-to': + case 'revoked-by': + case 'sample': + case 'sender': + case 'src': + case 'to': + case 'values': + case 'static-analyses-of': + case 'subnarrative-of': + case 'subtechnique-of': + case 'numberOfConnectedElement': + case 'known-as': + return dark ? '#616161' : '#9e9e9e'; + default: + return stringToColour(type, reversed); + } + } + switch (type) { case 'Attack-Pattern': if (dark) { diff --git a/opencti-platform/opencti-front/src/utils/graph/BasicRelationshipDetails.tsx b/opencti-platform/opencti-front/src/utils/graph/BasicRelationshipDetails.tsx index cb767e283f50f..b9d3ec431c45b 100644 --- a/opencti-platform/opencti-front/src/utils/graph/BasicRelationshipDetails.tsx +++ b/opencti-platform/opencti-front/src/utils/graph/BasicRelationshipDetails.tsx @@ -2,11 +2,12 @@ import React, { FunctionComponent } from 'react'; import Typography from '@mui/material/Typography'; import Chip from '@mui/material/Chip'; import makeStyles from '@mui/styles/makeStyles'; -import { hexToRGB, itemColor } from '../Colors'; +import { hexToRGB } from '../Colors'; import RelationShipFromAndTo from './RelationShipFromAndTo'; import ItemMarkings from '../../components/ItemMarkings'; import { useFormatter } from '../../components/i18n'; import type { SelectedEntity } from './EntitiesDetailsRightBar'; +import itemColor from '../../components/ItemColor'; // Deprecated - https://mui.com/system/styles/basics/ // Do not use it for new code. @@ -28,6 +29,7 @@ interface BasicRelationshipDetailsProps { const BasicRelationshipDetails: FunctionComponent = ({ relation }) => { const classes = useStyles(); const { t_i18n } = useFormatter(); + const relationshipType = relation.relationship_type ?? ''; return (
@@ -37,15 +39,15 @@ const BasicRelationshipDetails: FunctionComponent classes={{ root: classes.chipInList }} style={{ backgroundColor: hexToRGB( - itemColor(relation.relationship_type), + itemColor(relationshipType), 0.08, ), - color: itemColor(relation.relationship_type), + color: itemColor(relationshipType), border: `1px solid ${itemColor( - relation.relationship_type, + relationshipType, )}`, }} - label={t_i18n(`relationship_${relation.relationship_type}`)} + label={t_i18n(`relationship_${relationshipType}`)} /> {relation.source_id && ( { const { t_i18n } = useFormatter(); const theme = useTheme(); + const dark = theme.palette.mode === 'dark'; + const { me: { monochrome_labels } } = useAuth(); const getColorFromDistributionNode = (n: DistributionNode, selection: Selection) => { let color = isFieldForIdentifier(selection.attribute) - ? itemColor(n.entity?.entity_type) - : itemColor(n.label); + ? itemColor(n.entity?.entity_type ?? '', dark, undefined, monochrome_labels ?? false) + : itemColor(n.label, dark, undefined, monochrome_labels ?? false); if (n.entity?.color) { color = theme.palette.mode === 'light' && n.entity.color === '#ffffff' ? '#000000'