Loads of frontend fixes related to React & MUI
This commit is contained in:
@@ -3381,11 +3381,10 @@ Let me know if you're interested, or set up a call here: https://drift.me/${user
|
||||
<ListItemText
|
||||
style={{ maxWidth: 200, minWidth: 200 }}
|
||||
primary={
|
||||
schedule.environment === "cloud" ? (
|
||||
schedule.environment === "cloud" || schedule.environment === "" || schedule.frequency.length > 0 ?
|
||||
schedule.frequency
|
||||
) : (
|
||||
:
|
||||
<span>{schedule.seconds} seconds</span>
|
||||
)
|
||||
}
|
||||
/>
|
||||
<ListItemText
|
||||
@@ -3399,14 +3398,14 @@ Let me know if you're interested, or set up a call here: https://drift.me/${user
|
||||
style={{ textDecoration: "none", color: "#f85a3e" }}
|
||||
href={`/workflows/${schedule.workflow_id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{schedule.workflow_id}
|
||||
</a>
|
||||
}
|
||||
/>
|
||||
<ListItemText
|
||||
primary={schedule.argument}
|
||||
primary={schedule.argument.replaceAll('\\\"', '\"')}
|
||||
style={{
|
||||
minWidth: 300,
|
||||
maxWidth: 300,
|
||||
|
||||
+1455
-545
File diff suppressed because it is too large
Load Diff
+107
-115
@@ -196,8 +196,9 @@ const parseCurl = (s) => {
|
||||
case "data":
|
||||
if (out.method === "GET" || out.method === "HEAD")
|
||||
out.method = "POST";
|
||||
out.header["Content-Type"] =
|
||||
out.header["Content-Type"] || "application/x-www-form-urlencoded";
|
||||
|
||||
out.header["Content-Type"] = out.header["Content-Type"] || "application/x-www-form-urlencoded";
|
||||
|
||||
out.body = out.body ? out.body + "&" + arg : arg;
|
||||
state = "";
|
||||
break;
|
||||
@@ -223,52 +224,52 @@ const parseCurl = (s) => {
|
||||
|
||||
// Basically CRUD for each category + special
|
||||
export const appCategories = [
|
||||
{
|
||||
"name": "Communication",
|
||||
"color": "#FFC107",
|
||||
"icon": "communication",
|
||||
"action_labels": ["List Messages", "Send Message", "Get Message", "Search messages"],
|
||||
}, {
|
||||
"name": "SIEM",
|
||||
"color": "#FFC107",
|
||||
"icon": "siem",
|
||||
"action_labels": ["Search", "List Alerts", "Close Alert", "Create detection", "Add to lookup list",],
|
||||
}, {
|
||||
"name": "Eradication",
|
||||
"color": "#FFC107",
|
||||
"icon": "eradication",
|
||||
"action_labels": ["List Alerts", "Close Alert", "Create detection", "Block hash", "Search Hosts", "Isolate host", "Unisolate host"],
|
||||
}, {
|
||||
"name": "Cases",
|
||||
"color": "#FFC107",
|
||||
"icon": "cases",
|
||||
"action_labels": ["List tickets", "Get ticket", "Create ticket", "Close ticket", "Add comment", "Update ticket",],
|
||||
}, {
|
||||
"name": "Assets",
|
||||
"color": "#FFC107",
|
||||
"icon": "assets",
|
||||
"action_labels": ["List Assets", "Get Asset", "Search Assets", "Search Users", "Search endpoints", "Search vulnerabilities"],
|
||||
}, {
|
||||
"name": "Intel",
|
||||
"color": "#FFC107",
|
||||
"icon": "intel",
|
||||
"action_labels": ["Get IOC", "Search IOC", "Create IOC", "Update IOC", "Delete IOC",],
|
||||
}, {
|
||||
"name": "IAM",
|
||||
"color": "#FFC107",
|
||||
"icon": "iam",
|
||||
"action_labels": ["Reset Password", "Enable user", "Disable user", "Get Identity", "Get Asset", "Search Identity", ],
|
||||
}, {
|
||||
"name": "Network",
|
||||
"color": "#FFC107",
|
||||
"icon": "network",
|
||||
"action_labels": ["Get Rules", "Allow IP", "Block IP",],
|
||||
}, {
|
||||
"name": "Other",
|
||||
"color": "#FFC107",
|
||||
"icon": "other",
|
||||
"action_labels": ["Update Info", "Get Info", "Get Status", "Get Version", "Get Health", "Get Config", "Get Configs", "Get Configs by type", "Get Configs by name", "Run script"],
|
||||
},
|
||||
{
|
||||
"name": "Communication",
|
||||
"color": "#FFC107",
|
||||
"icon": "communication",
|
||||
"action_labels": ["List Messages", "Send Message", "Get Message", "Search messages", "List Attachments", "Get Attachment", "Get Contact"],
|
||||
}, {
|
||||
"name": "SIEM",
|
||||
"color": "#FFC107",
|
||||
"icon": "siem",
|
||||
"action_labels": ["Search", "List Alerts", "Close Alert", "Get Alert", "Create detection", "Add to lookup list",],
|
||||
}, {
|
||||
"name": "Eradication",
|
||||
"color": "#FFC107",
|
||||
"icon": "eradication",
|
||||
"action_labels": ["List Alerts", "Close Alert", "Get Alert", "Create detection", "Block hash", "Search Hosts", "Isolate host", "Unisolate host"],
|
||||
}, {
|
||||
"name": "Cases",
|
||||
"color": "#FFC107",
|
||||
"icon": "cases",
|
||||
"action_labels": ["List tickets", "Get ticket", "Create ticket", "Close ticket", "Add comment", "Update ticket", "Search tickets"],
|
||||
}, {
|
||||
"name": "Assets",
|
||||
"color": "#FFC107",
|
||||
"icon": "assets",
|
||||
"action_labels": ["List Assets", "Get Asset", "Search Assets", "Search Users", "Search endpoints", "Search vulnerabilities"],
|
||||
}, {
|
||||
"name": "Intel",
|
||||
"color": "#FFC107",
|
||||
"icon": "intel",
|
||||
"action_labels": ["Get IOC", "Search IOC", "Create IOC", "Update IOC", "Delete IOC",],
|
||||
}, {
|
||||
"name": "IAM",
|
||||
"color": "#FFC107",
|
||||
"icon": "iam",
|
||||
"action_labels": ["Reset Password", "Enable user", "Disable user", "Get Identity", "Get Asset", "Search Identity", ],
|
||||
}, {
|
||||
"name": "Network",
|
||||
"color": "#FFC107",
|
||||
"icon": "network",
|
||||
"action_labels": ["Get Rules", "Allow IP", "Block IP",],
|
||||
}, {
|
||||
"name": "Other",
|
||||
"color": "#FFC107",
|
||||
"icon": "other",
|
||||
"action_labels": ["Update Info", "Get Info", "Get Status", "Get Version", "Get Health", "Get Config", "Get Configs", "Get Configs by type", "Get Configs by name", "Run script"],
|
||||
},
|
||||
]
|
||||
|
||||
export const base64_decode = (str) => {
|
||||
@@ -570,11 +571,11 @@ const AppCreator = (defaultprops) => {
|
||||
|
||||
if (data.openapi === null) {
|
||||
toast("Failed to load OpenAPI for app. Please contact support if this persists.")
|
||||
setIsAppLoaded(true);
|
||||
setIsAppLoaded(true);
|
||||
return
|
||||
}
|
||||
|
||||
console.log("Decoded: ", parsedDecoded)
|
||||
//console.log("Decoded: ", parsedDecoded)
|
||||
const parsedapp =
|
||||
data.openapi === undefined || data.openapi === null
|
||||
? data
|
||||
@@ -719,9 +720,9 @@ const AppCreator = (defaultprops) => {
|
||||
var newActions = [];
|
||||
var wordlist = {};
|
||||
var all_categories = [];
|
||||
var parentUrl = ""
|
||||
var parentUrl = ""
|
||||
|
||||
console.log("Paths: ", data.paths)
|
||||
console.log("Paths: ", data.paths)
|
||||
if (data.paths !== null && data.paths !== undefined) {
|
||||
for (let [path, pathvalue] of Object.entries(data.paths)) {
|
||||
|
||||
@@ -751,45 +752,44 @@ const AppCreator = (defaultprops) => {
|
||||
tmpname = methodvalue.operationId;
|
||||
}
|
||||
|
||||
if (tmpname !== undefined && tmpname !== null) {
|
||||
tmpname = tmpname.replaceAll(".", " ");
|
||||
}
|
||||
if (tmpname !== undefined && tmpname !== null) {
|
||||
tmpname = tmpname.replaceAll(".", " ");
|
||||
}
|
||||
|
||||
if ((tmpname === undefined || tmpname === null) && methodvalue.description !== undefined && methodvalue.description !== null && methodvalue.description.length > 0) {
|
||||
tmpname = methodvalue.description.replaceAll(".", " ").replaceAll("_", " ")
|
||||
}
|
||||
if ((tmpname === undefined || tmpname === null) && methodvalue.description !== undefined && methodvalue.description !== null && methodvalue.description.length > 0) {
|
||||
tmpname = methodvalue.description.replaceAll(".", " ").replaceAll("_", " ")
|
||||
}
|
||||
|
||||
var newaction = {
|
||||
name: tmpname,
|
||||
description: methodvalue.description,
|
||||
url: path,
|
||||
file_field: "",
|
||||
method: method.toUpperCase(),
|
||||
headers: "",
|
||||
queries: [],
|
||||
paths: [],
|
||||
body: "",
|
||||
errors: [],
|
||||
example_response: "",
|
||||
action_label: "No Label",
|
||||
required_bodyfields: [],
|
||||
};
|
||||
var newaction = {
|
||||
name: tmpname,
|
||||
description: methodvalue.description,
|
||||
url: path,
|
||||
file_field: "",
|
||||
method: method.toUpperCase(),
|
||||
headers: "",
|
||||
queries: [],
|
||||
paths: [],
|
||||
body: "",
|
||||
errors: [],
|
||||
example_response: "",
|
||||
action_label: "No Label",
|
||||
required_bodyfields: [],
|
||||
};
|
||||
|
||||
if (methodvalue["x-label"] !== undefined && methodvalue["x-label"] !== null) {
|
||||
// FIX: Map labels only if they're actually in the category list
|
||||
newaction.action_label = methodvalue["x-label"]
|
||||
}
|
||||
if (methodvalue["x-label"] !== undefined && methodvalue["x-label"] !== null) {
|
||||
// FIX: Map labels only if they're actually in the category list
|
||||
newaction.action_label = methodvalue["x-label"]
|
||||
}
|
||||
|
||||
if (methodvalue["x-required-fields"] !== undefined && methodvalue["x-required-fields"] !== null) {
|
||||
newaction.required_bodyfields = methodvalue["x-required-fields"]
|
||||
}
|
||||
if (methodvalue["x-required-fields"] !== undefined && methodvalue["x-required-fields"] !== null) {
|
||||
newaction.required_bodyfields = methodvalue["x-required-fields"]
|
||||
}
|
||||
|
||||
if (newaction.url !== undefined && newaction.url !== null && newaction.url.includes("_shuffle_replace_")) {
|
||||
const regex = /_shuffle_replace_\d/i;
|
||||
//console.log("NEW: ",
|
||||
newaction.url = newaction.url.replaceAll(new RegExp(regex, 'g'), "")
|
||||
console.log("Replaced: ", newaction.url)
|
||||
}
|
||||
if (newaction.url !== undefined && newaction.url !== null && newaction.url.includes("_shuffle_replace_")) {
|
||||
const regex = /_shuffle_replace_\d/i;
|
||||
//console.log("NEW: ",
|
||||
newaction.url = newaction.url.replaceAll(new RegExp(regex, 'g'), "")
|
||||
}
|
||||
|
||||
// Finding category
|
||||
if (path.includes("/")) {
|
||||
@@ -1110,19 +1110,11 @@ const AppCreator = (defaultprops) => {
|
||||
undefined
|
||||
) {
|
||||
if (
|
||||
methodvalue.responses.default.content["text/plain"][
|
||||
"schema"
|
||||
] !== undefined
|
||||
) {
|
||||
if (
|
||||
methodvalue.responses.default.content["text/plain"][
|
||||
"schema"
|
||||
]["example"] !== undefined
|
||||
) {
|
||||
newaction.example_response =
|
||||
methodvalue.responses.default.content["text/plain"][
|
||||
"schema"
|
||||
]["example"]
|
||||
methodvalue.responses.default.content["text/plain"]["schema"] !== undefined) {
|
||||
if (methodvalue.responses.default.content["text/plain"]["schema"]["example"] !== undefined) {
|
||||
newaction.example_response = methodvalue.responses.default.content["text/plain"]["schema"]["example"]
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1560,12 +1552,12 @@ const AppCreator = (defaultprops) => {
|
||||
|
||||
if (securitySchemes !== undefined) {
|
||||
|
||||
console.log("SECURITY: ", securitySchemes)
|
||||
var newauth = [];
|
||||
try {
|
||||
var optionset = false
|
||||
//console.log("SECURITY: ", securitySchemes)
|
||||
var newauth = [];
|
||||
try {
|
||||
var optionset = false
|
||||
for (const [key, value] of Object.entries(securitySchemes)) {
|
||||
console.log("AUTH: ", key, value);
|
||||
//console.log("AUTH: ", key, value);
|
||||
|
||||
if (key === "jwt") {
|
||||
setAuthenticationOption("JWT");
|
||||
@@ -1776,12 +1768,12 @@ const AppCreator = (defaultprops) => {
|
||||
if (!found) {
|
||||
newActions2.push(action)
|
||||
} else {
|
||||
console.log("NOT skipping duplicate action: ", action.url, ". Should merge contents")
|
||||
//console.log("NOT skipping duplicate action: ", action.url, ". Should merge contents")
|
||||
newActions2.push(action)
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Actions: ", newActions.length, " Actions2: ", newActions2.length)
|
||||
//console.log("Actions: ", newActions.length, " Actions2: ", newActions2.length)
|
||||
newActions = newActions2
|
||||
if (newActions.length > increaseAmount - 1) {
|
||||
setActionAmount(increaseAmount);
|
||||
@@ -3880,7 +3872,7 @@ const AppCreator = (defaultprops) => {
|
||||
|
||||
const datasplit = parsedurlsplit[1].split("&")
|
||||
for (var key in datasplit) {
|
||||
console.log("Data: ", datasplit[key])
|
||||
//console.log("Data: ", datasplit[key])
|
||||
var actualkey = datasplit[key]
|
||||
var example = ""
|
||||
if (datasplit[key].includes("=")) {
|
||||
@@ -4143,7 +4135,7 @@ const AppCreator = (defaultprops) => {
|
||||
overflowX: "hidden",
|
||||
}}
|
||||
onClick={() => {
|
||||
console.log("Data: ", data)
|
||||
//console.log("Data: ", data)
|
||||
if (hasFile) {
|
||||
//setActionField("headers", "")
|
||||
//console.log("It has a file: ", data["file_field"])
|
||||
@@ -4321,9 +4313,9 @@ const AppCreator = (defaultprops) => {
|
||||
}
|
||||
|
||||
const LoopActions = (props) => {
|
||||
const { filteredActions } = props;
|
||||
const { filteredActions } = props;
|
||||
|
||||
console.log("Actions: ", filteredActions)
|
||||
//console.log("Actions: ", filteredActions)
|
||||
if (filteredActions === null || filteredActions === undefined || filteredActions.length === 0) {
|
||||
return null
|
||||
}
|
||||
@@ -4745,7 +4737,7 @@ const AppCreator = (defaultprops) => {
|
||||
}
|
||||
|
||||
const handleSubmitCheck = () => {
|
||||
console.log("NEW AUTH: ", authenticationOption);
|
||||
//console.log("NEW AUTH: ", authenticationOption);
|
||||
if (authenticationOption.label.length === 0) {
|
||||
authenticationOption.label = `Auth for ${selectedApp.name}`;
|
||||
//toast("Label can't be empty")
|
||||
@@ -4968,10 +4960,10 @@ const AppCreator = (defaultprops) => {
|
||||
{projectCategories.map((tag, index) => {
|
||||
const newname = tag.charAt(0).toUpperCase() + tag.slice(1);
|
||||
|
||||
//var regex = /_shuffle_replace_\d/i;
|
||||
////console.log("NEW: ",
|
||||
//newname = newname.replaceAll(regex, "")
|
||||
//console.log("Replaced: ", newname)
|
||||
//var regex = /_shuffle_replace_\d/i;
|
||||
////console.log("NEW: ",
|
||||
//newname = newname.replaceAll(regex, "")
|
||||
//console.log("Replaced: ", newname)
|
||||
|
||||
return (
|
||||
<Chip
|
||||
|
||||
+32
-14
@@ -391,19 +391,28 @@ const Docs = (defaultprops) => {
|
||||
}
|
||||
|
||||
function CodeHandler(props) {
|
||||
console.log("PROPS: ", props)
|
||||
|
||||
const propvalue = props.value !== undefined && props.value !== null ? props.value : props.children !== undefined && props.children !== null && props.children.length > 0 ? props.children[0] : ""
|
||||
|
||||
return (
|
||||
<pre
|
||||
<div
|
||||
style={{
|
||||
padding: 15,
|
||||
minWidth: "50%",
|
||||
maxWidth: "100%",
|
||||
backgroundColor: theme.palette.inputColor,
|
||||
overflowX: "auto",
|
||||
overflowY: "hidden",
|
||||
overflowY: "auto",
|
||||
}}
|
||||
>
|
||||
<code>{props.value}</code>
|
||||
</pre>
|
||||
<code
|
||||
style={{
|
||||
// Wrap if larger than X
|
||||
whiteSpace: "pre-wrap",
|
||||
overflow: "auto",
|
||||
}}
|
||||
>{propvalue}</code>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -436,7 +445,7 @@ const Docs = (defaultprops) => {
|
||||
href={selectedMeta.link}
|
||||
style={{ textDecoration: "none", color: "#f85a3e" }}
|
||||
>
|
||||
<Button style={{}} variant="outlined" color="secondary">
|
||||
<Button style={{color: "white", }} variant="outlined" color="secondary">
|
||||
<EditIcon /> Edit
|
||||
</Button>
|
||||
</a>
|
||||
@@ -638,7 +647,7 @@ const Docs = (defaultprops) => {
|
||||
|
||||
<Typography variant="h6" style={headerStyle}>Why Shuffle?</Typography>
|
||||
<Typography variant="body1">
|
||||
<b>Security first.</b> We incentivize trying before buying, and give you the full set of tools you need to automate your operations. What's more is we also help you <a href="https://shuffler.io/pricing?tag=docs" target="_blank" style={hrefStyle2}>find usecases</a> that fit your your unique needs. Accessibility is key, and we intend to help every SOC globally use and share their usecases.
|
||||
<b>Security first.</b> We incentivize trying before buying, and give you the full set of tools you need to automate your operations. What's more is we also help you <a href="https://shuffler.io/pricing?tag=docs" target="_blank" style={hrefStyle2}>find usecases</a> that fit your unique needs. Accessibility is key, and we intend to help every SOC globally use and share their usecases.
|
||||
</Typography>
|
||||
|
||||
<Typography variant="h6" style={headerStyle}>Get help</Typography>
|
||||
@@ -878,16 +887,25 @@ const Docs = (defaultprops) => {
|
||||
:
|
||||
<div id="markdown_wrapper_outer" style={markdownStyle}>
|
||||
<ReactMarkdown
|
||||
components={{
|
||||
img: Img,
|
||||
code: CodeHandler,
|
||||
h1: Heading,
|
||||
h2: Heading,
|
||||
h3: Heading,
|
||||
h4: Heading,
|
||||
h5: Heading,
|
||||
h6: Heading,
|
||||
a: OuterLink,
|
||||
}}
|
||||
id="markdown_wrapper"
|
||||
escapeHtml={false}
|
||||
source={data}
|
||||
renderers={{
|
||||
link: OuterLink,
|
||||
image: Img,
|
||||
code: CodeHandler,
|
||||
heading: Heading,
|
||||
style={{
|
||||
maxWidth: "100%", minWidth: "100%",
|
||||
}}
|
||||
/>
|
||||
>
|
||||
{data}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
}
|
||||
<Divider
|
||||
|
||||
@@ -66,10 +66,10 @@ const RunWorkflow = (defaultprops) => {
|
||||
marginBottom: 150,
|
||||
}
|
||||
|
||||
const params = useParams();
|
||||
var props = JSON.parse(JSON.stringify(defaultprops))
|
||||
props.match = {}
|
||||
props.match.params = params
|
||||
const params = useParams();
|
||||
var props = JSON.parse(JSON.stringify(defaultprops))
|
||||
props.match = {}
|
||||
props.match.params = params
|
||||
|
||||
const defaultTitle = "Run Workflow"
|
||||
if (document != undefined && document.title != defaultTitle) {
|
||||
@@ -126,12 +126,14 @@ const RunWorkflow = (defaultprops) => {
|
||||
}
|
||||
|
||||
const executionMargin = 20
|
||||
const defaultReturn =
|
||||
const defaultReturn = null
|
||||
/*
|
||||
<div style={{marginTop: executionMargin, }}>
|
||||
<Typography variant="h6" style={{color: theme.palette.primaryColor}}>
|
||||
No results yet
|
||||
</Typography>
|
||||
</div>
|
||||
*/
|
||||
|
||||
if (executionData.results === undefined || executionData.results === null) {
|
||||
return defaultReturn
|
||||
@@ -271,7 +273,7 @@ const RunWorkflow = (defaultprops) => {
|
||||
width: 30,
|
||||
}}
|
||||
onClick={() => {
|
||||
navigate(`?execution_highlight=${parsed_url}`)
|
||||
//navigate(`?execution_highlight=${parsed_url}`)
|
||||
}}
|
||||
>
|
||||
<PreviewIcon style={{ color: "rgba(255,255,255,0.5)" }} />
|
||||
@@ -314,10 +316,16 @@ const RunWorkflow = (defaultprops) => {
|
||||
)
|
||||
}
|
||||
|
||||
const onSubmit = (execution_id, authorization, answer) => {
|
||||
const onSubmit = (event, execution_id, authorization, answer) => {
|
||||
if (event !== null) {
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
console.log("In submit!")
|
||||
|
||||
stop()
|
||||
setMessage("")
|
||||
setExecutionLoading(true)
|
||||
setMessage("")
|
||||
setExecutionLoading(true)
|
||||
setExecutionData({})
|
||||
setExecutionInfo("")
|
||||
|
||||
@@ -327,13 +335,13 @@ const RunWorkflow = (defaultprops) => {
|
||||
|
||||
var url = `${globalUrl}/api/v1/workflows/${props.match.params.key}/execute`
|
||||
var fetchBody = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
mode: 'cors',
|
||||
credentials: 'include',
|
||||
crossDomain: true,
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
}
|
||||
|
||||
if (answer !== undefined && execution_id !== undefined && authorization !== undefined) {
|
||||
@@ -345,8 +353,10 @@ const RunWorkflow = (defaultprops) => {
|
||||
fetchBody.body = JSON.stringify(data)
|
||||
}
|
||||
|
||||
console.log("Pre request: ", url, fetchBody)
|
||||
fetch(url, fetchBody)
|
||||
.then((response) => {
|
||||
console.log("Got answer 1")
|
||||
if (response.status !== 200 && response.status !== 201) {
|
||||
|
||||
if (answer !== undefined && execution_id !== undefined && authorization !== undefined) {
|
||||
@@ -362,9 +372,11 @@ const RunWorkflow = (defaultprops) => {
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Got answer 2")
|
||||
return response.json();
|
||||
})
|
||||
.then(responseJson => {
|
||||
console.log("Got answer 3")
|
||||
setExecutionLoading(false)
|
||||
if (responseJson["success"] === false) {
|
||||
console.log("Failed sending execution request")
|
||||
@@ -379,6 +391,7 @@ const RunWorkflow = (defaultprops) => {
|
||||
start();
|
||||
}
|
||||
}
|
||||
console.log("Got answer 4")
|
||||
})
|
||||
.catch(error => {
|
||||
//setExecutionInfo("Error in workflow startup: " + error)
|
||||
@@ -387,14 +400,14 @@ const RunWorkflow = (defaultprops) => {
|
||||
}
|
||||
|
||||
const getWorkflow = (workflow_id) => {
|
||||
fetch(globalUrl + "/api/v1/workflows/" + workflow_id, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
credentials: "include",
|
||||
})
|
||||
fetch(globalUrl + "/api/v1/workflows/" + workflow_id, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status !== 200) {
|
||||
console.log("Status not 200 for workflows :O!");
|
||||
@@ -441,35 +454,35 @@ const RunWorkflow = (defaultprops) => {
|
||||
return
|
||||
}
|
||||
|
||||
console.log("Got response: ", responseJson)
|
||||
//console.log("Got response: ", responseJson)
|
||||
|
||||
ReactDOM.unstable_batchedUpdates(() => {
|
||||
if (JSON.stringify(responseJson) !== JSON.stringify(executionData)) {
|
||||
// FIXME: If another is selected, don't edit..
|
||||
// Doesn't work because this is some async garbage
|
||||
if (executionData.execution_id === undefined || (responseJson.execution_id === executionData.execution_id && responseJson.results !== undefined && responseJson.results !== null)) {
|
||||
if (executionData.status !== responseJson.status || executionData.result !== responseJson.result || (executionData.results !== undefined && responseJson.results !== null && executionData.results.length !== responseJson.results.length)) {
|
||||
console.log("Updating data!")
|
||||
setExecutionData(responseJson)
|
||||
ReactDOM.unstable_batchedUpdates(() => {
|
||||
if (JSON.stringify(responseJson) !== JSON.stringify(executionData)) {
|
||||
// FIXME: If another is selected, don't edit..
|
||||
// Doesn't work because this is some async garbage
|
||||
if (executionData.execution_id === undefined || (responseJson.execution_id === executionData.execution_id && responseJson.results !== undefined && responseJson.results !== null)) {
|
||||
if (executionData.status !== responseJson.status || executionData.result !== responseJson.result || (executionData.results !== undefined && responseJson.results !== null && executionData.results.length !== responseJson.results.length)) {
|
||||
//console.log("Updating data!")
|
||||
setExecutionData(responseJson)
|
||||
|
||||
for (var key in responseJson.results) {
|
||||
if (responseJson.results[key].status === "WAITING") {
|
||||
console.log("Found: ", responseJson.results[key])
|
||||
|
||||
const validate = validateJson(responseJson.results[key].result)
|
||||
console.log("Validate: ", validate)
|
||||
if (validate.valid && typeof validate.result === "string") {
|
||||
validate.result = JSON.parse(validate.result)
|
||||
}
|
||||
for (var key in responseJson.results) {
|
||||
if (responseJson.results[key].status === "WAITING") {
|
||||
console.log("Found: ", responseJson.results[key])
|
||||
|
||||
const validate = validateJson(responseJson.results[key].result)
|
||||
console.log("Validate: ", validate)
|
||||
if (validate.valid && typeof validate.result === "string") {
|
||||
validate.result = JSON.parse(validate.result)
|
||||
}
|
||||
|
||||
console.log("Newresult: ", validate.result)
|
||||
if (validate.result["information"] !== undefined && validate.result["information"] !== null) {
|
||||
setWorkflowQuestion(validate.result["information"])
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
console.log("Newresult: ", validate.result)
|
||||
if (validate.result["information"] !== undefined && validate.result["information"] !== null) {
|
||||
setWorkflowQuestion(validate.result["information"])
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log("NOT updating executiondata state.");
|
||||
}
|
||||
@@ -518,9 +531,9 @@ const RunWorkflow = (defaultprops) => {
|
||||
if (responseJson.sync_features === undefined || responseJson.sync_features === null) {
|
||||
}
|
||||
|
||||
if (document != undefined && document.title != defaultTitle) {
|
||||
document.title = responseJson.name + " - " + defaultTitle
|
||||
}
|
||||
if (document != undefined && document.title != defaultTitle) {
|
||||
document.title = responseJson.name + " - " + defaultTitle
|
||||
}
|
||||
setSelectedOrganization(responseJson)
|
||||
}
|
||||
})
|
||||
@@ -530,6 +543,11 @@ const RunWorkflow = (defaultprops) => {
|
||||
};
|
||||
|
||||
const fetchUpdates = (execution_id, authorization, getorg) => {
|
||||
if (execution_id === undefined || execution_id === null || execution_id === "") {
|
||||
stop()
|
||||
return
|
||||
}
|
||||
|
||||
const innerRequest = {
|
||||
"execution_id": execution_id,
|
||||
"authorization": authorization
|
||||
@@ -594,7 +612,7 @@ const RunWorkflow = (defaultprops) => {
|
||||
const buttonBackground = "linear-gradient(to right, #f86a3e, #f34079)"
|
||||
const buttonStyle = {borderRadius: 25, height: 50, fontSize: 18, backgroundImage: handleValidateForm(executionArgument) || executionLoading ? buttonBackground : "grey", color: "white"}
|
||||
|
||||
console.log("execdata: ", executionData)
|
||||
//console.log("execdata: ", executionData)
|
||||
const disabledButtons = message.length > 0 || executionData.status === "FINISHED" || executionData.status === "ABORTED"
|
||||
|
||||
const organization = selectedOrganization !== undefined && selectedOrganization !== null ? selectedOrganization.name : "Unknown"
|
||||
@@ -603,7 +621,7 @@ const RunWorkflow = (defaultprops) => {
|
||||
|
||||
const image = selectedOrganization !== undefined && selectedOrganization !== null && selectedOrganization.image !== undefined && selectedOrganization.image !== null && selectedOrganization.image !== "" ? selectedOrganization.image : theme.palette.defaultImage
|
||||
|
||||
console.log("IMG: ", image, "ORG: ", selectedOrganization)
|
||||
//console.log("IMG: ", image, "ORG: ", selectedOrganization)
|
||||
|
||||
if (!disabledButtons && answer !== undefined && answer !== null && organization !== "Unknown" && buttonClicked.length === 0) {
|
||||
console.log("Finding button!")
|
||||
@@ -627,7 +645,7 @@ const RunWorkflow = (defaultprops) => {
|
||||
const basedata =
|
||||
<div style={bodyDivStyle}>
|
||||
<Paper style={boxStyle}>
|
||||
<form onSubmit={() => {onSubmit()}} style={{margin: "15px 15px 15px 15px"}}>
|
||||
<form onSubmit={(e) => {onSubmit(e)}} style={{margin: "15px 15px 15px 15px"}}>
|
||||
|
||||
<img
|
||||
alt={workflow.name}
|
||||
@@ -676,7 +694,7 @@ const RunWorkflow = (defaultprops) => {
|
||||
|
||||
{answer !== undefined && answer !== null ? null :
|
||||
<span>
|
||||
Execution Argument
|
||||
Runtime Argument
|
||||
<div style={{marginBottom: 5}}>
|
||||
<TextField
|
||||
color="primary"
|
||||
@@ -705,9 +723,12 @@ const RunWorkflow = (defaultprops) => {
|
||||
{executionRunning ?
|
||||
<span style={{width: 50, height: 50, margin: "auto", alignItems: "center", justifyContent: "center", textAlign: "center", }}>
|
||||
<CircularProgress style={{marginTop: 20, marginBottom: 20, marginLeft: 185, }}/>
|
||||
<Typography variant="body2" style={{margin: "auto", marginTop: 20, marginBottom: 20, textAlign: "center", alignItem: "center", }} color="textSecondary">
|
||||
Status: {executionData.status}
|
||||
</Typography>
|
||||
|
||||
{executionData.status !== undefined && executionData.status !== null && executionData.status !== "" ?
|
||||
<Typography variant="body2" style={{margin: "auto", marginTop: 20, marginBottom: 20, textAlign: "center", alignItem: "center", }} color="textSecondary">
|
||||
Status: {executionData.status}
|
||||
</Typography>
|
||||
: null}
|
||||
</span>
|
||||
|
||||
:
|
||||
@@ -723,7 +744,7 @@ const RunWorkflow = (defaultprops) => {
|
||||
}
|
||||
<div fullWidth style={{width: "100%", marginTop: 10, marginBottom: 10, display: "flex", }}>
|
||||
<Button fullWidth id="continue_execution" variant="contained" disabled={disabledButtons} color="primary" style={{border: answer === "true" ? "2px solid rgba(255,255,255,0.6)" : null, flex: 1,}} onClick={() => {
|
||||
onSubmit(execution_id, authorization, true)
|
||||
onSubmit(null, execution_id, authorization, true)
|
||||
|
||||
setButtonClicked("FINISHED")
|
||||
setExecutionData({
|
||||
@@ -734,7 +755,7 @@ const RunWorkflow = (defaultprops) => {
|
||||
or
|
||||
</Typography>
|
||||
<Button fullWidth id="abort_execution" variant="contained" color="primary" disabled={disabledButtons} style={{border: answer !== "true" ? "2px solid rgba(255,255,255,0.6)" : null, flex: 1, }} onClick={() => {
|
||||
onSubmit(execution_id, authorization, false)
|
||||
onSubmit(null, execution_id, authorization, false)
|
||||
|
||||
setButtonClicked("ABORTED")
|
||||
setExecutionData({
|
||||
|
||||
@@ -393,6 +393,9 @@ export const validateJson = (showResult) => {
|
||||
if (typeof showResult === 'string') {
|
||||
showResult = showResult.split(" False").join(" false")
|
||||
showResult = showResult.split(" True").join(" true")
|
||||
|
||||
showResult.replaceAll("False,", "false,")
|
||||
showResult.replaceAll("True,", "true,")
|
||||
}
|
||||
|
||||
if (typeof showResult === "object" || typeof showResult === "array") {
|
||||
@@ -1247,9 +1250,9 @@ const Workflows = (props) => {
|
||||
|
||||
//flexDirection: !isMobile ? "column" : "row",
|
||||
const paperAppContainer = {
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
alignContent: "space-between",
|
||||
//display: "flex",
|
||||
//flexWrap: "wrap",
|
||||
//alignContent: "space-between",
|
||||
};
|
||||
|
||||
const paperAppStyle = {
|
||||
@@ -1587,7 +1590,7 @@ const Workflows = (props) => {
|
||||
const NewWorkflowPaper = () => {
|
||||
const [hover, setHover] = React.useState(false);
|
||||
|
||||
const innerColor = "rgba(255,255,255,0.3)";
|
||||
const innerColor = "rgba(255,255,255,0.3)"
|
||||
const setupPaperStyle = {
|
||||
minHeight: paperAppStyle.minHeight,
|
||||
maxWidth: "100%",
|
||||
@@ -1609,9 +1612,9 @@ const Workflows = (props) => {
|
||||
square
|
||||
style={setupPaperStyle}
|
||||
onClick={() => {
|
||||
setModalOpen(true)
|
||||
setIsEditing(false)
|
||||
}}
|
||||
setModalOpen(true)
|
||||
setIsEditing(false)
|
||||
}}
|
||||
onMouseOver={() => {
|
||||
setHover(true);
|
||||
}}
|
||||
@@ -1682,7 +1685,7 @@ const Workflows = (props) => {
|
||||
}
|
||||
|
||||
const actions = data.actions !== null ? data.actions.length : 0;
|
||||
const appGroup = getWorkflowAppgroup(data)
|
||||
const appGroup = getWorkflowAppgroup(data)
|
||||
const [triggers, subflows] = getWorkflowMeta(data);
|
||||
|
||||
const workflowMenuButtons = (
|
||||
@@ -1699,22 +1702,22 @@ const Workflows = (props) => {
|
||||
<MenuItem
|
||||
style={{ backgroundColor: theme.palette.inputColor, color: "white" }}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation()
|
||||
ReactDOM.unstable_batchedUpdates(() => {
|
||||
setModalOpen(true);
|
||||
setEditingWorkflow(JSON.parse(JSON.stringify(data)));
|
||||
setNewWorkflowName(data.name);
|
||||
setNewWorkflowDescription(data.description);
|
||||
setDefaultReturnValue(data.default_return_value);
|
||||
if (data.tags !== undefined && data.tags !== null) {
|
||||
setNewWorkflowTags(JSON.parse(JSON.stringify(data.tags)));
|
||||
}
|
||||
event.stopPropagation()
|
||||
ReactDOM.unstable_batchedUpdates(() => {
|
||||
setModalOpen(true);
|
||||
setEditingWorkflow(JSON.parse(JSON.stringify(data)));
|
||||
setNewWorkflowName(data.name);
|
||||
setNewWorkflowDescription(data.description);
|
||||
setDefaultReturnValue(data.default_return_value);
|
||||
if (data.tags !== undefined && data.tags !== null) {
|
||||
setNewWorkflowTags(JSON.parse(JSON.stringify(data.tags)));
|
||||
}
|
||||
|
||||
if (data.usecase_ids !== undefined && data.usecase_ids !== null && data.usecase_ids.length > 0) {
|
||||
setSelectedUsecases(data.usecase_ids)
|
||||
}
|
||||
})
|
||||
}}
|
||||
if (data.usecase_ids !== undefined && data.usecase_ids !== null && data.usecase_ids.length > 0) {
|
||||
setSelectedUsecases(data.usecase_ids)
|
||||
}
|
||||
})
|
||||
}}
|
||||
key={"change"}
|
||||
>
|
||||
<EditIcon style={{ marginLeft: 0, marginRight: 8 }} />
|
||||
@@ -2122,18 +2125,18 @@ const Workflows = (props) => {
|
||||
: null}
|
||||
</Grid>
|
||||
{data.actions !== undefined && data.actions !== null ? (
|
||||
<div style={{position: "absolute", top: 10, right: 10, }}>
|
||||
<IconButton
|
||||
aria-label="more"
|
||||
aria-controls="long-menu"
|
||||
aria-haspopup="true"
|
||||
onClick={menuClick}
|
||||
style={{ padding: "0px", color: "#979797" }}
|
||||
>
|
||||
<MoreVertIcon />
|
||||
</IconButton>
|
||||
{workflowMenuButtons}
|
||||
</div>
|
||||
<div style={{position: "absolute", top: 10, right: 10, }}>
|
||||
<IconButton
|
||||
aria-label="more"
|
||||
aria-controls="long-menu"
|
||||
aria-haspopup="true"
|
||||
onClick={menuClick}
|
||||
style={{ padding: "0px", color: "#979797" }}
|
||||
>
|
||||
<MoreVertIcon />
|
||||
</IconButton>
|
||||
{workflowMenuButtons}
|
||||
</div>
|
||||
) : null}
|
||||
</Grid>
|
||||
</Paper>
|
||||
@@ -2180,13 +2183,13 @@ const Workflows = (props) => {
|
||||
workflowdata["default_return_value"] = defaultReturnValue;
|
||||
}
|
||||
|
||||
if (currentUsecases !== undefined && currentUsecases !== null) {
|
||||
workflowdata["usecase_ids"] = currentUsecases
|
||||
//workflows[0].category = ["detect"]
|
||||
//workflows[0].usecase_ids = ["Correlate tickets"]
|
||||
}
|
||||
if (currentUsecases !== undefined && currentUsecases !== null) {
|
||||
workflowdata["usecase_ids"] = currentUsecases
|
||||
//workflows[0].category = ["detect"]
|
||||
//workflows[0].usecase_ids = ["Correlate tickets"]
|
||||
}
|
||||
|
||||
const new_url = `${globalUrl}/api/v1/workflows${extraData}`
|
||||
const new_url = `${globalUrl}/api/v1/workflows${extraData}`
|
||||
return fetch(new_url, {
|
||||
method: method,
|
||||
headers: {
|
||||
@@ -2206,16 +2209,16 @@ const Workflows = (props) => {
|
||||
return response.json();
|
||||
})
|
||||
.then((responseJson) => {
|
||||
if (responseJson.success === false) {
|
||||
if (responseJson.reason !== undefined) {
|
||||
toast("Error setting workflow: ", responseJson.reason)
|
||||
} else {
|
||||
toast("Error setting workflow.")
|
||||
}
|
||||
|
||||
return
|
||||
if (responseJson.success === false) {
|
||||
if (responseJson.reason !== undefined) {
|
||||
toast("Error setting workflow: ", responseJson.reason)
|
||||
} else {
|
||||
toast("Error setting workflow.")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (redirect) {
|
||||
//window.location.pathname = "/workflows/" + responseJson["id"];
|
||||
navigate("/workflows/" + responseJson["id"])
|
||||
@@ -2224,7 +2227,7 @@ const Workflows = (props) => {
|
||||
// Update :)
|
||||
setTimeout(() => {
|
||||
getAvailableWorkflows();
|
||||
}, 2500);
|
||||
}, 4000);
|
||||
setSubmitLoading(false)
|
||||
setModalOpen(false);
|
||||
} else {
|
||||
@@ -2244,7 +2247,7 @@ const Workflows = (props) => {
|
||||
|
||||
const importFiles = (event) => {
|
||||
console.log("Importing!");
|
||||
setSubmitLoading(true)
|
||||
setSubmitLoading(true)
|
||||
|
||||
if (event.target.files.length > 0) {
|
||||
console.log("Files: !", event.target.files.length);
|
||||
@@ -2281,9 +2284,9 @@ const Workflows = (props) => {
|
||||
data.default_return_value,
|
||||
{},
|
||||
false,
|
||||
[],
|
||||
"",
|
||||
data.status,
|
||||
[],
|
||||
"",
|
||||
data.status,
|
||||
)
|
||||
.then((response) => {
|
||||
if (response !== undefined) {
|
||||
@@ -2301,9 +2304,9 @@ const Workflows = (props) => {
|
||||
data.default_return_value,
|
||||
data,
|
||||
false,
|
||||
[],
|
||||
"",
|
||||
data.status,
|
||||
[],
|
||||
"",
|
||||
data.status,
|
||||
).then((response) => {
|
||||
if (response !== undefined) {
|
||||
toast("Successfully imported " + data.name);
|
||||
@@ -3239,14 +3242,18 @@ const Workflows = (props) => {
|
||||
fullWidth
|
||||
value={filters}
|
||||
onChange={(chips) => {
|
||||
console.log("CHANGE: ", chips);
|
||||
setFilters(chips);
|
||||
findWorkflow(chips);
|
||||
}}
|
||||
onAdd={(chip) => {
|
||||
addFilter(chip);
|
||||
}}
|
||||
onDelete={(_, index) => {
|
||||
removeFilter(index);
|
||||
}}
|
||||
//onAdd={(chip) => {
|
||||
// console.log("ADd: ", chip);
|
||||
// addFilter(chip);
|
||||
//}}
|
||||
//onDelete={(_, index) => {
|
||||
// console.log("Remove: ", index);
|
||||
// removeFilter(index);
|
||||
//}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -3485,11 +3492,11 @@ const Workflows = (props) => {
|
||||
/>
|
||||
: null}
|
||||
|
||||
<div style={{marginTop: 30, marginBottom: 50, marginLeft: 30, }}>
|
||||
<div style={{}}>
|
||||
{view === "grid" ? (
|
||||
<Grid container spacing={filteredWorkflows.length === 0 ? 12 : filteredWorkflows.length === 1 ? 6 : 4} style={paperAppContainer}>
|
||||
<Grid container spacing={0/*filteredWorkflows.length === 0 ? 12 : filteredWorkflows.length === 1 ? 6 : 4*/} style={paperAppContainer}>
|
||||
{/*<Zoom in={true} style={{ transitionDelay: `${workflowDelay}ms` }}>*/}
|
||||
<NewWorkflowPaper />
|
||||
<NewWorkflowPaper />
|
||||
{/*</Zoom>*/}
|
||||
|
||||
{filteredWorkflows.map((data, index) => {
|
||||
|
||||
Reference in New Issue
Block a user