From 13cb7166745a9b768881c5226f4aa03efd54eb19 Mon Sep 17 00:00:00 2001 From: RachelElysia <71795832+RachelElysia@users.noreply.github.com> Date: Wed, 7 Sep 2022 14:09:25 -0400 Subject: [PATCH] Fleet UI: Update software automation preview payload modal (#7607) --- ...-7602-software-automations-payload-example | 1 + frontend/interfaces/vulnerability.ts | 18 ++++++++----- .../PreviewPayloadModal.tsx | 25 +++++++++++++++---- 3 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 changes/issue-7602-software-automations-payload-example diff --git a/changes/issue-7602-software-automations-payload-example b/changes/issue-7602-software-automations-payload-example new file mode 100644 index 000000000..d41d89503 --- /dev/null +++ b/changes/issue-7602-software-automations-payload-example @@ -0,0 +1 @@ +* Fleet Free and Fleet Premium UI show different software automation payload example \ No newline at end of file diff --git a/frontend/interfaces/vulnerability.ts b/frontend/interfaces/vulnerability.ts index a8c056128..9f0440fde 100644 --- a/frontend/interfaces/vulnerability.ts +++ b/frontend/interfaces/vulnerability.ts @@ -5,10 +5,16 @@ export default PropTypes.shape({ details_link: PropTypes.string, }); -export interface IVulnerability { - cisa_known_exploit: string | null; - cve: string; - cvss_score: string | null; - details_link: string; - epss_probability: number | null; +export interface IHostsAffected { + id: number; + hostname: string; + url: string; +} +export interface IVulnerability { + cisa_known_exploit?: boolean; + cve: string; + cvss_score?: number; + details_link: string; + epss_probability?: number; + hosts_affected?: IHostsAffected[]; } diff --git a/frontend/pages/software/ManageSoftwarePage/components/PreviewPayloadModal/PreviewPayloadModal.tsx b/frontend/pages/software/ManageSoftwarePage/components/PreviewPayloadModal/PreviewPayloadModal.tsx index 320cb2dd3..a8455ada3 100644 --- a/frontend/pages/software/ManageSoftwarePage/components/PreviewPayloadModal/PreviewPayloadModal.tsx +++ b/frontend/pages/software/ManageSoftwarePage/components/PreviewPayloadModal/PreviewPayloadModal.tsx @@ -1,6 +1,8 @@ -import React from "react"; +import React, { useContext } from "react"; import { syntaxHighlight } from "utilities/helpers"; +import { AppContext } from "context/app"; +import { IVulnerability } from "interfaces/vulnerability"; import Modal from "components/Modal"; import Button from "components/buttons/Button"; import ExternalLinkIcon from "../../../../../../assets/images/icon-external-link-12x12@2x.png"; @@ -10,18 +12,24 @@ const baseClass = "preview-data-modal"; interface IPreviewPayloadModalProps { onCancel: () => void; } +interface IJsonPayload { + timestamp: string; + vulnerability: IVulnerability; +} const PreviewPayloadModal = ({ onCancel, }: IPreviewPayloadModalProps): JSX.Element => { - const json = { + const { isFreeTier } = useContext(AppContext); + + const json: IJsonPayload = { timestamp: "0000-00-00T00:00:00Z", vulnerability: { cve: "CVE-2014-9471", details_link: "https://nvd.nist.gov/vuln/detail/CVE-2014-9471", - epss_probability: 0.7, // Premium feature only - cvss_score: 5.7, // Premium feature only - cisa_known_exploit: true, // Premium feature only + epss_probability: 0.7, + cvss_score: 5.7, + cisa_known_exploit: true, hosts_affected: [ { id: 1, @@ -37,6 +45,13 @@ const PreviewPayloadModal = ({ }, }; + if (isFreeTier) { + // Premium only features + delete json.vulnerability.epss_probability; + delete json.vulnerability.cvss_score; + delete json.vulnerability.cisa_known_exploit; + } + return (