From c5fd6b422b18d888d160a254aa417b98fdc1c772 Mon Sep 17 00:00:00 2001 From: stefan1anuby Date: Mon, 23 Sep 2024 16:59:21 +0300 Subject: [PATCH 1/6] [backend] added 'has' relationship between system and vulnerability (#8453) Signed-off-by: stefan1anuby --- opencti-platform/opencti-graphql/src/database/stix.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/opencti-platform/opencti-graphql/src/database/stix.ts b/opencti-platform/opencti-graphql/src/database/stix.ts index a090621364e7..ed3689c6812c 100644 --- a/opencti-platform/opencti-graphql/src/database/stix.ts +++ b/opencti-platform/opencti-graphql/src/database/stix.ts @@ -346,6 +346,9 @@ export const stixCoreRelationshipsMapping: RelationshipMappings = { [`${ENTITY_TYPE_IDENTITY_SYSTEM}_${ENTITY_TYPE_LOCATION_REGION}`]: [ { name: RELATION_LOCATED_AT, type: REL_BUILT_IN } ], + [`${ENTITY_TYPE_IDENTITY_SYSTEM}_${ENTITY_TYPE_VULNERABILITY}`]: [ + { name: RELATION_HAS, type: REL_EXTENDED } + ], [`${ENTITY_TYPE_IDENTITY_SYSTEM}_${ENTITY_TYPE_IDENTITY_SYSTEM}`]: [ { name: RELATION_DERIVED_FROM, type: REL_BUILT_IN } ], From 9b5d4de433f3aa18cd0c08af40766aea27b4dd43 Mon Sep 17 00:00:00 2001 From: stefan1anuby Date: Sun, 6 Oct 2024 18:07:21 +0300 Subject: [PATCH 2/6] [frontend] added 'has' in the 'related' route as requested (#8453) --- .../src/private/components/entities/systems/SystemKnowledge.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx b/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx index a7856d0084d5..4d7d5c64b403 100644 --- a/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx +++ b/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx @@ -74,7 +74,7 @@ class SystemKnowledgeComponent extends Component { element={ From d9f2cf5478232f53aaa210fcf8b6b5cb0a61679b Mon Sep 17 00:00:00 2001 From: stefan1anuby Date: Sun, 6 Oct 2024 20:31:11 +0300 Subject: [PATCH 3/6] [frontend] added 'vulnerabilities' view in the knowledge bar of a system (#8498) --- .../components/entities/systems/Root.jsx | 334 ++++++++++++++++++ .../entities/systems/SystemKnowledge.jsx | 12 + 2 files changed, 346 insertions(+) create mode 100644 opencti-platform/opencti-front/src/private/components/entities/systems/Root.jsx diff --git a/opencti-platform/opencti-front/src/private/components/entities/systems/Root.jsx b/opencti-platform/opencti-front/src/private/components/entities/systems/Root.jsx new file mode 100644 index 000000000000..15ac514d9269 --- /dev/null +++ b/opencti-platform/opencti-front/src/private/components/entities/systems/Root.jsx @@ -0,0 +1,334 @@ +import React, { Component } from 'react'; +import * as PropTypes from 'prop-types'; +import { Route, Routes, Link, Navigate } from 'react-router-dom'; +import { graphql } from 'react-relay'; +import { propOr } from 'ramda'; +import * as R from 'ramda'; +import Box from '@mui/material/Box'; +import Tabs from '@mui/material/Tabs'; +import Tab from '@mui/material/Tab'; +import StixCoreObjectContentRoot from '../../common/stix_core_objects/StixCoreObjectContentRoot'; +import withRouter from '../../../../utils/compat_router/withRouter'; +import { QueryRenderer, requestSubscription } from '../../../../relay/environment'; +import System from './System'; +import SystemKnowledge from './SystemKnowledge'; +import StixDomainObjectHeader from '../../common/stix_domain_objects/StixDomainObjectHeader'; +import FileManager from '../../common/files/FileManager'; +import SystemPopover from './SystemPopover'; +import Loader from '../../../../components/Loader'; +import StixCoreObjectHistory from '../../common/stix_core_objects/StixCoreObjectHistory'; +import SystemAnalysis from './SystemAnalysis'; +import ErrorNotFound from '../../../../components/ErrorNotFound'; +import { buildViewParamsFromUrlAndStorage, saveViewParameters } from '../../../../utils/ListParameters'; +import StixCoreObjectKnowledgeBar from '../../common/stix_core_objects/StixCoreObjectKnowledgeBar'; +import EntityStixSightingRelationships from '../../events/stix_sighting_relationships/EntityStixSightingRelationships'; +import inject18n from '../../../../components/i18n'; +import Breadcrumbs from '../../../../components/Breadcrumbs'; +import { getCurrentTab, getPaddingRight } from '../../../../utils/utils'; +import Security from '../../../../utils/Security'; +import { KNOWLEDGE_KNUPDATE } from '../../../../utils/hooks/useGranted'; +import SystemEdition from './SystemEdition'; + +const subscription = graphql` + subscription RootSystemsSubscription($id: ID!) { + stixDomainObject(id: $id) { + ... on System { + ...System_system + ...SystemEditionContainer_system + } + ...FileImportViewer_entity + ...FileExportViewer_entity + ...FileExternalReferencesViewer_entity + ...WorkbenchFileViewer_entity + } + } +`; + +const systemQuery = graphql` + query RootSystemQuery($id: String!) { + system(id: $id) { + id + entity_type + name + x_opencti_aliases + stixCoreObjectsDistribution(field: "entity_type", operation: count) { + label + value + } + ...System_system + ...SystemKnowledge_system + ...FileImportViewer_entity + ...FileExportViewer_entity + ...FileExternalReferencesViewer_entity + ...WorkbenchFileViewer_entity + ...StixCoreObjectContent_stixCoreObject + } + connectorsForImport { + ...FileManager_connectorsImport + } + connectorsForExport { + ...FileManager_connectorsExport + } + } +`; + +class RootSystem extends Component { + constructor(props) { + super(props); + const { + params: { systemId }, + } = props; + const LOCAL_STORAGE_KEY = `system-${systemId}`; + const params = buildViewParamsFromUrlAndStorage( + props.navigate, + props.location, + LOCAL_STORAGE_KEY, + ); + this.state = { + viewAs: propOr('knowledge', 'viewAs', params), + }; + this.sub = requestSubscription({ + subscription, + variables: { id: systemId }, + }); + } + + componentWillUnmount() { + this.sub.dispose(); + } + + saveView() { + const { + params: { systemId }, + } = this.props; + const LOCAL_STORAGE_KEY = `system-${systemId}`; + saveViewParameters( + this.props.navigate, + this.props.location, + LOCAL_STORAGE_KEY, + this.state, + true, + ); + } + + handleChangeViewAs(event) { + this.setState({ viewAs: event.target.value }, () => this.saveView()); + } + + render() { + const { + t, + location, + params: { systemId }, + } = this.props; + const { viewAs } = this.state; + const link = `/dashboard/entities/systems/${systemId}/knowledge`; + + return ( + <> + { + if (props) { + if (props.system) { + const { system } = props; + const paddingRight = getPaddingRight(location.pathname, system.id, '/dashboard/entities/systems'); + return ( + <> + + + )} + /> + +
+ + } + EditComponent={( + + + + )} + onViewAs={this.handleChangeViewAs.bind(this)} + viewAs={viewAs} + /> + + + + + + + + + + + + + + } + /> + + } + /> + + } + /> + + } + /> + + } + /> + + } + /> + + } + /> + + } + /> + +
+ + ); + } + return ; + } + return ; + }} + /> + + ); + } +} + +RootSystem.propTypes = { + children: PropTypes.node, + params: PropTypes.object, +}; + +export default R.compose(inject18n, withRouter)(RootSystem); diff --git a/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx b/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx index 4d7d5c64b403..069fc435b13a 100644 --- a/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx +++ b/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx @@ -210,6 +210,18 @@ class SystemKnowledgeComponent extends Component { /> } /> + + } + /> ); From cee7ca5d33aa9dff44d2efc390b0596f8d106466 Mon Sep 17 00:00:00 2001 From: stefan1anuby Date: Sun, 6 Oct 2024 21:20:18 +0300 Subject: [PATCH 4/6] [frontend] added the 'vulnerabilities' back (merge conflicts) --- .../src/private/components/entities/systems/Root.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/opencti-platform/opencti-front/src/private/components/entities/systems/Root.tsx b/opencti-platform/opencti-front/src/private/components/entities/systems/Root.tsx index 2bbe0ae348f4..c677422eccbd 100644 --- a/opencti-platform/opencti-front/src/private/components/entities/systems/Root.tsx +++ b/opencti-platform/opencti-front/src/private/components/entities/systems/Root.tsx @@ -146,6 +146,7 @@ const RootSystem = ({ systemId, queryRef }: RootSystemProps) => { 'attack_patterns', 'tools', 'observables', + 'vulnerabilities', ]} stixCoreObjectsDistribution={system.stixCoreObjectsDistribution} /> From 9e6fb5eab79b55fd692b515ea683db933f5c8e51 Mon Sep 17 00:00:00 2001 From: BocognanoSarah Date: Mon, 14 Oct 2024 10:04:50 +0200 Subject: [PATCH 5/6] [frontend] remove 'has' relationship in related-to now that vulnerability tab is present --- .../src/private/components/entities/systems/SystemKnowledge.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx b/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx index 069fc435b13a..7609176310a1 100644 --- a/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx +++ b/opencti-platform/opencti-front/src/private/components/entities/systems/SystemKnowledge.jsx @@ -74,7 +74,7 @@ class SystemKnowledgeComponent extends Component { element={ From f2bfcff731e209a96f0e23a6a14b3ee2c00d34b9 Mon Sep 17 00:00:00 2001 From: BocognanoSarah Date: Mon, 14 Oct 2024 11:12:13 +0200 Subject: [PATCH 6/6] [frontend] fix root.jsx deletion --- .../components/entities/systems/Root.jsx | 334 ------------------ 1 file changed, 334 deletions(-) delete mode 100644 opencti-platform/opencti-front/src/private/components/entities/systems/Root.jsx diff --git a/opencti-platform/opencti-front/src/private/components/entities/systems/Root.jsx b/opencti-platform/opencti-front/src/private/components/entities/systems/Root.jsx deleted file mode 100644 index 15ac514d9269..000000000000 --- a/opencti-platform/opencti-front/src/private/components/entities/systems/Root.jsx +++ /dev/null @@ -1,334 +0,0 @@ -import React, { Component } from 'react'; -import * as PropTypes from 'prop-types'; -import { Route, Routes, Link, Navigate } from 'react-router-dom'; -import { graphql } from 'react-relay'; -import { propOr } from 'ramda'; -import * as R from 'ramda'; -import Box from '@mui/material/Box'; -import Tabs from '@mui/material/Tabs'; -import Tab from '@mui/material/Tab'; -import StixCoreObjectContentRoot from '../../common/stix_core_objects/StixCoreObjectContentRoot'; -import withRouter from '../../../../utils/compat_router/withRouter'; -import { QueryRenderer, requestSubscription } from '../../../../relay/environment'; -import System from './System'; -import SystemKnowledge from './SystemKnowledge'; -import StixDomainObjectHeader from '../../common/stix_domain_objects/StixDomainObjectHeader'; -import FileManager from '../../common/files/FileManager'; -import SystemPopover from './SystemPopover'; -import Loader from '../../../../components/Loader'; -import StixCoreObjectHistory from '../../common/stix_core_objects/StixCoreObjectHistory'; -import SystemAnalysis from './SystemAnalysis'; -import ErrorNotFound from '../../../../components/ErrorNotFound'; -import { buildViewParamsFromUrlAndStorage, saveViewParameters } from '../../../../utils/ListParameters'; -import StixCoreObjectKnowledgeBar from '../../common/stix_core_objects/StixCoreObjectKnowledgeBar'; -import EntityStixSightingRelationships from '../../events/stix_sighting_relationships/EntityStixSightingRelationships'; -import inject18n from '../../../../components/i18n'; -import Breadcrumbs from '../../../../components/Breadcrumbs'; -import { getCurrentTab, getPaddingRight } from '../../../../utils/utils'; -import Security from '../../../../utils/Security'; -import { KNOWLEDGE_KNUPDATE } from '../../../../utils/hooks/useGranted'; -import SystemEdition from './SystemEdition'; - -const subscription = graphql` - subscription RootSystemsSubscription($id: ID!) { - stixDomainObject(id: $id) { - ... on System { - ...System_system - ...SystemEditionContainer_system - } - ...FileImportViewer_entity - ...FileExportViewer_entity - ...FileExternalReferencesViewer_entity - ...WorkbenchFileViewer_entity - } - } -`; - -const systemQuery = graphql` - query RootSystemQuery($id: String!) { - system(id: $id) { - id - entity_type - name - x_opencti_aliases - stixCoreObjectsDistribution(field: "entity_type", operation: count) { - label - value - } - ...System_system - ...SystemKnowledge_system - ...FileImportViewer_entity - ...FileExportViewer_entity - ...FileExternalReferencesViewer_entity - ...WorkbenchFileViewer_entity - ...StixCoreObjectContent_stixCoreObject - } - connectorsForImport { - ...FileManager_connectorsImport - } - connectorsForExport { - ...FileManager_connectorsExport - } - } -`; - -class RootSystem extends Component { - constructor(props) { - super(props); - const { - params: { systemId }, - } = props; - const LOCAL_STORAGE_KEY = `system-${systemId}`; - const params = buildViewParamsFromUrlAndStorage( - props.navigate, - props.location, - LOCAL_STORAGE_KEY, - ); - this.state = { - viewAs: propOr('knowledge', 'viewAs', params), - }; - this.sub = requestSubscription({ - subscription, - variables: { id: systemId }, - }); - } - - componentWillUnmount() { - this.sub.dispose(); - } - - saveView() { - const { - params: { systemId }, - } = this.props; - const LOCAL_STORAGE_KEY = `system-${systemId}`; - saveViewParameters( - this.props.navigate, - this.props.location, - LOCAL_STORAGE_KEY, - this.state, - true, - ); - } - - handleChangeViewAs(event) { - this.setState({ viewAs: event.target.value }, () => this.saveView()); - } - - render() { - const { - t, - location, - params: { systemId }, - } = this.props; - const { viewAs } = this.state; - const link = `/dashboard/entities/systems/${systemId}/knowledge`; - - return ( - <> - { - if (props) { - if (props.system) { - const { system } = props; - const paddingRight = getPaddingRight(location.pathname, system.id, '/dashboard/entities/systems'); - return ( - <> - - - )} - /> - -
- - } - EditComponent={( - - - - )} - onViewAs={this.handleChangeViewAs.bind(this)} - viewAs={viewAs} - /> - - - - - - - - - - - - - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - -
- - ); - } - return ; - } - return ; - }} - /> - - ); - } -} - -RootSystem.propTypes = { - children: PropTypes.node, - params: PropTypes.object, -}; - -export default R.compose(inject18n, withRouter)(RootSystem);