Fleet UI: Update software automation preview payload modal (#7607)

This commit is contained in:
RachelElysia 2022-09-07 14:09:25 -04:00 committed by GitHub
parent 1c26e2555d
commit 13cb716674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 11 deletions

View File

@ -0,0 +1 @@
* Fleet Free and Fleet Premium UI show different software automation payload example

View File

@ -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[];
}

View File

@ -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 (
<Modal title={"Example payload"} onExit={onCancel} className={baseClass}>
<div className={`${baseClass}__preview-modal`}>