Fixed OpenAPI body parser auto-casting
This commit is contained in:
+48
-14
@@ -757,6 +757,9 @@ class AppBase:
|
||||
#return value.json()
|
||||
return {"success": False}
|
||||
|
||||
def set_file(self, infiles):
|
||||
return self.set_files(infiles)
|
||||
|
||||
# Sets files in the backend
|
||||
def set_files(self, infiles):
|
||||
full_execution = self.full_execution
|
||||
@@ -1009,6 +1012,34 @@ class AppBase:
|
||||
return data.strip()
|
||||
if "split" in thistype:
|
||||
return data.split()
|
||||
if "replace" in thistype:
|
||||
print("Running replace!")
|
||||
splitvalues = data.split(",")
|
||||
|
||||
if len(splitvalues) > 2:
|
||||
for i in range(len(splitvalues)):
|
||||
if i != 0:
|
||||
if splitvalues[i] == " ":
|
||||
splitvalues[i] = " "
|
||||
continue
|
||||
|
||||
splitvalues[i] = splitvalues[i].strip()
|
||||
|
||||
if splitvalues[i] == "\"\"":
|
||||
splitvalues[i] = ""
|
||||
if splitvalues[i] == "\" \"":
|
||||
splitvalues[i] = " "
|
||||
if len(splitvalues[i]) > 2:
|
||||
if splitvalues[i][0] == "\"" and splitvalues[i][len(splitvalues[i])-1] == "\"":
|
||||
splitvalues[i] = splitvalues[i][1:-1]
|
||||
if splitvalues[i][0] == "'" and splitvalues[i][len(splitvalues[i])-1] == "'":
|
||||
splitvalues[i] = splitvalues[i][1:-1]
|
||||
|
||||
|
||||
replacementvalue = splitvalues[0]
|
||||
return replacementvalue.replace(splitvalues[1], splitvalues[2], -1)
|
||||
else:
|
||||
return f"replace({data})"
|
||||
if "join" in thistype:
|
||||
print(f"SHOULD JOIN: {data}")
|
||||
try:
|
||||
@@ -1104,8 +1135,7 @@ class AppBase:
|
||||
except TypeError:
|
||||
return data, False
|
||||
|
||||
wrappers = ["int", "number", "lower", "upper", "trim", "strip", "split", "parse", "len", "length", "lenght",
|
||||
"join"]
|
||||
wrappers = ["int", "number", "lower", "upper", "trim", "strip", "split", "parse", "len", "length", "lenght", "join", "replace"]
|
||||
|
||||
if not any(wrapper in data for wrapper in wrappers):
|
||||
return data, False
|
||||
@@ -2051,34 +2081,38 @@ class AppBase:
|
||||
print("KeyError body OpenAPI: %s" % e)
|
||||
pass
|
||||
|
||||
|
||||
print(f"""HANDLING {action["parameters"][counter]["value"]}""")
|
||||
try:
|
||||
newvalue = json.loads(action["parameters"][counter]["value"])
|
||||
deletekeys = []
|
||||
for key, value in newvalue.items():
|
||||
print(key, value)
|
||||
if isinstance(value, str) and len(value) == 0:
|
||||
deletekeys.append(key)
|
||||
continue
|
||||
|
||||
if value == "${%s}" % key:
|
||||
print("Deleting %s because key = value")
|
||||
deletekeys.append(key)
|
||||
continue
|
||||
|
||||
for deletekey in deletekeys:
|
||||
del newvalue[deletekey]
|
||||
|
||||
print("Post delete: %s" % newvalue)
|
||||
for key, value in newvalue.items():
|
||||
try:
|
||||
value = json.loads(value)
|
||||
newvalue[key] = value
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
print("Inner overwrite issue: %s" % e)
|
||||
|
||||
action["parameters"][counter]["value"] = json.dumps(newvalue)
|
||||
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
print("Failed JSON replacement for OpenAPI keys (2) {e}")
|
||||
|
||||
#if "\n" in action["parameters"][counter]["value"]:
|
||||
# print("MODIFYING BODY!!")
|
||||
# newbody = ""
|
||||
# for line in action["parameters"][counter]["value"].split("\n"):
|
||||
# if ": \"\"" in line:
|
||||
# print("Skipping line %s" % line)
|
||||
# continue
|
||||
|
||||
# newbody += line
|
||||
|
||||
# print("New body: %s" % newbody)
|
||||
|
||||
break
|
||||
|
||||
#print(action["parameters"])
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
### DEFAULT
|
||||
NAME=shuffle-app_sdk
|
||||
VERSION=0.9.14
|
||||
VERSION=0.9.15
|
||||
|
||||
docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force
|
||||
docker build . -f Dockerfile -t frikky/shuffle:app_sdk -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION
|
||||
|
||||
@@ -3565,7 +3565,9 @@ func IterateAppGithubFolders(ctx context.Context, fs billy.Filesystem, dir []os.
|
||||
"OWA",
|
||||
"NLP",
|
||||
"YARA",
|
||||
"ATTACK-PREDICTOR",
|
||||
}
|
||||
//if strings.ToUpper(workflowapp.Name) == strings.ToUpper(appname) {
|
||||
|
||||
// It's here to prevent getting them in every iteration
|
||||
buildLaterFirst := []shuffle.BuildLaterStruct{}
|
||||
|
||||
@@ -1326,7 +1326,7 @@ const ParsedAction = (props) => {
|
||||
</Tooltip>
|
||||
</div>
|
||||
*/}
|
||||
{(selectedActionParameters[count].options !== undefined && selectedActionParameters[count].options !== null && selectedActionParameters[count].options.length > 0 && selectedActionParameters[count].required === true && selectedActionParameters[count].unique_toggled !== undefined) || hideExtraTypes ? null :
|
||||
{/*(selectedActionParameters[count].options !== undefined && selectedActionParameters[count].options !== null && selectedActionParameters[count].options.length > 0 && selectedActionParameters[count].required === true && selectedActionParameters[count].unique_toggled !== undefined) || hideExtraTypes ? null :
|
||||
<div style={{display: "flex"}}>
|
||||
<Tooltip color="secondary" title="Value must be unique" placement="top">
|
||||
<div style={{cursor: "pointer", color: staticcolor}} onClick={(e) => {}}>
|
||||
@@ -1349,7 +1349,7 @@ const ParsedAction = (props) => {
|
||||
</div>
|
||||
</Tooltip>
|
||||
</div>
|
||||
}
|
||||
*/}
|
||||
</div>
|
||||
{datafield}
|
||||
{showDropdown && showDropdownNumber === count && data.variant === "STATIC_VALUE" && jsonList.length > 0 ?
|
||||
|
||||
@@ -91,10 +91,10 @@ export const GetIconInfo = (action) => {
|
||||
{"key": "merge", "values": ["join", "merge"]},
|
||||
{"key": "search", "values": ["search", "find", "locate", "index", "analyze", "anal", "match"]},
|
||||
{"key": "list", "values": ["list", "head", "options"]},
|
||||
{"key": "download", "values": ["capture", "get", "download", "return", "hello_world", "curl", "request", ]},
|
||||
{"key": "download", "values": ["capture", "get", "download", "return", "hello_world", "curl", "request", "export", "preview"]},
|
||||
{"key": "add", "values": ["add"]},
|
||||
{"key": "delete", "values": ["delete", "remove", "clear", "clean",]},
|
||||
{"key": "send", "values": ["send", "dispatch", "mail", "forward", "post", "submit", "mark", "set"]},
|
||||
{"key": "send", "values": ["send", "dispatch", "mail", "forward", "post", "submit", "mark", "set", "release", ]},
|
||||
{"key": "repeat", "values": ["repeat", "retry", "pause", "skip", "copy", "replicat", ]},
|
||||
{"key": "execute", "values": ["execute", "run", "play", "raise",]},
|
||||
{"key": "extract", "values": ["extract", "unpack", "decompress", "open"]},
|
||||
|
||||
@@ -3,7 +3,7 @@ import urllib.parse
|
||||
import requests
|
||||
import os
|
||||
|
||||
#print('Loading function')
|
||||
print('Loading function')
|
||||
|
||||
def lambda_handler(event, context):
|
||||
#print("Received event: " + json.dumps(event, indent=2))
|
||||
|
||||
Reference in New Issue
Block a user