2022-09-07 18:09:25 +00:00
|
|
|
import React, { useContext } from "react";
|
2022-04-22 16:45:35 +00:00
|
|
|
import { syntaxHighlight } from "utilities/helpers";
|
2022-02-05 00:48:35 +00:00
|
|
|
|
2022-09-07 18:09:25 +00:00
|
|
|
import { AppContext } from "context/app";
|
|
|
|
|
import { IVulnerability } from "interfaces/vulnerability";
|
2022-02-05 00:48:35 +00:00
|
|
|
import Modal from "components/Modal";
|
|
|
|
|
import Button from "components/buttons/Button";
|
2022-10-27 18:06:57 +00:00
|
|
|
import CustomLink from "components/CustomLink";
|
2022-02-05 00:48:35 +00:00
|
|
|
|
|
|
|
|
const baseClass = "preview-data-modal";
|
|
|
|
|
|
|
|
|
|
interface IPreviewPayloadModalProps {
|
|
|
|
|
onCancel: () => void;
|
|
|
|
|
}
|
2022-09-07 18:09:25 +00:00
|
|
|
interface IJsonPayload {
|
|
|
|
|
timestamp: string;
|
|
|
|
|
vulnerability: IVulnerability;
|
|
|
|
|
}
|
2022-02-05 00:48:35 +00:00
|
|
|
|
|
|
|
|
const PreviewPayloadModal = ({
|
|
|
|
|
onCancel,
|
|
|
|
|
}: IPreviewPayloadModalProps): JSX.Element => {
|
2022-09-07 18:09:25 +00:00
|
|
|
const { isFreeTier } = useContext(AppContext);
|
|
|
|
|
|
|
|
|
|
const json: IJsonPayload = {
|
2022-02-05 00:48:35 +00:00
|
|
|
timestamp: "0000-00-00T00:00:00Z",
|
|
|
|
|
vulnerability: {
|
|
|
|
|
cve: "CVE-2014-9471",
|
|
|
|
|
details_link: "https://nvd.nist.gov/vuln/detail/CVE-2014-9471",
|
2022-09-07 18:09:25 +00:00
|
|
|
epss_probability: 0.7,
|
|
|
|
|
cvss_score: 5.7,
|
|
|
|
|
cisa_known_exploit: true,
|
2023-03-31 15:26:48 +00:00
|
|
|
cve_published: "2014-10-10T00:00:00Z",
|
2022-02-05 00:48:35 +00:00
|
|
|
hosts_affected: [
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
2022-10-14 19:26:15 +00:00
|
|
|
display_name: "macbook-1",
|
2022-02-05 00:48:35 +00:00
|
|
|
url: "https://fleet.example.com/hosts/1",
|
2023-05-17 20:53:15 +00:00
|
|
|
software_installed_paths: ["/usr/lib/some-path"],
|
2022-02-05 00:48:35 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 2,
|
2022-10-14 19:26:15 +00:00
|
|
|
display_name: "macbook-2",
|
2022-02-05 00:48:35 +00:00
|
|
|
url: "https://fleet.example.com/hosts/2",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2022-09-07 18:09:25 +00:00
|
|
|
if (isFreeTier) {
|
|
|
|
|
// Premium only features
|
|
|
|
|
delete json.vulnerability.epss_probability;
|
|
|
|
|
delete json.vulnerability.cvss_score;
|
|
|
|
|
delete json.vulnerability.cisa_known_exploit;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 00:48:35 +00:00
|
|
|
return (
|
2022-09-21 17:06:29 +00:00
|
|
|
<Modal
|
|
|
|
|
title={"Example payload"}
|
|
|
|
|
onExit={onCancel}
|
|
|
|
|
onEnter={onCancel}
|
|
|
|
|
className={baseClass}
|
|
|
|
|
>
|
2022-02-05 00:48:35 +00:00
|
|
|
<div className={`${baseClass}__preview-modal`}>
|
|
|
|
|
<p>
|
|
|
|
|
Want to learn more about how automations in Fleet work?{" "}
|
2022-10-27 18:06:57 +00:00
|
|
|
<CustomLink
|
|
|
|
|
url="https://fleetdm.com/docs/using-fleet/automations"
|
|
|
|
|
text="Check out the Fleet documentation"
|
|
|
|
|
newTab
|
|
|
|
|
/>
|
2022-02-05 00:48:35 +00:00
|
|
|
</p>
|
|
|
|
|
<div className={`${baseClass}__payload-request-preview`}>
|
|
|
|
|
<pre>POST https://server.com/example</pre>
|
|
|
|
|
</div>
|
|
|
|
|
<div className={`${baseClass}__payload-webhook-preview`}>
|
|
|
|
|
<pre dangerouslySetInnerHTML={{ __html: syntaxHighlight(json) }} />
|
|
|
|
|
</div>
|
2022-08-29 15:21:37 +00:00
|
|
|
<div className="modal-cta-wrap">
|
|
|
|
|
<Button onClick={onCancel} variant="brand">
|
2022-02-05 00:48:35 +00:00
|
|
|
Done
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default PreviewPayloadModal;
|