Projects STRLCPY opencti Commits ed232202
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-front/src/components/StixItemMarkings.js
    skipped 74 lines
    75 75   const className = variant === 'inList' ? classes.chipInList : classes.chip;
    76 76   const number = limit || 1;
    77 77   const sortBy = R.sortWith([R.descend(R.prop('name'))]);
    78  - const markings = R.pipe(
    79  - sortBy,
    80  - R.take(number),
    81  - )(markingDefinitions);
     78 + const markings = R.pipe(sortBy, R.take(number))(markingDefinitions);
    82 79   return (
    83 80   <div>
    84 81   {markings.map((markingDefinition) => {
    85  - const label = truncate(markingDefinition.name || markingDefinition.definition, 20);
     82 + let def = markingDefinition.name;
     83 + if (!def) {
     84 + if (markingDefinition.definition) {
     85 + const definition = R.toPairs(markingDefinition.definition);
     86 + if (definition[0]) {
     87 + if (definition[0][1].includes(':')) {
     88 + // eslint-disable-next-line prefer-destructuring
     89 + def = definition[0][1];
     90 + } else {
     91 + def = `${definition[0][0]}:${definition[0][1]}`;
     92 + }
     93 + } else {
     94 + def = 'Unknown';
     95 + }
     96 + }
     97 + }
     98 + const label = truncate(def, 20);
    86 99   if (markingDefinition.x_opencti_color) {
    87 100   let backgroundColor = markingDefinition.x_opencti_color;
    88 101   let textColor = theme.palette.text.primary;
    skipped 11 lines
    100 113   }
    101 114   return (
    102 115   <Chip
    103  - key={markingDefinition.name || markingDefinition.definition}
     116 + key={label}
    104 117   className={className}
    105 118   style={{
    106 119   backgroundColor,
    skipped 8 lines
    115 128   if (theme.palette.mode === 'light') {
    116 129   inlineStyles = inlineStylesLight;
    117 130   }
    118  - switch (markingDefinition.name || markingDefinition.definition) {
     131 + switch (def) {
    119 132   case 'CD':
    120 133   case 'CD-SF':
    121 134   case 'DR':
    skipped 1 lines
    123 136   case 'TLP:RED':
    124 137   return (
    125 138   <Chip
    126  - key={markingDefinition.name || markingDefinition.definition}
     139 + key={def}
    127 140   className={className}
    128 141   style={inlineStyles.red}
    129 142   label={label}
    skipped 2 lines
    132 145   case 'TLP:AMBER':
    133 146   return (
    134 147   <Chip
    135  - key={markingDefinition.name || markingDefinition.definition}
     148 + key={def}
    136 149   className={className}
    137 150   style={inlineStyles.orange}
    138 151   label={label}
    skipped 3 lines
    142 155   case 'TLP:GREEN':
    143 156   return (
    144 157   <Chip
    145  - key={markingDefinition.name || markingDefinition.definition}
     158 + key={def}
    146 159   className={className}
    147 160   style={inlineStyles.green}
    148 161   label={label}
    skipped 2 lines
    151 164   case 'SF':
    152 165   return (
    153 166   <Chip
    154  - key={markingDefinition.name}
     167 + key={def}
    155 168   className={className}
    156 169   style={inlineStyles.blue}
    157 170   label={label}
    skipped 2 lines
    160 173   default:
    161 174   return (
    162 175   <Chip
    163  - key={markingDefinition.name || markingDefinition.definition}
     176 + key={def}
    164 177   className={className}
    165 178   style={inlineStyles.white}
    166 179   label={label}
    skipped 18 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-front/src/private/components/common/files/workbench/WorkbenchFileContent.js
    skipped 496 lines
    497 497   .map((n) => {
    498 498   const marking = this.findEntityById(n);
    499 499   if (marking) {
     500 + let label = truncate(marking.name, 20);
     501 + if (!label) {
     502 + if (marking.definition) {
     503 + const definition = R.toPairs(marking.definition);
     504 + if (definition[0]) {
     505 + if (definition[0][1].includes(':')) {
     506 + label = truncate(definition[0][1], 20);
     507 + } else {
     508 + label = truncate(
     509 + `${definition[0][0]}:${definition[0][1]}`,
     510 + 20,
     511 + );
     512 + }
     513 + } else {
     514 + label = 'Unknown';
     515 + }
     516 + }
     517 + }
    500 518   return {
    501  - label: marking.name || marking.definition,
     519 + label,
    502 520   value: marking.id,
    503 521   entity: marking,
    504 522   };
    skipped 3558 lines
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-front/src/utils/Graph.js
    skipped 295 lines
    296 296   return t(`entity_${n.entity_type}`);
    297 297  };
    298 298   
     299 +export const defaultValueMarking = (n) => {
     300 + let def = 'Unknown';
     301 + if (n.definition) {
     302 + const definition = R.toPairs(n.definition);
     303 + if (definition[0]) {
     304 + if (definition[0][1].includes(':')) {
     305 + // eslint-disable-next-line prefer-destructuring
     306 + def = definition[0][1];
     307 + } else {
     308 + def = `${definition[0][0]}:${definition[0][1]}`;
     309 + }
     310 + }
     311 + }
     312 + return def;
     313 +};
     314 + 
    299 315  export const defaultValue = (n, tooltip = false) => {
    300 316   if (!n) return '';
     317 + if (typeof n.definition === 'object') {
     318 + return defaultValueMarking(n);
     319 + }
    301 320   if (tooltip) {
    302 321   return `${n.x_mitre_id ? `[${n.x_mitre_id}] ` : ''}${
    303 322   n.name
    skipped 654 lines
Please wait...
Page is in error, reload to recover