Skip to content

Commit

Permalink
[backend] For Software, display the version in addition to the names …
Browse files Browse the repository at this point in the history
…in parenthesis (#7765)
  • Loading branch information
ValentinBouzinFiligran authored Jul 23, 2024
1 parent 9505d99 commit 585127b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion opencti-platform/opencti-graphql/src/utils/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ export const truncate = (str, limit = DEFAULT_TRUNCATE_LIMIT, withPoints = true)
return `${trimmedStr.substr(0, Math.min(trimmedStr.length, trimmedStr.lastIndexOf(' ')))}...`;
};

const formatSoftware = (stixCyberObservable) => {
const value = stixCyberObservable.name || stixCyberObservable.cpe || stixCyberObservable.swid || 'Unknown';
if (value !== 'Unknown' && !!stixCyberObservable.version) {
return `${value} (${stixCyberObservable.version})`;
}
return value;
};

// TODO for now this list is duplicated in Front, think about updating it aswell
export const observableValue = (stixCyberObservable) => {
switch (stixCyberObservable.entity_type) {
Expand All @@ -144,7 +152,7 @@ export const observableValue = (stixCyberObservable) => {
case ENTITY_PROCESS:
return stixCyberObservable.pid || stixCyberObservable.command_line || 'Unknown';
case ENTITY_SOFTWARE:
return stixCyberObservable.name || stixCyberObservable.cpe || stixCyberObservable.swid || 'Unknown';
return formatSoftware(stixCyberObservable);
case ENTITY_USER_ACCOUNT:
return stixCyberObservable.account_login || stixCyberObservable.user_id || 'Unknown';
case ENTITY_BANK_ACCOUNT:
Expand Down

0 comments on commit 585127b

Please sign in to comment.