2022-05-11 02:33:30 +00:00
|
|
|
import React, { useState, useEffect } from "react";
|
2022-04-11 19:04:41 +00:00
|
|
|
import { useQuery } from "react-query";
|
2022-02-05 00:48:35 +00:00
|
|
|
|
2022-04-11 19:04:41 +00:00
|
|
|
import { Link } from "react-router";
|
|
|
|
|
import PATHS from "router/paths";
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
IJiraIntegration,
|
2022-05-11 02:33:30 +00:00
|
|
|
IZendeskIntegration,
|
|
|
|
|
IIntegration,
|
|
|
|
|
IIntegrations,
|
2022-10-14 19:26:15 +00:00
|
|
|
IIntegrationType,
|
2022-04-11 19:04:41 +00:00
|
|
|
} from "interfaces/integration";
|
2022-10-19 19:00:39 +00:00
|
|
|
import {
|
|
|
|
|
IConfig,
|
|
|
|
|
CONFIG_DEFAULT_RECENT_VULNERABILITY_MAX_AGE_IN_DAYS,
|
|
|
|
|
} from "interfaces/config";
|
2022-04-11 19:04:41 +00:00
|
|
|
import configAPI from "services/entities/config";
|
|
|
|
|
|
2022-04-13 22:23:09 +00:00
|
|
|
import ReactTooltip from "react-tooltip";
|
2022-04-11 19:04:41 +00:00
|
|
|
// @ts-ignore
|
|
|
|
|
import Dropdown from "components/forms/fields/Dropdown";
|
2022-02-05 00:48:35 +00:00
|
|
|
import Modal from "components/Modal";
|
|
|
|
|
import Button from "components/buttons/Button";
|
2022-03-11 17:56:14 +00:00
|
|
|
import Slider from "components/forms/fields/Slider";
|
2022-04-11 19:04:41 +00:00
|
|
|
import Radio from "components/forms/fields/Radio";
|
2022-02-05 00:48:35 +00:00
|
|
|
// @ts-ignore
|
|
|
|
|
import InputField from "components/forms/fields/InputField";
|
|
|
|
|
|
|
|
|
|
import { IWebhookSoftwareVulnerabilities } from "interfaces/webhook";
|
2022-04-22 16:45:35 +00:00
|
|
|
import useDeepEffect from "hooks/useDeepEffect";
|
2022-10-19 19:00:39 +00:00
|
|
|
import { size } from "lodash";
|
2022-02-05 00:48:35 +00:00
|
|
|
|
|
|
|
|
import PreviewPayloadModal from "../PreviewPayloadModal";
|
2022-10-14 19:26:15 +00:00
|
|
|
import PreviewTicketModal from "../PreviewTicketModal";
|
2022-02-05 00:48:35 +00:00
|
|
|
|
2022-04-11 19:04:41 +00:00
|
|
|
interface ISoftwareAutomations {
|
|
|
|
|
webhook_settings: {
|
|
|
|
|
vulnerabilities_webhook: IWebhookSoftwareVulnerabilities;
|
|
|
|
|
};
|
|
|
|
|
integrations: {
|
|
|
|
|
jira: IJiraIntegration[];
|
2022-05-11 02:33:30 +00:00
|
|
|
zendesk: IZendeskIntegration[];
|
2022-04-11 19:04:41 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 00:48:35 +00:00
|
|
|
interface IManageAutomationsModalProps {
|
|
|
|
|
onCancel: () => void;
|
2022-04-11 19:04:41 +00:00
|
|
|
onCreateWebhookSubmit: (formData: ISoftwareAutomations) => void;
|
2022-02-05 00:48:35 +00:00
|
|
|
togglePreviewPayloadModal: () => void;
|
2022-10-14 19:26:15 +00:00
|
|
|
togglePreviewTicketModal: () => void;
|
2022-02-05 00:48:35 +00:00
|
|
|
showPreviewPayloadModal: boolean;
|
2022-10-14 19:26:15 +00:00
|
|
|
showPreviewTicketModal: boolean;
|
2022-04-11 19:04:41 +00:00
|
|
|
softwareVulnerabilityAutomationEnabled?: boolean;
|
2022-02-05 00:48:35 +00:00
|
|
|
softwareVulnerabilityWebhookEnabled?: boolean;
|
|
|
|
|
currentDestinationUrl?: string;
|
2022-04-13 18:45:50 +00:00
|
|
|
recentVulnerabilityMaxAge?: number;
|
2022-02-05 00:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const validateWebhookURL = (url: string) => {
|
|
|
|
|
const errors: { [key: string]: string } = {};
|
|
|
|
|
|
2022-03-03 17:20:49 +00:00
|
|
|
if (url === "") {
|
|
|
|
|
errors.url = "Please add a destination URL";
|
2022-02-05 00:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const valid = !size(errors);
|
|
|
|
|
return { valid, errors };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const baseClass = "manage-automations-modal";
|
|
|
|
|
|
|
|
|
|
const ManageAutomationsModal = ({
|
|
|
|
|
onCancel: onReturnToApp,
|
|
|
|
|
onCreateWebhookSubmit,
|
|
|
|
|
togglePreviewPayloadModal,
|
2022-10-14 19:26:15 +00:00
|
|
|
togglePreviewTicketModal,
|
2022-02-05 00:48:35 +00:00
|
|
|
showPreviewPayloadModal,
|
2022-10-14 19:26:15 +00:00
|
|
|
showPreviewTicketModal,
|
2022-04-11 19:04:41 +00:00
|
|
|
softwareVulnerabilityAutomationEnabled,
|
2022-02-05 00:48:35 +00:00
|
|
|
softwareVulnerabilityWebhookEnabled,
|
|
|
|
|
currentDestinationUrl,
|
2022-04-13 18:45:50 +00:00
|
|
|
recentVulnerabilityMaxAge,
|
2022-02-05 00:48:35 +00:00
|
|
|
}: IManageAutomationsModalProps): JSX.Element => {
|
2022-09-01 15:28:02 +00:00
|
|
|
const [destinationUrl, setDestinationUrl] = useState(
|
2022-02-05 00:48:35 +00:00
|
|
|
currentDestinationUrl || ""
|
|
|
|
|
);
|
|
|
|
|
const [errors, setErrors] = useState<{ [key: string]: string }>({});
|
2022-09-01 15:28:02 +00:00
|
|
|
const [softwareAutomationsEnabled, setSoftwareAutomationsEnabled] = useState(
|
|
|
|
|
softwareVulnerabilityAutomationEnabled || false
|
|
|
|
|
);
|
|
|
|
|
const [integrationEnabled, setIntegrationEnabled] = useState(
|
2022-04-11 19:04:41 +00:00
|
|
|
!softwareVulnerabilityWebhookEnabled
|
|
|
|
|
);
|
2022-05-11 02:33:30 +00:00
|
|
|
const [jiraIntegrationsIndexed, setJiraIntegrationsIndexed] = useState<
|
|
|
|
|
IIntegration[]
|
|
|
|
|
>();
|
|
|
|
|
const [zendeskIntegrationsIndexed, setZendeskIntegrationsIndexed] = useState<
|
|
|
|
|
IIntegration[]
|
|
|
|
|
>();
|
|
|
|
|
const [allIntegrationsIndexed, setAllIntegrationsIndexed] = useState<
|
|
|
|
|
IIntegration[]
|
2022-04-11 19:04:41 +00:00
|
|
|
>();
|
|
|
|
|
const [
|
|
|
|
|
selectedIntegration,
|
|
|
|
|
setSelectedIntegration,
|
2022-05-11 02:33:30 +00:00
|
|
|
] = useState<IIntegration>();
|
|
|
|
|
|
2022-04-15 17:41:05 +00:00
|
|
|
useDeepEffect(() => {
|
|
|
|
|
setSoftwareAutomationsEnabled(
|
|
|
|
|
softwareVulnerabilityAutomationEnabled || false
|
|
|
|
|
);
|
|
|
|
|
}, [softwareVulnerabilityAutomationEnabled]);
|
2022-02-05 00:48:35 +00:00
|
|
|
|
|
|
|
|
useDeepEffect(() => {
|
2022-04-13 22:23:09 +00:00
|
|
|
if (destinationUrl) {
|
2022-02-05 00:48:35 +00:00
|
|
|
setErrors({});
|
|
|
|
|
}
|
2022-04-13 22:23:09 +00:00
|
|
|
}, [destinationUrl]);
|
2022-02-05 00:48:35 +00:00
|
|
|
|
2022-05-11 02:33:30 +00:00
|
|
|
const { data: integrations } = useQuery<IConfig, Error, IIntegrations>(
|
2022-04-11 19:04:41 +00:00
|
|
|
["integrations"],
|
|
|
|
|
() => configAPI.loadAll(),
|
|
|
|
|
{
|
|
|
|
|
select: (data: IConfig) => {
|
2022-05-11 02:33:30 +00:00
|
|
|
return data.integrations;
|
2022-04-11 19:04:41 +00:00
|
|
|
},
|
|
|
|
|
onSuccess: (data) => {
|
2022-05-11 02:33:30 +00:00
|
|
|
// Set jira and zendesk integrations
|
|
|
|
|
const addJiraIndexed = data.jira
|
|
|
|
|
? data.jira.map((integration, index) => {
|
2022-10-14 19:26:15 +00:00
|
|
|
return {
|
|
|
|
|
...integration,
|
|
|
|
|
originalIndex: index,
|
|
|
|
|
type: "jira" as IIntegrationType,
|
|
|
|
|
};
|
2022-05-11 02:33:30 +00:00
|
|
|
})
|
|
|
|
|
: [];
|
|
|
|
|
setJiraIntegrationsIndexed(addJiraIndexed);
|
|
|
|
|
const addZendeskIndexed = data.zendesk
|
|
|
|
|
? data.zendesk.map((integration, index) => {
|
|
|
|
|
return {
|
|
|
|
|
...integration,
|
|
|
|
|
originalIndex: index,
|
2022-10-14 19:26:15 +00:00
|
|
|
type: "zendesk" as IIntegrationType,
|
2022-05-11 02:33:30 +00:00
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
: [];
|
|
|
|
|
setZendeskIntegrationsIndexed(addZendeskIndexed);
|
2022-04-11 19:04:41 +00:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2022-05-11 02:33:30 +00:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (jiraIntegrationsIndexed && zendeskIntegrationsIndexed) {
|
|
|
|
|
const combineDataSets = jiraIntegrationsIndexed.concat(
|
|
|
|
|
zendeskIntegrationsIndexed
|
|
|
|
|
);
|
|
|
|
|
setAllIntegrationsIndexed(
|
|
|
|
|
combineDataSets?.map((integration, index) => {
|
|
|
|
|
return { ...integration, dropdownIndex: index };
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}, [
|
|
|
|
|
jiraIntegrationsIndexed,
|
|
|
|
|
zendeskIntegrationsIndexed,
|
|
|
|
|
setAllIntegrationsIndexed,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (allIntegrationsIndexed) {
|
|
|
|
|
const currentSelectedIntegration = allIntegrationsIndexed.find(
|
|
|
|
|
(integration) => {
|
|
|
|
|
return integration.enable_software_vulnerabilities === true;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
setSelectedIntegration(currentSelectedIntegration);
|
|
|
|
|
}
|
|
|
|
|
}, [allIntegrationsIndexed]);
|
|
|
|
|
|
2022-02-05 00:48:35 +00:00
|
|
|
const onURLChange = (value: string) => {
|
|
|
|
|
setDestinationUrl(value);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleSaveAutomation = (evt: React.MouseEvent<HTMLFormElement>) => {
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
|
2022-04-11 19:04:41 +00:00
|
|
|
const { valid: validUrl, errors: newErrors } = validateWebhookURL(
|
2022-04-13 22:23:09 +00:00
|
|
|
destinationUrl
|
2022-04-11 19:04:41 +00:00
|
|
|
);
|
2022-02-05 00:48:35 +00:00
|
|
|
setErrors({
|
|
|
|
|
...errors,
|
|
|
|
|
...newErrors,
|
|
|
|
|
});
|
|
|
|
|
|
2022-04-11 19:04:41 +00:00
|
|
|
// Original config keys for software automation (webhook_settings, integrations)
|
|
|
|
|
const configSoftwareAutomations: ISoftwareAutomations = {
|
|
|
|
|
webhook_settings: {
|
|
|
|
|
vulnerabilities_webhook: {
|
2022-04-13 22:23:09 +00:00
|
|
|
destination_url: destinationUrl,
|
2022-04-11 19:04:41 +00:00
|
|
|
enable_vulnerabilities_webhook: softwareVulnerabilityWebhookEnabled,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
integrations: {
|
2022-05-11 02:33:30 +00:00
|
|
|
jira: integrations?.jira || [],
|
|
|
|
|
zendesk: integrations?.zendesk || [],
|
2022-04-11 19:04:41 +00:00
|
|
|
},
|
|
|
|
|
};
|
2022-02-05 00:48:35 +00:00
|
|
|
|
2022-04-11 19:04:41 +00:00
|
|
|
const updateSoftwareAutomation = () => {
|
|
|
|
|
if (!softwareAutomationsEnabled) {
|
2022-05-11 02:33:30 +00:00
|
|
|
// set enable_vulnerabilities_webhook
|
|
|
|
|
// jira.enable_software_vulnerabilities
|
|
|
|
|
// and zendesk.enable_software_vulnerabilities to false
|
2022-04-11 19:04:41 +00:00
|
|
|
configSoftwareAutomations.webhook_settings.vulnerabilities_webhook.enable_vulnerabilities_webhook = false;
|
|
|
|
|
const disableAllJira = configSoftwareAutomations.integrations.jira.map(
|
|
|
|
|
(integration) => {
|
|
|
|
|
return { ...integration, enable_software_vulnerabilities: false };
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
configSoftwareAutomations.integrations.jira = disableAllJira;
|
2022-05-11 02:33:30 +00:00
|
|
|
const disableAllZendesk = configSoftwareAutomations.integrations.zendesk.map(
|
|
|
|
|
(integration) => {
|
|
|
|
|
return {
|
|
|
|
|
...integration,
|
|
|
|
|
enable_software_vulnerabilities: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
configSoftwareAutomations.integrations.zendesk = disableAllZendesk;
|
2022-04-11 19:04:41 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2022-05-11 02:33:30 +00:00
|
|
|
if (!integrationEnabled) {
|
2022-04-11 19:04:41 +00:00
|
|
|
if (!validUrl) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-05-11 02:33:30 +00:00
|
|
|
// set enable_vulnerabilities_webhook to true
|
|
|
|
|
// all jira.enable_software_vulnerabilities to false
|
|
|
|
|
// all zendesk.enable_software_vulnerabilities to false
|
2022-04-11 19:04:41 +00:00
|
|
|
configSoftwareAutomations.webhook_settings.vulnerabilities_webhook.enable_vulnerabilities_webhook = true;
|
|
|
|
|
const disableAllJira = configSoftwareAutomations.integrations.jira.map(
|
|
|
|
|
(integration) => {
|
|
|
|
|
return {
|
|
|
|
|
...integration,
|
|
|
|
|
enable_software_vulnerabilities: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
configSoftwareAutomations.integrations.jira = disableAllJira;
|
2022-05-11 02:33:30 +00:00
|
|
|
const disableAllZendesk = configSoftwareAutomations.integrations.zendesk.map(
|
|
|
|
|
(integration) => {
|
|
|
|
|
return {
|
|
|
|
|
...integration,
|
|
|
|
|
enable_software_vulnerabilities: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
configSoftwareAutomations.integrations.zendesk = disableAllZendesk;
|
2022-04-11 19:04:41 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2022-05-11 02:33:30 +00:00
|
|
|
// set enable_vulnerabilities_webhook to false
|
|
|
|
|
// all jira.enable_software_vulnerabilities to false
|
|
|
|
|
// all zendesk.enable_software_vulnerabilities to false
|
|
|
|
|
// except the one integration selected
|
2022-04-11 19:04:41 +00:00
|
|
|
configSoftwareAutomations.webhook_settings.vulnerabilities_webhook.enable_vulnerabilities_webhook = false;
|
|
|
|
|
const enableSelectedJiraIntegrationOnly = configSoftwareAutomations.integrations.jira.map(
|
|
|
|
|
(integration, index) => {
|
|
|
|
|
return {
|
|
|
|
|
...integration,
|
|
|
|
|
enable_software_vulnerabilities:
|
2022-05-11 02:33:30 +00:00
|
|
|
selectedIntegration?.type === "jira"
|
|
|
|
|
? index === selectedIntegration?.originalIndex
|
|
|
|
|
: false,
|
2022-04-11 19:04:41 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
configSoftwareAutomations.integrations.jira = enableSelectedJiraIntegrationOnly;
|
2022-05-11 02:33:30 +00:00
|
|
|
const enableSelectedZendeskIntegrationOnly = configSoftwareAutomations.integrations.zendesk.map(
|
|
|
|
|
(integration, index) => {
|
|
|
|
|
return {
|
|
|
|
|
...integration,
|
|
|
|
|
enable_software_vulnerabilities:
|
|
|
|
|
selectedIntegration?.type === "zendesk"
|
|
|
|
|
? index === selectedIntegration?.originalIndex
|
|
|
|
|
: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
configSoftwareAutomations.integrations.zendesk = enableSelectedZendeskIntegrationOnly;
|
2022-04-11 19:04:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateSoftwareAutomation();
|
|
|
|
|
onCreateWebhookSubmit(configSoftwareAutomations);
|
|
|
|
|
onReturnToApp();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const createIntegrationDropdownOptions = () => {
|
2022-05-11 02:33:30 +00:00
|
|
|
const integrationOptions = allIntegrationsIndexed?.map((i) => {
|
2022-04-11 19:04:41 +00:00
|
|
|
return {
|
2022-05-11 02:33:30 +00:00
|
|
|
value: String(i.dropdownIndex),
|
|
|
|
|
label: `${i.url} - ${i.project_key || i.group_id}`,
|
2022-04-11 19:04:41 +00:00
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
return integrationOptions;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onChangeSelectIntegration = (selectIntegrationIndex: string) => {
|
|
|
|
|
const integrationWithIndex:
|
2022-05-11 02:33:30 +00:00
|
|
|
| IIntegration
|
|
|
|
|
| undefined = allIntegrationsIndexed?.find(
|
|
|
|
|
(integ: IIntegration) =>
|
|
|
|
|
integ.dropdownIndex === parseInt(selectIntegrationIndex, 10)
|
2022-04-11 19:04:41 +00:00
|
|
|
);
|
|
|
|
|
setSelectedIntegration(integrationWithIndex);
|
|
|
|
|
};
|
|
|
|
|
|
2022-05-11 02:33:30 +00:00
|
|
|
const onRadioChange = (
|
|
|
|
|
enableIntegration: boolean
|
|
|
|
|
): ((evt: string) => void) => {
|
2022-04-11 19:04:41 +00:00
|
|
|
return () => {
|
2022-05-11 02:33:30 +00:00
|
|
|
setIntegrationEnabled(enableIntegration);
|
2022-04-11 19:04:41 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const renderTicket = () => {
|
|
|
|
|
return (
|
|
|
|
|
<div className={`${baseClass}__ticket`}>
|
|
|
|
|
<div className={`${baseClass}__software-automation-description`}>
|
|
|
|
|
<p>
|
|
|
|
|
A ticket will be created in your <b>Integration</b> if a detected
|
2022-04-13 18:45:50 +00:00
|
|
|
vulnerability (CVE) was published in the last{" "}
|
2022-10-19 19:00:39 +00:00
|
|
|
{recentVulnerabilityMaxAge ||
|
|
|
|
|
CONFIG_DEFAULT_RECENT_VULNERABILITY_MAX_AGE_IN_DAYS}{" "}
|
|
|
|
|
days.
|
2022-04-11 19:04:41 +00:00
|
|
|
</p>
|
|
|
|
|
</div>
|
2022-05-11 02:33:30 +00:00
|
|
|
{(jiraIntegrationsIndexed && jiraIntegrationsIndexed.length > 0) ||
|
|
|
|
|
(zendeskIntegrationsIndexed &&
|
|
|
|
|
zendeskIntegrationsIndexed.length > 0) ? (
|
2022-04-11 19:04:41 +00:00
|
|
|
<Dropdown
|
|
|
|
|
searchable
|
|
|
|
|
options={createIntegrationDropdownOptions()}
|
|
|
|
|
onChange={onChangeSelectIntegration}
|
2022-05-11 02:33:30 +00:00
|
|
|
placeholder={"Select integration"}
|
|
|
|
|
value={selectedIntegration?.dropdownIndex}
|
2022-04-11 19:04:41 +00:00
|
|
|
label={"Integration"}
|
|
|
|
|
wrapperClassName={`${baseClass}__form-field ${baseClass}__form-field--frequency`}
|
|
|
|
|
hint={
|
|
|
|
|
"For each new vulnerability detected, Fleet will create a ticket with a list of the affected hosts."
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<div className={`${baseClass}__no-integrations`}>
|
|
|
|
|
<div>
|
|
|
|
|
<b>You have no integrations.</b>
|
|
|
|
|
</div>
|
|
|
|
|
<div className={`${baseClass}__no-integration--cta`}>
|
|
|
|
|
<Link
|
|
|
|
|
to={PATHS.ADMIN_INTEGRATIONS}
|
|
|
|
|
className={`${baseClass}__add-integration-link`}
|
|
|
|
|
>
|
2022-09-02 19:28:42 +00:00
|
|
|
Add integration
|
2022-04-11 19:04:41 +00:00
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2022-10-14 19:26:15 +00:00
|
|
|
{!!selectedIntegration && (
|
|
|
|
|
<Button
|
|
|
|
|
type="button"
|
|
|
|
|
variant="text-link"
|
|
|
|
|
onClick={togglePreviewTicketModal}
|
|
|
|
|
>
|
|
|
|
|
Preview ticket
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
2022-04-11 19:04:41 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const renderWebhook = () => {
|
|
|
|
|
return (
|
|
|
|
|
<div className={`${baseClass}__webhook`}>
|
|
|
|
|
<div className={`${baseClass}__software-automation-description`}>
|
|
|
|
|
<p>
|
|
|
|
|
A request will be sent to your configured <b>Destination URL</b> if
|
2022-04-13 18:45:50 +00:00
|
|
|
a detected vulnerability (CVE) was published in the last{" "}
|
|
|
|
|
{recentVulnerabilityMaxAge || "30"} days.
|
2022-04-11 19:04:41 +00:00
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<InputField
|
|
|
|
|
inputWrapperClass={`${baseClass}__url-input`}
|
|
|
|
|
name="webhook-url"
|
|
|
|
|
label={"Destination URL"}
|
|
|
|
|
type={"text"}
|
2022-04-13 22:23:09 +00:00
|
|
|
value={destinationUrl}
|
2022-04-11 19:04:41 +00:00
|
|
|
onChange={onURLChange}
|
|
|
|
|
error={errors.url}
|
|
|
|
|
hint={
|
|
|
|
|
"For each new vulnerability detected, Fleet will send a JSON payload to this URL with a list of the affected hosts."
|
|
|
|
|
}
|
|
|
|
|
placeholder={"https://server.com/example"}
|
|
|
|
|
tooltip="Provide a URL to deliver a webhook request to."
|
|
|
|
|
/>
|
|
|
|
|
<Button
|
|
|
|
|
type="button"
|
|
|
|
|
variant="text-link"
|
|
|
|
|
onClick={togglePreviewPayloadModal}
|
|
|
|
|
>
|
|
|
|
|
Preview payload
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2022-02-05 00:48:35 +00:00
|
|
|
};
|
|
|
|
|
|
2022-10-14 19:26:15 +00:00
|
|
|
if (showPreviewTicketModal && selectedIntegration?.type) {
|
|
|
|
|
return (
|
|
|
|
|
<PreviewTicketModal
|
|
|
|
|
integrationType={selectedIntegration.type}
|
|
|
|
|
onCancel={togglePreviewTicketModal}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 00:48:35 +00:00
|
|
|
if (showPreviewPayloadModal) {
|
|
|
|
|
return <PreviewPayloadModal onCancel={togglePreviewPayloadModal} />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal
|
|
|
|
|
onExit={onReturnToApp}
|
|
|
|
|
title={"Manage automations"}
|
|
|
|
|
className={baseClass}
|
|
|
|
|
>
|
|
|
|
|
<div className={baseClass}>
|
|
|
|
|
<div className={`${baseClass}__software-select-items`}>
|
2022-03-11 17:56:14 +00:00
|
|
|
<Slider
|
|
|
|
|
value={softwareAutomationsEnabled}
|
|
|
|
|
onChange={() =>
|
|
|
|
|
setSoftwareAutomationsEnabled(!softwareAutomationsEnabled)
|
2022-02-05 00:48:35 +00:00
|
|
|
}
|
2022-03-11 17:56:14 +00:00
|
|
|
inactiveText={"Vulnerability automations disabled"}
|
|
|
|
|
activeText={"Vulnerability automations enabled"}
|
2022-02-05 00:48:35 +00:00
|
|
|
/>
|
|
|
|
|
</div>
|
2022-03-11 17:56:14 +00:00
|
|
|
<div className={`${baseClass}__overlay-container`}>
|
|
|
|
|
<div className={`${baseClass}__software-automation-enabled`}>
|
2022-04-11 19:04:41 +00:00
|
|
|
<div className={`${baseClass}__workflow`}>
|
|
|
|
|
Workflow
|
|
|
|
|
<Radio
|
|
|
|
|
className={`${baseClass}__radio-input`}
|
|
|
|
|
label={"Ticket"}
|
|
|
|
|
id={"ticket-radio-btn"}
|
2022-05-11 02:33:30 +00:00
|
|
|
checked={integrationEnabled}
|
2022-04-11 19:04:41 +00:00
|
|
|
value={"ticket"}
|
|
|
|
|
name={"ticket"}
|
|
|
|
|
onChange={onRadioChange(true)}
|
|
|
|
|
/>
|
|
|
|
|
<Radio
|
|
|
|
|
className={`${baseClass}__radio-input`}
|
|
|
|
|
label={"Webhook"}
|
|
|
|
|
id={"webhook-radio-btn"}
|
2022-05-11 02:33:30 +00:00
|
|
|
checked={!integrationEnabled}
|
2022-04-11 19:04:41 +00:00
|
|
|
value={"webhook"}
|
|
|
|
|
name={"webhook"}
|
|
|
|
|
onChange={onRadioChange(false)}
|
|
|
|
|
/>
|
2022-03-11 17:56:14 +00:00
|
|
|
</div>
|
2022-05-11 02:33:30 +00:00
|
|
|
{integrationEnabled ? renderTicket() : renderWebhook()}
|
2022-03-11 17:56:14 +00:00
|
|
|
</div>
|
|
|
|
|
{!softwareAutomationsEnabled && (
|
|
|
|
|
<div className={`${baseClass}__overlay`} />
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2022-04-27 20:40:28 +00:00
|
|
|
<div className="modal-cta-wrap">
|
2022-04-13 22:23:09 +00:00
|
|
|
<div
|
|
|
|
|
data-tip
|
|
|
|
|
data-for="save-automation-button"
|
|
|
|
|
data-tip-disable={
|
|
|
|
|
!(
|
2022-05-11 02:33:30 +00:00
|
|
|
((jiraIntegrationsIndexed &&
|
|
|
|
|
jiraIntegrationsIndexed.length === 0) ||
|
|
|
|
|
(zendeskIntegrationsIndexed &&
|
|
|
|
|
zendeskIntegrationsIndexed.length === 0)) &&
|
|
|
|
|
integrationEnabled &&
|
2022-04-13 22:23:09 +00:00
|
|
|
softwareAutomationsEnabled
|
|
|
|
|
)
|
|
|
|
|
}
|
2022-02-05 00:48:35 +00:00
|
|
|
>
|
2022-04-13 22:23:09 +00:00
|
|
|
<Button
|
|
|
|
|
type="submit"
|
|
|
|
|
variant="brand"
|
|
|
|
|
onClick={handleSaveAutomation}
|
|
|
|
|
disabled={
|
|
|
|
|
(softwareAutomationsEnabled &&
|
2022-05-11 02:33:30 +00:00
|
|
|
integrationEnabled &&
|
2022-04-13 22:23:09 +00:00
|
|
|
!selectedIntegration) ||
|
|
|
|
|
(softwareAutomationsEnabled &&
|
2022-05-11 02:33:30 +00:00
|
|
|
!integrationEnabled &&
|
2022-04-13 22:23:09 +00:00
|
|
|
destinationUrl === "")
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
Save
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<ReactTooltip
|
|
|
|
|
className={`save-automation-button-tooltip`}
|
|
|
|
|
place="bottom"
|
|
|
|
|
effect="solid"
|
|
|
|
|
backgroundColor="#3e4771"
|
|
|
|
|
id="save-automation-button"
|
|
|
|
|
data-html
|
|
|
|
|
>
|
2022-07-15 19:10:35 +00:00
|
|
|
<>
|
|
|
|
|
Add an integration to create
|
|
|
|
|
<br /> tickets for vulnerability automations.
|
|
|
|
|
</>
|
2022-04-13 22:23:09 +00:00
|
|
|
</ReactTooltip>
|
2022-08-29 15:21:37 +00:00
|
|
|
<Button onClick={onReturnToApp} variant="inverse">
|
|
|
|
|
Cancel
|
|
|
|
|
</Button>
|
2022-02-05 00:48:35 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ManageAutomationsModal;
|