0.8.72 release
This commit is contained in:
+42
-16
@@ -1708,23 +1708,21 @@ class AppBase:
|
||||
if values != None:
|
||||
added = 0
|
||||
for val in values:
|
||||
#print(f"VAL: {val}")
|
||||
#parameter["value"].replace(val["key"], val["value"], -1)
|
||||
#print(f'PARAM1: {action["parameters"][counter]["value"]}')
|
||||
action["parameters"][counter]["value"] = action["parameters"][counter]["value"].replace(val["key"], val["value"], 1)
|
||||
#action["parameters"][counter]["value"].replace(r"${url}", r"$Find_URLs.valid.#.data", 1)
|
||||
#print(f'PARAM2: {action["parameters"][counter]["value"]}')
|
||||
#newparams.append({
|
||||
# "name": val["key"],
|
||||
# "value": val["value"],
|
||||
# "variant": "STATIC_VALUE",
|
||||
# "id": "body_replacement",
|
||||
# "schema": {
|
||||
# "type": "string",
|
||||
# },
|
||||
#})
|
||||
replace_value = val["value"]
|
||||
replace_key = val["key"]
|
||||
if (val["value"].startswith("{") and val["value"].endswith("}")) or (val["value"].startswith("[") and val["value"].endswith("]")):
|
||||
print(f"""Trying to parse as JSON: {val["value"]}""")
|
||||
try:
|
||||
value_replace = json.loads(val["value"])
|
||||
# If it gets here, remove the "" infront and behind the key as well since this is preventing the JSON from being loaded
|
||||
replace_key = f"\"{replace_key}\""
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
print("Failed JSON replacement for OpenAPI %s", val["key"])
|
||||
elif val["value"].lower() == "true" or val["value"].lower() == "false":
|
||||
replace_key = f"\"{replace_key}\""
|
||||
|
||||
action["parameters"][counter]["value"] = action["parameters"][counter]["value"].replace(replace_key, replace_value, 1)
|
||||
|
||||
#print(f'[INFO] Added param {val["key"]} for body with value {val["value"]} (using OpenAPI)')
|
||||
print(f'[INFO] Added param {val["key"]} for body (using OpenAPI)')
|
||||
added += 1
|
||||
|
||||
@@ -1735,6 +1733,34 @@ class AppBase:
|
||||
print("KeyError body OpenAPI: %s" % e)
|
||||
pass
|
||||
|
||||
try:
|
||||
newvalue = json.loads(action["parameters"][counter]["value"])
|
||||
deletekeys = []
|
||||
for key, value in newvalue.items():
|
||||
if isinstance(value, str) and len(value) == 0:
|
||||
deletekeys.append(key)
|
||||
continue
|
||||
|
||||
for deletekey in deletekeys:
|
||||
del newvalue[deletekey]
|
||||
|
||||
action["parameters"][counter]["value"] = json.dumps(newvalue)
|
||||
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
print("Failed JSON replacement for OpenAPI keys (2) %s", val["key"])
|
||||
|
||||
#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"])
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
NAME=shuffle-app_sdk
|
||||
VERSION=0.8.71
|
||||
VERSION=0.8.72
|
||||
|
||||
docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force
|
||||
docker build . -t frikky/shuffle:app_sdk -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION
|
||||
|
||||
@@ -2,7 +2,7 @@ module shuffle
|
||||
|
||||
go 1.13
|
||||
|
||||
replace github.com/frikky/shuffle-shared => ../../../../git/shuffle-shared
|
||||
//replace github.com/frikky/shuffle-shared => ../../../../git/shuffle-shared
|
||||
|
||||
//replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi
|
||||
|
||||
@@ -20,7 +20,7 @@ require (
|
||||
github.com/docker/go-connections v0.4.0
|
||||
github.com/docker/go-units v0.4.0 // indirect
|
||||
github.com/frikky/kin-openapi v0.38.0
|
||||
github.com/frikky/shuffle-shared v0.0.23
|
||||
github.com/frikky/shuffle-shared v0.0.27
|
||||
github.com/ghodss/yaml v1.0.0
|
||||
github.com/go-git/go-billy/v5 v5.0.0
|
||||
github.com/go-git/go-git/v5 v5.0.0
|
||||
|
||||
+22
-2
@@ -10,6 +10,8 @@ import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
//"unicode/utf8"
|
||||
|
||||
"errors"
|
||||
"path/filepath"
|
||||
|
||||
@@ -4191,7 +4193,7 @@ func verifySwagger(resp http.ResponseWriter, request *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("[INFO] EDITING APP WITH ID %s", app.ID)
|
||||
log.Printf("[INFO] EDITING APP WITH ID %s and md5 %s", app.ID, newmd5)
|
||||
newmd5 = app.ID
|
||||
}
|
||||
|
||||
@@ -4199,11 +4201,29 @@ func verifySwagger(resp http.ResponseWriter, request *http.Request) {
|
||||
// Test = client side with fetch?
|
||||
|
||||
ctx := context.Background()
|
||||
//s := string(body)
|
||||
//if !utf8.ValidString(s) {
|
||||
// v := make([]rune, 0, len(s))
|
||||
// for i, r := range s {
|
||||
// if r == utf8.RuneError {
|
||||
// _, size := utf8.DecodeRuneInString(s[i:])
|
||||
// if size == 1 {
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
// v = append(v, r)
|
||||
// }
|
||||
// s = string(v)
|
||||
//}
|
||||
//fmt.Printf("%q\n", s)
|
||||
|
||||
//body = []byte(strings.Replace(string(body), '<80>', '', -1))
|
||||
|
||||
//log.Println(string(body))
|
||||
swaggerLoader := openapi3.NewSwaggerLoader()
|
||||
swaggerLoader.IsExternalRefsAllowed = true
|
||||
swagger, err := swaggerLoader.LoadSwaggerFromData(body)
|
||||
if err != nil {
|
||||
log.Println(string(body))
|
||||
log.Printf("[ERROR] Swagger validation error: %s", err)
|
||||
resp.WriteHeader(500)
|
||||
resp.Write([]byte(`{"success": false, "reason": "Failed verifying openapi"}`))
|
||||
|
||||
Reference in New Issue
Block a user