Skip to content

Commit

Permalink
[frontend] Update relationship creation and display (#8576)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kedae committed Oct 8, 2024
1 parent 93f1a93 commit 65500f4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MalwareKnowledgeComponent extends Component {
entityLink={link}
defaultStartTime={malware.first_seen}
defaultStopTime={malware.last_seen}
allDirections={true}
allDirections
/>
)}
/>
Expand Down Expand Up @@ -94,12 +94,13 @@ class MalwareKnowledgeComponent extends Component {
element={(
<EntityStixCoreRelationships
entityId={malware.id}
relationshipTypes={['uses']}
relationshipTypes={['uses', 'authored-by']}
stixCoreObjectTypes={['Threat-Actor']}
entityLink={link}
defaultStartTime={malware.first_seen}
defaultStopTime={malware.last_seen}
isRelationReversed={true}
allDirections
/>
)}
/>
Expand All @@ -108,12 +109,13 @@ class MalwareKnowledgeComponent extends Component {
element={(
<EntityStixCoreRelationships
entityId={malware.id}
relationshipTypes={['uses']}
relationshipTypes={['uses', 'authored-by']}
stixCoreObjectTypes={['Intrusion-Set']}
entityLink={link}
defaultStartTime={malware.first_seen}
defaultStopTime={malware.last_seen}
isRelationReversed={true}
allDirections
/>
)}
/>
Expand Down Expand Up @@ -248,7 +250,7 @@ class MalwareKnowledgeComponent extends Component {
entityLink={link}
defaultStartTime={malware.first_seen}
defaultStopTime={malware.last_seen}
allDirections={true}
allDirections
/>
)}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FunctionComponent } from 'react';
import React, { FunctionComponent, useState } from 'react';
import useAuth from '../../../../../utils/hooks/useAuth';
import ListLines from '../../../../../components/list_lines/ListLines';
import ToolBar from '../../../data/ToolBar';
Expand Down Expand Up @@ -146,6 +146,11 @@ EntityStixCoreRelationshipsEntitiesViewProps
onToggleEntity,
} = useEntityToggle(localStorageKey);

const [reversedRelation, setReversedRelation] = useState(isRelationReversed);
const handleReverseRelation = () => {
setReversedRelation(!reversedRelation);
};

const finalView = currentView || view;
return (
<>
Expand Down Expand Up @@ -238,7 +243,8 @@ EntityStixCoreRelationshipsEntitiesViewProps
<StixCoreRelationshipCreationFromEntity
entityId={entityId}
allowedRelationshipTypes={relationshipTypes}
isRelationReversed={isRelationReversed}
isRelationReversed={reversedRelation}
handleReverseRelation={handleReverseRelation}
targetStixDomainObjectTypes={computeTargetStixDomainObjectTypes(
stixCoreObjectTypes,
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class IntrusionSetKnowledgeComponent extends Component {
entityLink={link}
defaultStartTime={intrusionSet.first_seen}
defaultStopTime={intrusionSet.last_seen}
allDirections={true}
allDirections
/>
}
/>
Expand Down Expand Up @@ -114,12 +114,13 @@ class IntrusionSetKnowledgeComponent extends Component {
element={
<EntityStixCoreRelationships
entityId={intrusionSet.id}
relationshipTypes={['uses']}
relationshipTypes={['uses', 'authored-by']}
stixCoreObjectTypes={['Malware']}
entityLink={link}
defaultStartTime={intrusionSet.first_seen}
defaultStopTime={intrusionSet.last_seen}
isRelationReversed={false}
allDirections
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ThreatActorGroupKnowledgeComponent extends Component {
entityLink={link}
defaultStartTime={threatActorGroup.first_seen}
defaultStopTime={threatActorGroup.last_seen}
allDirections={true}
allDirections
/>
}
/>
Expand All @@ -81,7 +81,7 @@ class ThreatActorGroupKnowledgeComponent extends Component {
entityLink={link}
defaultStartTime={threatActorGroup.first_seen}
defaultStopTime={threatActorGroup.last_seen}
allDirections={true}
allDirections
/>
}
/>
Expand Down Expand Up @@ -109,7 +109,6 @@ class ThreatActorGroupKnowledgeComponent extends Component {
entityLink={link}
defaultStartTime={threatActorGroup.first_seen}
defaultStopTime={threatActorGroup.last_seen}
allDirections={true}
/>
}
/>
Expand All @@ -128,11 +127,12 @@ class ThreatActorGroupKnowledgeComponent extends Component {
element={
<EntityStixCoreRelationships
entityId={threatActorGroup.id}
relationshipTypes={['uses']}
relationshipTypes={['uses', 'authored-by']}
stixCoreObjectTypes={['Malware']}
entityLink={link}
defaultStartTime={threatActorGroup.first_seen}
defaultStopTime={threatActorGroup.last_seen}
allDirections
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const ThreatActorIndividualKnowledgeComponent = ({
entityLink={link}
defaultStartTime={threatActorIndividual.first_seen}
defaultStopTime={threatActorIndividual.last_seen}
allDirections={true}
allDirections
/>
}
/>
Expand All @@ -100,7 +100,7 @@ const ThreatActorIndividualKnowledgeComponent = ({
entityLink={link}
defaultStartTime={threatActorIndividual.first_seen}
defaultStopTime={threatActorIndividual.last_seen}
allDirections={true}
allDirections
/>
}
/>
Expand Down Expand Up @@ -128,7 +128,7 @@ const ThreatActorIndividualKnowledgeComponent = ({
entityLink={link}
defaultStartTime={threatActorIndividual.first_seen}
defaultStopTime={threatActorIndividual.last_seen}
allDirections={true}
allDirections
/>
}
/>
Expand All @@ -147,11 +147,12 @@ const ThreatActorIndividualKnowledgeComponent = ({
element={
<EntityStixCoreRelationships
entityId={threatActorIndividual.id}
relationshipTypes={['uses']}
relationshipTypes={['uses', 'authored-by']}
stixCoreObjectTypes={['Malware']}
entityLink={link}
defaultStartTime={threatActorIndividual.first_seen}
defaultStopTime={threatActorIndividual.last_seen}
allDirections
/>
}
/>
Expand Down

0 comments on commit 65500f4

Please sign in to comment.