feat(web): add Download STIX button to AttackerHeader
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import React from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Crosshair } from '../../../icons';
|
||||
import { Crosshair, Download } from '../../../icons';
|
||||
import { Tag } from '../ui';
|
||||
import api from '../../../utils/api';
|
||||
import type { AttackerData } from '../types';
|
||||
|
||||
interface Props {
|
||||
@@ -12,6 +13,20 @@ interface Props {
|
||||
* The identity badge is click-through to the resolved-actor page. */
|
||||
export const AttackerHeader: React.FC<Props> = ({ attacker }) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleStixDownload = async () => {
|
||||
try {
|
||||
const res = await api.get(`/attackers/${attacker.uuid}/export/stix`, { responseType: 'blob' });
|
||||
const href = URL.createObjectURL(res.data);
|
||||
const a = document.createElement('a');
|
||||
a.href = href;
|
||||
a.download = `decnet-attacker-${attacker.uuid.slice(0, 8)}.stix.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(href);
|
||||
} catch {
|
||||
// best-effort
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '16px' }}>
|
||||
<Crosshair size={32} className="violet-accent" />
|
||||
@@ -45,6 +60,16 @@ export const AttackerHeader: React.FC<Props> = ({ attacker }) => {
|
||||
IDENTITY · {attacker.identity_id.slice(0, 8)}
|
||||
</span>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="btn"
|
||||
style={{ marginLeft: 'auto' }}
|
||||
title="Download STIX 2.1 bundle for this attacker"
|
||||
onClick={handleStixDownload}
|
||||
>
|
||||
<Download size={12} />
|
||||
<span style={{ marginLeft: 6 }}>STIX</span>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user