From 2eb22efdac1ff177cdc6747106e27b69fdb030b0 Mon Sep 17 00:00:00 2001 From: frikky Date: Tue, 17 Jan 2023 17:02:51 +0100 Subject: [PATCH] Fixed unreachable code for #1020 and #1021 --- backend/app_sdk/app_base.py | 22 ------ frontend/src/components/WelcomeForm2.jsx | 93 ++++++++++++++++++++++-- 2 files changed, 85 insertions(+), 30 deletions(-) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 8af1f9a1..6b56cd29 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -2787,9 +2787,6 @@ class AppBase: correct_branches += 1 continue - # FIXME: Check if the previous node has a result or not - - #self.logger.info("[DEBUG] Relevant conditions: %s" % branch["conditions"]) successful_conditions = [] failed_conditions = [] successful_conditions = 0 @@ -2802,27 +2799,20 @@ class AppBase: check, sourcevalue, is_loop = parse_params(action, fullexecution, condition["source"], self) if check: continue - return False, {"success": False, "reason": "Failed condition: %s %s %s because %s" % (sourcevalue, condition["condition"]["value"], destinationvalue, check)} - #sourcevalue = sourcevalue.encode("utf-8") sourcevalue = parse_wrapper_start(sourcevalue, self) destinationvalue = condition["destination"]["value"] check, destinationvalue, is_loop = parse_params(action, fullexecution, condition["destination"], self) if check: continue - return False, {"success": False, "reason": "Failed condition: %s %s %s because %s" % (sourcevalue, condition["condition"]["value"], destinationvalue, check)} - #destinationvalue = destinationvalue.encode("utf-8") destinationvalue = parse_wrapper_start(destinationvalue, self) if not condition["condition"]["value"] in available_checks: self.logger.warning("Skipping %s %s %s because %s is invalid." % (sourcevalue, condition["condition"]["value"], destinationvalue, condition["condition"]["value"])) continue - #self.logger.info(destinationvalue) - # NEGATE - # Configuration = negated because of WorkflowAppActionParam.. validation = run_validation(sourcevalue, condition["condition"]["value"], destinationvalue) try: @@ -2834,12 +2824,6 @@ class AppBase: if validation == True: successful_conditions += 1 - #if not validation: - # self.logger.info("Failed condition check for %s %s %s." % (sourcevalue, condition["condition"]["value"], destinationvalue)) - # return False, {"success": False, "reason": "Failed condition (3): %s %s %s" % (sourcevalue, condition["condition"]["value"], destinationvalue)} - - #self.logger.info("CONDITIONS VS SUCCESS: %d vs %d" % (total_conditions, successful_conditions)) - if total_conditions == successful_conditions: correct_branches += 1 @@ -2849,15 +2833,9 @@ class AppBase: if matching_branches > 0 and correct_branches > 0: return True, "" - # FIXME: Check if previous branches are at all finished - self.logger.info("[DEBUG] Correct branches vs matching branches: %d vs %d" % (correct_branches, matching_branches)) return False, {"success": False, "reason": "Minimum of one branch's conditions must be correct to continue. Total: %d of %d" % (correct_branches, matching_branches)} - #Correct branches vs matching branches: 1 vs 1 - #if - return True, "" - # # diff --git a/frontend/src/components/WelcomeForm2.jsx b/frontend/src/components/WelcomeForm2.jsx index a3ccf86d..713f6a57 100644 --- a/frontend/src/components/WelcomeForm2.jsx +++ b/frontend/src/components/WelcomeForm2.jsx @@ -36,6 +36,7 @@ import { Divider, Tooltip, Chip, + ButtonGroup, } from "@material-ui/core"; import { useAlert } from "react-alert"; @@ -53,7 +54,25 @@ const responsive = { const WelcomeForm = (props) => { const { userdata, globalUrl, discoveryWrapper, setDiscoveryWrapper, appFramework, getFramework, activeStep, setActiveStep, steps, skipped, setSkipped, getApps, apps, handleSetSearch, usecaseButtons, defaultSearch, setDefaultSearch, selectionOpen, setSelectionOpen, } = props - const usecaseItems = [ + const [usecaseItems, setUsecaseItems] = useState([ + { + "search": "Phishing", + "usecase_search": undefined, + }, + { + "search": "Enrichment", + "usecase_search": undefined, + }, + { + "search": "Enrichment", + "usecase_search": "SIEM alert enrichment", + }, + { + "search": "Build your own", + "usecase_search": undefined, + }]) + + /*
{ userdata={userdata} />
- ] + ]) + */ const [discoveryData, setDiscoveryData] = React.useState({}) const [name, setName] = React.useState("") @@ -166,6 +186,43 @@ const WelcomeForm = (props) => { } else { //navigate(`/welcome?tab=1`) } + + const foundTemplate = params["workflow_template"]; + if (foundTemplate !== null && foundTemplate !== undefined) { + console.log("Found workflow template: ", foundTemplate) + + var sourceapp = undefined + var destinationapp = undefined + var action = undefined + const srcapp = params["source_app"]; + if (srcapp !== null && srcapp !== undefined) { + sourceapp = srcapp + } + + const dstapp = params["dest_app"]; + if (dstapp !== null && dstapp !== undefined) { + destinationapp = dstapp + } + + const act = params["action"]; + if (act !== null && act !== undefined) { + action = act + } + + //defaultSearch={foundTemplate} + // + usecaseItems[0] = { + "search": "enrichment", + "usecase_search": foundTemplate, + "sourceapp": sourceapp, + "destinationapp": destinationapp, + "autotry": action === "try", + } + + console.log("Adding: ", usecaseItems[0]) + + setUsecaseItems(usecaseItems) + } } }, []) @@ -416,7 +473,27 @@ const WelcomeForm = (props) => { minWidth: buttonWidth, maxWidth: buttonWidth, } - + + + const formattedCarousel = appFramework === undefined || appFramework === null ? [] : usecaseItems.map((item, index) => { + return ( +
+ +
+ ) + }) + const getStepContent = (step) => { switch (step) { case 0: @@ -676,10 +753,10 @@ const WelcomeForm = (props) => {
{ animationType="fadeout" animationDuration={800} disableButtonsControls - disableDotsControls />
@@ -721,6 +797,7 @@ const WelcomeForm = (props) => { } } + const extraHeight = isCloud ? -7 : 0 return (
{/*selectionOpen ? @@ -756,7 +833,7 @@ const WelcomeForm = (props) => { disabled={activeStep === 0} onClick={handleBack} variant={"outlined"} - style={{marginLeft: 10, height: 64, width: 100, position: "absolute", top: activeStep === 1 ? -600 : -577, left: activeStep === 1 ? 105 : -145+clickdiff, }} + style={{marginLeft: 10, height: 64, width: 100, position: "absolute", top: activeStep === 1 ? -600-extraHeight : -577, left: activeStep === 1 ? 105 : -145+clickdiff, borderRadius: "50px 0px 0px 50px", }} > Back @@ -764,7 +841,7 @@ const WelcomeForm = (props) => { variant={"outlined"} color="primary" onClick={handleNext} - style={{marginLeft: 10, height: 64, width: 100, position: "absolute", top: activeStep === 1 ? -600: -577, left: activeStep === 1 ? 748 : 510+clickdiff, }} + style={{marginLeft: 10, height: 64, width: 100, position: "absolute", top: activeStep === 1 ? -600-extraHeight: -577, left: activeStep === 1 ? 748 : 510+clickdiff, borderRadius: "0px 50px 50px 0px", }} disabled={activeStep === 0 ? orgName.length === 0 || name.length === 0 : false} > {activeStep === steps.length - 1 ? "Finish" : "Next"}