Major fixes to app creator

This commit is contained in:
frikky
2020-09-13 08:10:46 +02:00
parent 4d6984e23e
commit 6ec4fed722
8 changed files with 225 additions and 86 deletions
+4 -4
View File
@@ -270,7 +270,7 @@ class AppBase:
except TypeError: except TypeError:
return data return data
print("Running %s" % data) #print("Running %s" % data)
# Look for the INNER wrapper first, then move out # Look for the INNER wrapper first, then move out
wrappers = ["int", "number", "lower", "upper", "trim", "strip", "split", "parse", "len", "length"] wrappers = ["int", "number", "lower", "upper", "trim", "strip", "split", "parse", "len", "length"]
@@ -337,7 +337,7 @@ class AppBase:
if len(newstring) > 0: if len(newstring) > 0:
newdata.append(newstring) newdata.append(newstring)
print(newdata) #print(newdata)
parsedlist = [] parsedlist = []
non_string = False non_string = False
for item in newdata: for item in newdata:
@@ -352,7 +352,7 @@ class AppBase:
elif len(parsedlist) == 1 and non_string: elif len(parsedlist) == 1 and non_string:
return parsedlist[0] return parsedlist[0]
else: else:
print("Casting back to string because multi: ", parsedlist) #print("Casting back to string because multi: ", parsedlist)
newlist = [] newlist = []
for item in parsedlist: for item in parsedlist:
try: try:
@@ -870,7 +870,7 @@ class AppBase:
if not multiexecution: if not multiexecution:
print("APP_SDK DONE: Starting normal execution of function") print("APP_SDK DONE: Starting normal execution of function")
newres = await func(**params) newres = await func(**params)
print("NEWRES: ", newres) #print("NEWRES: ", newres)
if isinstance(newres, str): if isinstance(newres, str):
result += newres result += newres
else: else:
+2 -2
View File
@@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
NAME=app_sdk NAME=app_sdk
VERSION=0.6.1 VERSION=0.6.2
docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force
docker build . -t frikky/shuffle:$NAME -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/app_sdk:0.6.0 docker build . -t frikky/shuffle:$NAME -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION
#docker push frikky/$NAME:$VERSION #docker push frikky/$NAME:$VERSION
#docker push docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION #docker push docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION
+106 -9
View File
@@ -253,9 +253,13 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
parameterData := "" parameterData := ""
if len(optionalQueries) > 0 { if len(optionalQueries) > 0 {
queryString += ", " queryString += ", "
for _, query := range optionalQueries { for index, query := range optionalQueries {
// Check if it's a part of the URL already // Check if it's a part of the URL already
queryString += fmt.Sprintf("%s=\"\", ", query) queryString += fmt.Sprintf("%s=\"\"", query)
if index != len(optionalQueries)-1 {
queryString += ", "
}
queryData += fmt.Sprintf(` queryData += fmt.Sprintf(`
if %s: if %s:
url += f"&%s={%s}"`, query, query, query) url += f"&%s={%s}"`, query, query, query)
@@ -274,8 +278,8 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
authenticationParameter = ", apikey" authenticationParameter = ", apikey"
authenticationSetup = "if apikey != \" \": headers[\"Authorization\"] = f\"Bearer {apikey}\"" authenticationSetup = "if apikey != \" \": headers[\"Authorization\"] = f\"Bearer {apikey}\""
} else if swagger.Components.SecuritySchemes["BasicAuth"] != nil { } else if swagger.Components.SecuritySchemes["BasicAuth"] != nil {
authenticationParameter = ", username, password" authenticationParameter = ", username_basic, password_basic"
authenticationAddin = ", auth=(username, password)" authenticationAddin = ", auth=(username_basic, password_basic)"
} else if swagger.Components.SecuritySchemes["ApiKeyAuth"] != nil { } else if swagger.Components.SecuritySchemes["ApiKeyAuth"] != nil {
authenticationParameter = ", apikey" authenticationParameter = ", apikey"
if swagger.Components.SecuritySchemes["ApiKeyAuth"].Value.In == "header" { if swagger.Components.SecuritySchemes["ApiKeyAuth"].Value.In == "header" {
@@ -401,6 +405,11 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
verifyAddin, verifyAddin,
) )
if strings.Contains(functionname, "get_returns_the_vuln") {
log.Println(data)
log.Printf("Queries: %s", queryString)
}
//log.Printf(data) //log.Printf(data)
return functionname, data return functionname, data
} }
@@ -553,7 +562,7 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
}) })
} else if securitySchemes["BasicAuth"] != nil { } else if securitySchemes["BasicAuth"] != nil {
api.Authentication.Parameters = append(api.Authentication.Parameters, AuthenticationParams{ api.Authentication.Parameters = append(api.Authentication.Parameters, AuthenticationParams{
Name: "username", Name: "username_auth",
Value: "", Value: "",
Example: "username", Example: "username",
Description: securitySchemes["BasicAuth"].Value.Description, Description: securitySchemes["BasicAuth"].Value.Description,
@@ -565,7 +574,7 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
}) })
api.Authentication.Parameters = append(api.Authentication.Parameters, AuthenticationParams{ api.Authentication.Parameters = append(api.Authentication.Parameters, AuthenticationParams{
Name: "password", Name: "password_auth",
Value: "", Value: "",
Example: "*****", Example: "*****",
Description: securitySchemes["BasicAuth"].Value.Description, Description: securitySchemes["BasicAuth"].Value.Description,
@@ -577,7 +586,7 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
}) })
extraParameters = append(extraParameters, WorkflowAppActionParameter{ extraParameters = append(extraParameters, WorkflowAppActionParameter{
Name: "username", Name: "username_basic",
Description: "The username to use", Description: "The username to use",
Multiline: false, Multiline: false,
Required: true, Required: true,
@@ -588,7 +597,7 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
}, },
}) })
extraParameters = append(extraParameters, WorkflowAppActionParameter{ extraParameters = append(extraParameters, WorkflowAppActionParameter{
Name: "password", Name: "password_basic",
Description: "The password to use", Description: "The password to use",
Multiline: false, Multiline: false,
Required: true, Required: true,
@@ -846,21 +855,102 @@ func deployAppToDatastore(ctx context.Context, workflowapp WorkflowApp) error {
return nil return nil
} }
// FIXME:
// https://docs.python.org/3.2/reference/lexical_analysis.html#identifiers
// This is used to build the python functions.
func fixFunctionName(functionName, actualPath string) string { func fixFunctionName(functionName, actualPath string) string {
if len(functionName) == 0 { if len(functionName) == 0 {
functionName = actualPath functionName = actualPath
} }
// REGEX THIS SHIT
// ROFL
//log.Printf("Fixing function name for %s", functionName) //log.Printf("Fixing function name for %s", functionName)
functionName = strings.Replace(functionName, " ", "_", -1)
functionName = strings.Replace(functionName, ".", "", -1) functionName = strings.Replace(functionName, ".", "", -1)
functionName = strings.Replace(functionName, ",", "", -1)
functionName = strings.Replace(functionName, ".", "", -1) functionName = strings.Replace(functionName, ".", "", -1)
functionName = strings.Replace(functionName, "&", "", -1)
functionName = strings.Replace(functionName, "/", "", -1) functionName = strings.Replace(functionName, "/", "", -1)
functionName = strings.Replace(functionName, "\\", "", -1) functionName = strings.Replace(functionName, "\\", "", -1)
functionName = strings.Replace(functionName, "!", "", -1)
functionName = strings.Replace(functionName, "?", "", -1)
functionName = strings.Replace(functionName, "@", "", -1)
functionName = strings.Replace(functionName, "#", "", -1)
functionName = strings.Replace(functionName, "$", "", -1)
functionName = strings.Replace(functionName, "&", "", -1)
functionName = strings.Replace(functionName, "*", "", -1)
functionName = strings.Replace(functionName, "(", "", -1)
functionName = strings.Replace(functionName, ")", "", -1)
functionName = strings.Replace(functionName, "[", "", -1)
functionName = strings.Replace(functionName, "]", "", -1)
functionName = strings.Replace(functionName, "{", "", -1)
functionName = strings.Replace(functionName, "}", "", -1)
functionName = strings.Replace(functionName, `"`, "", -1)
functionName = strings.Replace(functionName, `'`, "", -1)
functionName = strings.Replace(functionName, `|`, "", -1)
functionName = strings.Replace(functionName, `~`, "", -1)
functionName = strings.Replace(functionName, " ", "_", -1)
functionName = strings.Replace(functionName, "-", "_", -1)
functionName = strings.ToLower(functionName) functionName = strings.ToLower(functionName)
return functionName return functionName
} }
// Returns a valid param name
func validateParameterName(name string) string {
invalid := []string{"False",
"await",
"else",
"import",
"pass",
"None",
"break",
"except",
"in",
"raise",
"True",
"class",
"finally",
"is",
"return",
"and",
"continue",
"for",
"lambda",
"try",
"as",
"def",
"from",
"nonlocal",
"while",
"assert",
"del",
"global",
"not",
"with",
"async",
"elif",
"if",
"or",
"yield",
}
newname := name
for _, item := range invalid {
if item == name {
//log.Printf("%s is NOT a valid parameter name!", item)
newname = fmt.Sprintf("%s_shuffle", item)
break
}
}
return newname
}
func handleConnect(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []WorkflowAppActionParameter, path *openapi3.PathItem, actualPath string) (WorkflowAppAction, string) { func handleConnect(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []WorkflowAppActionParameter, path *openapi3.PathItem, actualPath string) (WorkflowAppAction, string) {
// What to do with this, hmm // What to do with this, hmm
functionName := fixFunctionName(path.Connect.Summary, actualPath) functionName := fixFunctionName(path.Connect.Summary, actualPath)
@@ -926,6 +1016,7 @@ func handleConnect(swagger *openapi3.Swagger, api WorkflowApp, extraParameters [
parsedName = strings.ReplaceAll(parsedName, ",", "_") parsedName = strings.ReplaceAll(parsedName, ",", "_")
parsedName = strings.ReplaceAll(parsedName, ".", "_") parsedName = strings.ReplaceAll(parsedName, ".", "_")
parsedName = strings.ReplaceAll(parsedName, "|", "_") parsedName = strings.ReplaceAll(parsedName, "|", "_")
parsedName = validateParameterName(parsedName)
param.Value.Name = parsedName param.Value.Name = parsedName
path.Connect.Parameters[counter].Value.Name = parsedName path.Connect.Parameters[counter].Value.Name = parsedName
@@ -1074,6 +1165,7 @@ func handleGet(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wor
parsedName = strings.ReplaceAll(parsedName, ",", "_") parsedName = strings.ReplaceAll(parsedName, ",", "_")
parsedName = strings.ReplaceAll(parsedName, ".", "_") parsedName = strings.ReplaceAll(parsedName, ".", "_")
parsedName = strings.ReplaceAll(parsedName, "|", "_") parsedName = strings.ReplaceAll(parsedName, "|", "_")
parsedName = validateParameterName(parsedName)
param.Value.Name = parsedName param.Value.Name = parsedName
path.Get.Parameters[counter].Value.Name = parsedName path.Get.Parameters[counter].Value.Name = parsedName
@@ -1222,6 +1314,7 @@ func handleHead(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wo
parsedName = strings.ReplaceAll(parsedName, ",", "_") parsedName = strings.ReplaceAll(parsedName, ",", "_")
parsedName = strings.ReplaceAll(parsedName, ".", "_") parsedName = strings.ReplaceAll(parsedName, ".", "_")
parsedName = strings.ReplaceAll(parsedName, "|", "_") parsedName = strings.ReplaceAll(parsedName, "|", "_")
parsedName = validateParameterName(parsedName)
param.Value.Name = parsedName param.Value.Name = parsedName
path.Head.Parameters[counter].Value.Name = parsedName path.Head.Parameters[counter].Value.Name = parsedName
@@ -1370,6 +1463,7 @@ func handleDelete(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []
parsedName = strings.ReplaceAll(parsedName, ",", "_") parsedName = strings.ReplaceAll(parsedName, ",", "_")
parsedName = strings.ReplaceAll(parsedName, ".", "_") parsedName = strings.ReplaceAll(parsedName, ".", "_")
parsedName = strings.ReplaceAll(parsedName, "|", "_") parsedName = strings.ReplaceAll(parsedName, "|", "_")
parsedName = validateParameterName(parsedName)
param.Value.Name = parsedName param.Value.Name = parsedName
path.Delete.Parameters[counter].Value.Name = parsedName path.Delete.Parameters[counter].Value.Name = parsedName
@@ -1517,6 +1611,7 @@ func handlePost(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wo
parsedName = strings.ReplaceAll(parsedName, ",", "_") parsedName = strings.ReplaceAll(parsedName, ",", "_")
parsedName = strings.ReplaceAll(parsedName, ".", "_") parsedName = strings.ReplaceAll(parsedName, ".", "_")
parsedName = strings.ReplaceAll(parsedName, "|", "_") parsedName = strings.ReplaceAll(parsedName, "|", "_")
parsedName = validateParameterName(parsedName)
param.Value.Name = parsedName param.Value.Name = parsedName
path.Post.Parameters[counter].Value.Name = parsedName path.Post.Parameters[counter].Value.Name = parsedName
@@ -1664,6 +1759,7 @@ func handlePatch(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []W
parsedName = strings.ReplaceAll(parsedName, ",", "_") parsedName = strings.ReplaceAll(parsedName, ",", "_")
parsedName = strings.ReplaceAll(parsedName, ".", "_") parsedName = strings.ReplaceAll(parsedName, ".", "_")
parsedName = strings.ReplaceAll(parsedName, "|", "_") parsedName = strings.ReplaceAll(parsedName, "|", "_")
parsedName = validateParameterName(parsedName)
param.Value.Name = parsedName param.Value.Name = parsedName
path.Patch.Parameters[counter].Value.Name = parsedName path.Patch.Parameters[counter].Value.Name = parsedName
@@ -1811,6 +1907,7 @@ func handlePut(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wor
parsedName = strings.ReplaceAll(parsedName, ",", "_") parsedName = strings.ReplaceAll(parsedName, ",", "_")
parsedName = strings.ReplaceAll(parsedName, ".", "_") parsedName = strings.ReplaceAll(parsedName, ".", "_")
parsedName = strings.ReplaceAll(parsedName, "|", "_") parsedName = strings.ReplaceAll(parsedName, "|", "_")
parsedName = validateParameterName(parsedName)
param.Value.Name = parsedName param.Value.Name = parsedName
path.Put.Parameters[counter].Value.Name = parsedName path.Put.Parameters[counter].Value.Name = parsedName
+11 -11
View File
@@ -47,7 +47,6 @@ import (
// Random // Random
xj "github.com/basgys/goxml2json" xj "github.com/basgys/goxml2json"
newscheduler "github.com/carlescere/scheduler" newscheduler "github.com/carlescere/scheduler"
gyaml "github.com/ghodss/yaml"
"github.com/satori/go.uuid" "github.com/satori/go.uuid"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
@@ -5545,7 +5544,7 @@ func handleSwaggerValidation(body []byte) (ParsedOpenApi, error) {
//log.Printf("Json err: %s", err) //log.Printf("Json err: %s", err)
err = yaml.Unmarshal(body, &version) err = yaml.Unmarshal(body, &version)
if err != nil { if err != nil {
log.Printf("Yaml error: %s", err) log.Printf("Yaml error (1): %s", err)
} else { } else {
//log.Printf("Successfully parsed YAML!") //log.Printf("Successfully parsed YAML!")
} }
@@ -5583,9 +5582,9 @@ func handleSwaggerValidation(body []byte) (ParsedOpenApi, error) {
err = json.Unmarshal(body, &swagger) err = json.Unmarshal(body, &swagger)
if err != nil { if err != nil {
//log.Printf("Json error? %s", err) //log.Printf("Json error? %s", err)
err = gyaml.Unmarshal(body, &swagger) err = yaml.Unmarshal(body, &swagger)
if err != nil { if err != nil {
log.Printf("Yaml error: %s", err) log.Printf("Yaml error (2): %s", err)
return ParsedOpenApi{}, err return ParsedOpenApi{}, err
} else { } else {
//log.Printf("Valid yaml!") //log.Printf("Valid yaml!")
@@ -5677,7 +5676,7 @@ func validateSwagger(resp http.ResponseWriter, request *http.Request) {
log.Printf("Json err: %s", err) log.Printf("Json err: %s", err)
err = yaml.Unmarshal(body, &version) err = yaml.Unmarshal(body, &version)
if err != nil { if err != nil {
log.Printf("Yaml error: %s", err) log.Printf("Yaml error (3): %s", err)
//resp.WriteHeader(422) //resp.WriteHeader(422)
//resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed reading openapi to json and yaml: %s"}`, err))) //resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed reading openapi to json and yaml: %s"}`, err)))
//return //return
@@ -5736,17 +5735,18 @@ func validateSwagger(resp http.ResponseWriter, request *http.Request) {
//log.Println(string(body)) //log.Println(string(body))
err = json.Unmarshal(body, &swagger) err = json.Unmarshal(body, &swagger)
if err != nil { if err != nil {
log.Printf("Json error? %s", err) log.Printf("Json error for v2 - trying yaml: %s", err)
err = gyaml.Unmarshal(body, &swagger) err = yaml.Unmarshal([]byte(body), &swagger)
if err != nil { if err != nil {
log.Printf("Yaml error: %s", err) log.Printf("Yaml error (4): %s", err)
resp.WriteHeader(422)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed reading openapi2: %s"}`, err)))
return
} else { } else {
log.Printf("Found valid yaml!") log.Printf("Found valid yaml!")
} }
resp.WriteHeader(422)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed reading openapi2: %s"}`, err)))
return
} }
swaggerv3, err := openapi2conv.ToV3Swagger(&swagger) swaggerv3, err := openapi2conv.ToV3Swagger(&swagger)
+15 -20
View File
@@ -489,7 +489,6 @@ const Admin = (props) => {
return response.json() return response.json()
}) })
.then((responseJson) => { .then((responseJson) => {
console.log(responseJson)
setUsers(responseJson) setUsers(responseJson)
}) })
.catch(error => { .catch(error => {
@@ -857,9 +856,9 @@ const Admin = (props) => {
style={{ minWidth: 180, maxWidth: 180 }} style={{ minWidth: 180, maxWidth: 180 }}
/> />
</ListItem> </ListItem>
{users === undefined ? null : users.map(data => { {users === undefined ? null : users.map((data, index) => {
return ( return (
<ListItem> <ListItem key={index}>
<ListItemText <ListItemText
primary={data.username} primary={data.username}
style={{ minWidth: 200, maxWidth: 200 }} style={{ minWidth: 200, maxWidth: 200 }}
@@ -870,19 +869,15 @@ const Admin = (props) => {
/> />
<ListItemText <ListItemText
primary= primary=
{<Select {<Select
PaperProps={{ SelectDisplayProps={{
style: { style: {
} marginLeft: 10,
}} }
SelectDisplayProps={{ }}
style: { value={data.role}
marginLeft: 10, fullWidth
} onChange={(e) => {
}}
value={data.role}
fullWidth
onChange={(e) => {
console.log("VALUE: ", e.target.value) console.log("VALUE: ", e.target.value)
setUser(data.id, "role", e.target.value) setUser(data.id, "role", e.target.value)
}} }}
@@ -1131,7 +1126,6 @@ const Admin = (props) => {
</div> </div>
: null : null
console.log("Environments: ", environments)
const environmentView = curTab === 2 ? const environmentView = curTab === 2 ?
<div> <div>
<div style={{marginTop: 20, marginBottom: 20,}}> <div style={{marginTop: 20, marginBottom: 20,}}>
@@ -1147,13 +1141,14 @@ const Admin = (props) => {
Add environment Add environment
</Button> </Button>
<Button <Button
style={{marginLeft: 5, }} style={{marginLeft: 5, marginRight: 15, }}
variant="contained" variant="contained"
color="primary" color="primary"
onClick={() => getEnvironments()} onClick={() => getEnvironments()}
> >
<CachedIcon /> <CachedIcon />
</Button> </Button>
<Switch checked={showArchived} onChange={() => {setShowArchived(!showArchived)}} /> Show archived
<Divider style={{marginTop: 20, marginBottom: 20, backgroundColor: theme.palette.inputColor}}/> <Divider style={{marginTop: 20, marginBottom: 20, backgroundColor: theme.palette.inputColor}}/>
<List> <List>
<ListItem> <ListItem>
@@ -1178,7 +1173,7 @@ const Admin = (props) => {
style={{minWidth: 150, maxWidth: 150}} style={{minWidth: 150, maxWidth: 150}}
/> />
</ListItem> </ListItem>
{environments === undefined ? null : environments.map(environment => { {environments === undefined ? null : environments.map((environment, index)=> {
if (!showArchived && environment.archived) { if (!showArchived && environment.archived) {
return null return null
} }
@@ -1189,7 +1184,7 @@ const Admin = (props) => {
} }
return ( return (
<ListItem> <ListItem key={index}>
<ListItemText <ListItemText
primary={environment.Name} primary={environment.Name}
style={{minWidth: 150, maxWidth: 150, overflow: "hidden"}} style={{minWidth: 150, maxWidth: 150, overflow: "hidden"}}
+35 -20
View File
@@ -118,6 +118,7 @@ const AngularWorkflow = (props) => {
const [currentView, setCurrentView] = React.useState(0) const [currentView, setCurrentView] = React.useState(0)
const [triggerAuthentication, setTriggerAuthentication] = React.useState({}) const [triggerAuthentication, setTriggerAuthentication] = React.useState({})
const [triggerFolders, setTriggerFolders] = React.useState([]) const [triggerFolders, setTriggerFolders] = React.useState([])
const [showEnvironment, setShowEnvironment] = React.useState(false)
const [workflow, setWorkflow] = React.useState({}); const [workflow, setWorkflow] = React.useState({});
const [leftViewOpen, setLeftViewOpen] = React.useState(true); const [leftViewOpen, setLeftViewOpen] = React.useState(true);
@@ -766,6 +767,13 @@ const AngularWorkflow = (props) => {
return data return data
} }
// This can be used to only show prioritzed ones later
// Right now, it can prioritize authenticated ones
const internalIds = [
"Shuffle Tools",
"Testing",
"Http",
]
const getAppAuthentication = () => { const getAppAuthentication = () => {
fetch(globalUrl+"/api/v1/apps/authentication", { fetch(globalUrl+"/api/v1/apps/authentication", {
method: 'GET', method: 'GET',
@@ -795,10 +803,6 @@ const AngularWorkflow = (props) => {
}); });
} }
const internalIds = [
"80a1fdd2-95c2-49ab-81f6-e05689beb745", // Shuffle tools
"39c5f8fa-a088-4cdc-826f-19e2e61cb284", // Testing
]
const getApps = () => { const getApps = () => {
fetch(globalUrl+"/api/v1/workflows/apps", { fetch(globalUrl+"/api/v1/workflows/apps", {
@@ -823,11 +827,10 @@ const AngularWorkflow = (props) => {
//tmpapps = tmpapps.concat(getExtraApps()) //tmpapps = tmpapps.concat(getExtraApps())
//tmpapps = tmpapps.concat(responseJson) //tmpapps = tmpapps.concat(responseJson)
setApps(responseJson) setApps(responseJson)
setFilteredApps(responseJson)
getAppAuthentication() getAppAuthentication()
setFilteredApps(responseJson.filter(app => !internalIds.includes(app.name)))
setPrioritizedApps(responseJson.filter(app => internalIds.includes(app.id))) setPrioritizedApps(responseJson.filter(app => internalIds.includes(app.name)))
}) })
.catch(error => { .catch(error => {
alert.error(error.toString()) alert.error(error.toString())
@@ -931,7 +934,9 @@ const AngularWorkflow = (props) => {
setSelectedActionEnvironment(env) setSelectedActionEnvironment(env)
setSelectedActionName(curaction.name) setSelectedActionName(curaction.name)
setRequiresAuthentication(curapp.authentication.required)
setRequiresAuthentication(curapp.authentication.required && curapp.authentication.parameters !== undefined && curapp.authentication.parameters !== null)
if (curapp.authentication.required) { if (curapp.authentication.required) {
// Setup auth here :) // Setup auth here :)
@@ -1237,12 +1242,20 @@ const AngularWorkflow = (props) => {
}) })
.then((responseJson) => { .then((responseJson) => {
var found = false var found = false
var showEnvCnt = 0
for (var key in responseJson) { for (var key in responseJson) {
if (responseJson[key].default) { if (responseJson[key].default) {
setDefaultEnvironmentIndex(key) setDefaultEnvironmentIndex(key)
found = true found = true
break
} }
if (responseJson[key].archived === false) {
showEnvCnt += 1
}
}
if (showEnvCnt > 1) {
setShowEnvironment(true)
} }
if (!found) { if (!found) {
@@ -1813,13 +1826,12 @@ const AngularWorkflow = (props) => {
<Tabs <Tabs
value={currentView} value={currentView}
indicatorColor="primary" indicatorColor="primary"
textColor="white"
onChange={handleSetTab} onChange={handleSetTab}
aria-label="Left sidebar tab" aria-label="Left sidebar tab"
> >
<Tab label={ <Tab label={
<Grid container direction="row" alignItems="center"> <Grid container direction="row" alignItems="center">
<Grid item> <Grid item>
<AppsIcon style={iconStyle} /> <AppsIcon style={iconStyle} />
</Grid> </Grid>
<Grid item> <Grid item>
@@ -2246,16 +2258,16 @@ const AngularWorkflow = (props) => {
<Grid item> <Grid item>
<div style={{borderRadius: borderRadius, height: 80, width: 80, backgroundImage: image, backgroundSize: "cover", backgroundRepeat: "no-repeat"}} /> <div style={{borderRadius: borderRadius, height: 80, width: 80, backgroundImage: image, backgroundSize: "cover", backgroundRepeat: "no-repeat"}} />
</Grid> </Grid>
<Grid style={{display: "flex", flexDirection: "column", marginLeft: "20px"}}> <Grid style={{display: "flex", flexDirection: "column", marginLeft: "20px", minWidth: 185, maxWidth: 185, overflow: "hidden", maxHeight: 80, }}>
<Grid item style={{flex: 1}}> <Grid item style={{flex: 1}}>
<h4 style={{marginBottom: "0px", marginTop: "5px"}}>{newAppname}</h4> <h4 style={{marginBottom: 0, marginTop: 5}}>{newAppname}</h4>
</Grid>
<Grid item style={{flex: 1, width: "100%", }}>
Short description...
</Grid> </Grid>
<Grid item style={{flex: 1}}> <Grid item style={{flex: 1}}>
Version: {app.app_version} Version: {app.app_version}
</Grid> </Grid>
<Grid item style={{flex: 1, width: "100%", maxHeight: 27, overflow: "hidden",}}>
{app.description}
</Grid>
</Grid> </Grid>
</Grid> </Grid>
</Paper> </Paper>
@@ -2291,12 +2303,12 @@ const AngularWorkflow = (props) => {
*/} */}
{prioritizedApps.map((app, index) => { {prioritizedApps.map((app, index) => {
return( return(
<ParsedAppPaper app={app} /> <ParsedAppPaper key={index} app={app} />
) )
})} })}
{filteredApps.filter(innerapp => !internalIds.includes(innerapp.id)).map((app, index) => { {filteredApps.filter(innerapp => !internalIds.includes(innerapp.id)).map((app, index) => {
return( return(
<ParsedAppPaper app={app} /> <ParsedAppPaper key={index} app={app} />
) )
})} })}
</div> </div>
@@ -2637,6 +2649,9 @@ const AngularWorkflow = (props) => {
data.variant = "STATIC_VALUE" data.variant = "STATIC_VALUE"
} }
// selectedAction.selectedAuthentication = e.target.value
// selectedAction.authentication_id = e.target.value.id
if (!selectedAction.auth_not_required && selectedAction.selectedAuthentication !== undefined && selectedAction.selectedAuthentication.fields !== undefined && selectedAction.selectedAuthentication.fields[data.name] !== undefined) { if (!selectedAction.auth_not_required && selectedAction.selectedAuthentication !== undefined && selectedAction.selectedAuthentication.fields !== undefined && selectedAction.selectedAuthentication.fields[data.name] !== undefined) {
// This sets the placeholder in the frontend. (Replaced in backend) // This sets the placeholder in the frontend. (Replaced in backend)
selectedActionParameters[count].value = selectedAction.selectedAuthentication.fields[data.name] selectedActionParameters[count].value = selectedAction.selectedAuthentication.fields[data.name]
@@ -3227,7 +3242,7 @@ const AngularWorkflow = (props) => {
</div> </div>
</div> </div>
: null} : null}
{environments !== undefined && environments !== null && environments.length > 1 ? {showEnvironment ?
<div style={{marginTop: "20px"}}> <div style={{marginTop: "20px"}}>
<Typography> <Typography>
Environment Environment
@@ -5658,7 +5673,7 @@ const AngularWorkflow = (props) => {
return null return null
} }
if (selectedApp.authentication.parameters.length === undefined || selectedApp.authentication.parameters.length === 0) { if (selectedApp.authentication.parameters === null || selectedApp.authentication.parameters === undefined || selectedApp.authentication.parameters.length === 0) {
return null return null
} }
+41 -19
View File
@@ -214,7 +214,7 @@ const AppCreator = (props) => {
const [update, setUpdate] = useState("") const [update, setUpdate] = useState("")
const [urlPathParameters, ] = useState([]); const [urlPathParameters, ] = useState([]);
const [firstrequest, setFirstrequest] = React.useState(true) const [firstrequest, setFirstrequest] = React.useState(true)
const [, setBasedata] = React.useState({}) const [basedata, setBasedata] = React.useState({})
const [actions, setActions] = useState([]) const [actions, setActions] = useState([])
const [errorCode, setErrorCode] = useState("") const [errorCode, setErrorCode] = useState("")
const [appBuilding, setAppBuilding] = useState(false) const [appBuilding, setAppBuilding] = useState(false)
@@ -394,8 +394,6 @@ const AppCreator = (props) => {
setNewWorkflowTags(newWorkflowTags) setNewWorkflowTags(newWorkflowTags)
} }
console.log(data.info)
// This is annoying (: // This is annoying (:
var securitySchemes = data.components.securityDefinitions var securitySchemes = data.components.securityDefinitions
if (securitySchemes === undefined) { if (securitySchemes === undefined) {
@@ -431,8 +429,6 @@ const AppCreator = (props) => {
continue continue
} }
console.log("Method: ", method)
console.log("Methodval: ", methodvalue)
var newaction = { var newaction = {
"name": methodvalue.summary, "name": methodvalue.summary,
"description": methodvalue.description, "description": methodvalue.description,
@@ -604,7 +600,10 @@ const AppCreator = (props) => {
"id": props.match.params.appid, "id": props.match.params.appid,
} }
if (contact === "") {
if (basedata.info.contact !== undefined) {
data.info["contact"] = basedata.info.contact
} else if (contact === "") {
data.info["contact"] = { data.info["contact"] = {
"name": "@frikkylikeme", "name": "@frikkylikeme",
"url": "https://twitter.com/frikkylikeme", "url": "https://twitter.com/frikkylikeme",
@@ -629,7 +628,7 @@ const AppCreator = (props) => {
// Handles actions // Handles actions
for (var key in actions) { for (var key in actions) {
const item = actions[key] var item = actions[key]
if (item.errors.length > 0) { if (item.errors.length > 0) {
alert.error("Saving with error in action "+item.name) alert.error("Saving with error in action "+item.name)
} }
@@ -642,6 +641,12 @@ const AppCreator = (props) => {
data.paths[item.url] = {} data.paths[item.url] = {}
} }
const regex = /[A-Za-z0-9 _]/g;
const found = item.name.match(regex);
if (found !== null) {
item.name = found.join("")
}
data.paths[item.url][item.method.toLowerCase()] = { data.paths[item.url][item.method.toLowerCase()] = {
"responses": { "responses": {
"default": { "default": {
@@ -803,8 +808,6 @@ const AppCreator = (props) => {
} }
} }
console.log("ACTIONS: ", data.paths)
fetch(globalUrl+"/api/v1/verify_openapi", { fetch(globalUrl+"/api/v1/verify_openapi", {
method: 'POST', method: 'POST',
headers: { headers: {
@@ -927,6 +930,16 @@ const AppCreator = (props) => {
setUrlPathQueries(urlPathQueries) setUrlPathQueries(urlPathQueries)
} }
const duplicateAction = (index) => {
var newAction = JSON.parse(JSON.stringify(actions[index]))
newAction.name = newAction.name+"_copy"
newAction.errors.push("Can't have the same name")
actions.push(newAction)
setActions(actions)
setUpdate(Math.random())
}
const deleteAction = (index) => { const deleteAction = (index) => {
actions.splice(index, 1) actions.splice(index, 1)
setCurrentAction({ setCurrentAction({
@@ -942,6 +955,7 @@ const AppCreator = (props) => {
}) })
setActions(actions) setActions(actions)
setUpdate(Math.random())
} }
//console.log("Option: ", authenticationOption) //console.log("Option: ", authenticationOption)
@@ -1018,7 +1032,7 @@ const AppCreator = (props) => {
fullWidth={true} fullWidth={true}
defaultValue={data.name} defaultValue={data.name}
placeholder={'Query name'} placeholder={'Query name'}
helperText={<div style={{color:"white", marginBottom: "2px",}}>Click required switch</div>} helperText={<span style={{color:"white", marginBottom: "2px",}}>Click required switch</span>}
onBlur={(e) => { onBlur={(e) => {
urlPathQueries[index].name = e.target.value urlPathQueries[index].name = e.target.value
setUrlPathQueries(urlPathQueries) setUrlPathQueries(urlPathQueries)
@@ -1059,12 +1073,12 @@ const AppCreator = (props) => {
} }
const url = baseUrl+data.url const url = data.url
return ( return (
<Paper style={actionListStyle}> <Paper style={actionListStyle}>
{error} {error}
<Tooltip title="Edit action" placement="bottom"> <Tooltip title="Edit action" placement="bottom">
<div style={{marginLeft: "5px", width: "100%", cursor: "pointer", maxWidth: 675}} onClick={() => { <div style={{marginLeft: "5px", width: "100%", cursor: "pointer", maxWidth: 725, overflowX: "hidden",}} onClick={() => {
setCurrentAction(data) setCurrentAction(data)
setCurrentActionMethod(data.method) setCurrentActionMethod(data.method)
setUrlPathQueries(data.queries) setUrlPathQueries(data.queries)
@@ -1081,7 +1095,14 @@ const AppCreator = (props) => {
</div> </div>
</Tooltip> </Tooltip>
*/} */}
<Tooltip title="Delete action" placement="bottom"> <Tooltip title="Duplicate action" placement="bottom" style={{minWidth: 60}} >
<div style={{color: "#f85a3e", cursor: "pointer", marginRight: 15, }} onClick={() => {
duplicateAction(index)
}}>
Duplicate
</div>
</Tooltip>
<Tooltip title="Delete action" placement="bottom" style={{minWidth: 60}} >
<div style={{color: "#f85a3e", cursor: "pointer"}} onClick={() => {deleteAction(index)}}> <div style={{color: "#f85a3e", cursor: "pointer"}} onClick={() => {deleteAction(index)}}>
Delete Delete
</div> </div>
@@ -1094,7 +1115,7 @@ const AppCreator = (props) => {
const setActionField = (field, value) => { const setActionField = (field, value) => {
currentAction[field] = value currentAction[field] = value
setCurrentAction(currentAction) setCurrentAction(currentAction)
console.log("ACTION: ", currentAction) //setUrlPathQueries(currentAction.queries)
} }
const bodyInfo = actionBodyRequest.includes(currentActionMethod) ? const bodyInfo = actionBodyRequest.includes(currentActionMethod) ?
@@ -1253,7 +1274,7 @@ const AppCreator = (props) => {
} }
// FIXME: Frontend isn't updating.. // FIXME: Frontend isn't updating..
if (JSON.stringify(tmpQueries) !== JSON.stringify(urlPathQueries)) { if (tmpQueries.length > 0 && JSON.stringify(tmpQueries) !== JSON.stringify(urlPathQueries)) {
setUrlPathQueries(tmpQueries) setUrlPathQueries(tmpQueries)
} }
@@ -1388,7 +1409,7 @@ const AppCreator = (props) => {
setUrlPath(e.target.value) setUrlPath(e.target.value)
console.log(e.target.value) console.log(e.target.value)
}} }}
helperText={<div style={{color:"white", marginBottom: "2px",}}>The path to use. Must start with /. Use {"{variablename}"} to have path variables</div>} helperText={<span style={{color:"white", marginBottom: "2px",}}>The path to use. Must start with /. Use {"{variablename}"} to have path variables</span>}
InputProps={{ InputProps={{
classes: { classes: {
notchedOutline: classes.notchedOutline, notchedOutline: classes.notchedOutline,
@@ -1485,7 +1506,7 @@ const AppCreator = (props) => {
multiline multiline
rows="5" rows="5"
onChange={e => setActionField("headers", e.target.value)} onChange={e => setActionField("headers", e.target.value)}
helperText={<div style={{color:"white", marginBottom: "2px",}}>Headers that are part of the request</div>} helperText={<span style={{color:"white", marginBottom: "2px",}}>Headers that are part of the request</span>}
InputProps={{ InputProps={{
classes: { classes: {
notchedOutline: classes.notchedOutline, notchedOutline: classes.notchedOutline,
@@ -1503,6 +1524,7 @@ const AppCreator = (props) => {
Cancel Cancel
</Button> </Button>
<Button color="primary" variant="outlined" style={{borderRadius: "0px"}} onClick={() => { <Button color="primary" variant="outlined" style={{borderRadius: "0px"}} onClick={() => {
console.log(urlPathQueries)
const errors = getActionErrors() const errors = getActionErrors()
addActionToView(errors) addActionToView(errors)
setActionsModalOpen(false) setActionsModalOpen(false)
@@ -1617,7 +1639,7 @@ const AppCreator = (props) => {
img.onload = function() { img.onload = function() {
// img, x, y, width, height // img, x, y, width, height
//ctx.drawImage(img, 174, 174) //ctx.drawImage(img, 174, 174)
console.log("IMG natural: ", img.naturalWidth, img.naturalHeight) //console.log("IMG natural: ", img.naturalWidth, img.naturalHeight)
//ctx.drawImage(img, 0, 0, 174, 174) //ctx.drawImage(img, 0, 0, 174, 174)
ctx.drawImage(img, ctx.drawImage(img,
0, 0, img.width, img.height, 0, 0, img.width, img.height,
@@ -1626,7 +1648,7 @@ const AppCreator = (props) => {
const canvasUrl = canvas.toDataURL() const canvasUrl = canvas.toDataURL()
if (canvasUrl !== fileBase64) { if (canvasUrl !== fileBase64) {
console.log("SET URL TO: ", canvasUrl) //console.log("SET URL TO: ", canvasUrl)
setFileBase64(canvasUrl) setFileBase64(canvasUrl)
} }
} }
+11 -1
View File
@@ -895,7 +895,17 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
fmt.Sprintf("EXECUTIONID=%s", workflowExecution.ExecutionId), fmt.Sprintf("EXECUTIONID=%s", workflowExecution.ExecutionId),
fmt.Sprintf("AUTHORIZATION=%s", workflowExecution.Authorization), fmt.Sprintf("AUTHORIZATION=%s", workflowExecution.Authorization),
fmt.Sprintf("CALLBACK_URL=%s", baseUrl), fmt.Sprintf("CALLBACK_URL=%s", baseUrl),
fmt.Sprintf("FULL_EXECUTION=%s", string(executionData)), }
// Fixes issue:
// standard_init_linux.go:185: exec user process caused "argument list too long"
// https://devblogs.microsoft.com/oldnewthing/20100203-00/?p=15083
maxSize := 32700 - len(string(actionData)) - 2000
if len(executionData) < maxSize {
log.Printf("ADDING FULL_EXECUTION because size is larger than %d", maxSize)
env = append(env, fmt.Sprintf("FULL_EXECUTION=%s", string(executionData)))
} else {
log.Printf("Skipping FULL_EXECUTION because size is larger than %d", maxSize)
} }
err = deployApp(dockercli, image, identifier, env) err = deployApp(dockercli, image, identifier, env)