Skip to content

Commit

Permalink
[frontend] entity markings to default file markings for upload file f…
Browse files Browse the repository at this point in the history
…rom ask ai (#5823)
  • Loading branch information
ValentinBouzinFiligran committed Apr 26, 2024
1 parent 7f82370 commit 11ba9e5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ const ContainerHeader = (props) => {
instanceId={container.id}
instanceType={container.entity_type}
instanceName={getMainRepresentative(container)}
instanceMarkings={container.objectMarking.map(({ id }) => id)}
type="container"
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface StixCoreObjectAskAiProps {
instanceId: string;
instanceName: string;
instanceType: string;
instanceMarkings?: string[];
type: 'container' | 'threat' | 'victim' | 'unsupported';
}

Expand Down Expand Up @@ -98,7 +99,7 @@ const actionsExplanation = {
'convert-files': 'Try to convert the selected files (or all files associated to this entity) in a STIX 2.1 bundle.',
};

const StixCoreObjectAskAI: FunctionComponent<StixCoreObjectAskAiProps> = ({ instanceId, instanceType, instanceName, type }) => {
const StixCoreObjectAskAI: FunctionComponent<StixCoreObjectAskAiProps> = ({ instanceId, instanceType, instanceName, type, instanceMarkings }) => {
const { t_i18n } = useFormatter();
const navigate = useNavigate();
const isEnterpriseEdition = useEnterpriseEdition();
Expand Down Expand Up @@ -251,10 +252,12 @@ const StixCoreObjectAskAI: FunctionComponent<StixCoreObjectAskAiProps> = ({ inst
const file = new File([blob], fileName, {
type,
});
const fileMarkings = instanceMarkings ?? [];
commitMutationCreateFile({
variables: {
id: instanceId,
file,
fileMarkings,
noTriggerImport: false,
},
onCompleted: (response: StixDomainObjectContentFilesUploadStixDomainObjectMutation$data) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,13 @@ const StixDomainObjectHeader = (props) => {
/>
)}
{enableAskAi && (
<StixCoreObjectAskAI
instanceId={stixDomainObject.id}
instanceType={stixDomainObject.entity_type}
instanceName={getMainRepresentative(stixDomainObject)}
type={type}
/>
<StixCoreObjectAskAI
instanceId={stixDomainObject.id}
instanceType={stixDomainObject.entity_type}
instanceName={getMainRepresentative(stixDomainObject)}
instanceMarkings={stixDomainObject.objectMarking.map(({ id }) => id) ?? []}
type={type}
/>
)}
{(isKnowledgeUpdater || isKnowledgeEnricher) && (
<div className={classes.popover}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const intrusionSetQuery = graphql`
entity_type
name
aliases
objectMarking {
id
}
x_opencti_graph_data
...IntrusionSet_intrusionSet
...IntrusionSetKnowledge_intrusionSet
Expand Down

0 comments on commit 11ba9e5

Please sign in to comment.