FIXES: Added wazuh integration and loads more
This commit is contained in:
+33
-18
@@ -606,11 +606,14 @@ class AppBase:
|
||||
if "len" in thistype or "length" in thistype or "lenght" in thistype:
|
||||
tmp = ""
|
||||
try:
|
||||
tmpdata = data.replace("\'", "\"")
|
||||
tmp = json.loads(tmpdata)
|
||||
except:
|
||||
print("Passing bug")
|
||||
pass
|
||||
try:
|
||||
tmpdata = data.replace("\'", "\"")
|
||||
tmp = json.loads(tmpdata)
|
||||
except:
|
||||
print("[ERROR] Parsing bug for length in app sdk")
|
||||
pass
|
||||
|
||||
if isinstance(tmp, list):
|
||||
return len(tmp)
|
||||
@@ -649,14 +652,14 @@ class AppBase:
|
||||
return tmp
|
||||
except IndexError as e:
|
||||
return default_error
|
||||
|
||||
|
||||
# Parses the INNER value and recurses until everything is done
|
||||
def parse_wrapper(data):
|
||||
try:
|
||||
if "(" not in data or ")" not in data:
|
||||
return data
|
||||
return (data, False)
|
||||
except TypeError:
|
||||
return data
|
||||
return (data, False)
|
||||
|
||||
#print("Running %s" % data)
|
||||
|
||||
@@ -671,7 +674,7 @@ class AppBase:
|
||||
break
|
||||
|
||||
if not found:
|
||||
return data
|
||||
return (data, False)
|
||||
|
||||
# Do stuff here.
|
||||
innervalue = parse_nested_param(data, maxDepth(data)-0)
|
||||
@@ -692,10 +695,11 @@ class AppBase:
|
||||
|
||||
parsed_value = parse_type(innervalue[0], thistype.lower())
|
||||
print("Parsed value from %s: %s" % (thistype, parsed_value))
|
||||
return parsed_value
|
||||
return (parsed_value, True)
|
||||
|
||||
print("DATA: %s\n" % data)
|
||||
return parse_wrapper(data)
|
||||
return (parse_wrapper(data)[0], True)
|
||||
|
||||
|
||||
# Looks for parantheses to grab special cases within a string, e.g:
|
||||
# int(1) lower(HELLO) or length(what's the length)
|
||||
@@ -737,15 +741,20 @@ class AppBase:
|
||||
if len(newstring) > 0:
|
||||
newdata.append(newstring)
|
||||
|
||||
print("Newdata: ", newdata)
|
||||
parsedlist = []
|
||||
non_string = False
|
||||
parsed = False
|
||||
for item in newdata:
|
||||
ret = parse_wrapper(item)
|
||||
if not isinstance(ret, str):
|
||||
if not isinstance(ret[0], str):
|
||||
non_string = True
|
||||
|
||||
parsedlist.append(ret)
|
||||
|
||||
parsedlist.append(ret[0])
|
||||
if ret[1]:
|
||||
parsed = True
|
||||
|
||||
if not parsed:
|
||||
return data
|
||||
|
||||
if len(parsedlist) > 0 and not non_string:
|
||||
print("Returning parsed list: ", parsedlist)
|
||||
@@ -949,7 +958,6 @@ class AppBase:
|
||||
if len(parsersplit) == 1:
|
||||
return str(baseresult)+str(appendresult), False
|
||||
|
||||
baseresult = baseresult.replace("\'", "\"")
|
||||
baseresult = baseresult.replace(" True,", " true,")
|
||||
baseresult = baseresult.replace(" False", " false,")
|
||||
|
||||
@@ -958,8 +966,12 @@ class AppBase:
|
||||
try:
|
||||
basejson = json.loads(baseresult)
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
print("Parser issue with JSON: %s" % e)
|
||||
return str(baseresult)+str(appendresult), False
|
||||
try:
|
||||
baseresult = baseresult.replace("\'", "\"")
|
||||
basejson = json.loads(baseresult)
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
print("Parser issue with JSON: %s" % e)
|
||||
return str(baseresult)+str(appendresult), False
|
||||
|
||||
print("After fourth parser return as JSON")
|
||||
|
||||
@@ -1365,14 +1377,17 @@ class AppBase:
|
||||
if replacement.startswith("\"") and replacement.endswith("\""):
|
||||
replacement = replacement[1:len(replacement)-1]
|
||||
|
||||
replacement = replacement.replace("\'", "\"", -1)
|
||||
print("POST replacement: %s" % replacement)
|
||||
|
||||
json_replacement = replacement
|
||||
try:
|
||||
json_replacement = json.loads(replacement)
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
print("JSON error singular: %s" % e)
|
||||
try:
|
||||
replacement = replacement.replace("\'", "\"", -1)
|
||||
json_replacement = json.loads(replacement)
|
||||
except:
|
||||
print("JSON error singular: %s" % e)
|
||||
|
||||
if len(json_replacement) > minlength:
|
||||
minlength = len(json_replacement)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
NAME=shuffle-app_sdk
|
||||
VERSION=0.8.32
|
||||
VERSION=0.8.4
|
||||
|
||||
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
|
||||
|
||||
@@ -230,6 +230,7 @@ func buildImageMemory(fs billy.Filesystem, tags []string, dockerfileFolder strin
|
||||
}
|
||||
|
||||
// Build the actual image
|
||||
log.Printf("Building %s. This may take up to a few minutes.", dockerfileFolder)
|
||||
imageBuildResponse, err := client.ImageBuild(
|
||||
ctx,
|
||||
dockerFileTarReader,
|
||||
|
||||
@@ -2483,7 +2483,7 @@ func handleLogin(resp http.ResponseWriter, request *http.Request) {
|
||||
if len(users) != 1 {
|
||||
log.Printf(`Found multiple or no users with the same username: %s: %d`, data.Username, len(users))
|
||||
resp.WriteHeader(401)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Found %d users with the same username: %s"}`, len(users), data.Username)))
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Error: %d users with username %s"}`, len(users), data.Username)))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4785,7 +4785,7 @@ func getDocList(resp http.ResponseWriter, request *http.Request) {
|
||||
|
||||
if len(item1) == 0 {
|
||||
resp.WriteHeader(500)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "No docs available."`)))
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "No docs available."}`)))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4844,7 +4844,7 @@ func getDocs(resp http.ResponseWriter, request *http.Request) {
|
||||
location := strings.Split(request.URL.String(), "/")
|
||||
if len(location) != 5 {
|
||||
resp.WriteHeader(404)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad path. Use e.g. /api/v1/docs/workflows.md"`)))
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad path. Use e.g. /api/v1/docs/workflows.md"}`)))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4868,7 +4868,7 @@ func getDocs(resp http.ResponseWriter, request *http.Request) {
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad path. Use e.g. /api/v1/docs/workflows.md"`)))
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad path. Use e.g. /api/v1/docs/workflows.md"}`)))
|
||||
resp.WriteHeader(404)
|
||||
//setBadMemcache(ctx, docPath)
|
||||
return
|
||||
@@ -4877,7 +4877,7 @@ func getDocs(resp http.ResponseWriter, request *http.Request) {
|
||||
newresp, err := client.Do(req)
|
||||
if err != nil {
|
||||
resp.WriteHeader(404)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad path. Use e.g. /api/v1/docs/workflows.md"`)))
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad path. Use e.g. /api/v1/docs/workflows.md"}`)))
|
||||
//setBadMemcache(ctx, docPath)
|
||||
return
|
||||
}
|
||||
@@ -4885,7 +4885,7 @@ func getDocs(resp http.ResponseWriter, request *http.Request) {
|
||||
body, err := ioutil.ReadAll(newresp.Body)
|
||||
if err != nil {
|
||||
resp.WriteHeader(500)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Can't parse data"`)))
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Can't parse data"}`)))
|
||||
//setBadMemcache(ctx, docPath)
|
||||
return
|
||||
}
|
||||
@@ -5958,7 +5958,7 @@ func echoOpenapiData(resp http.ResponseWriter, request *http.Request) {
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] URLbody error: %s", err)
|
||||
resp.WriteHeader(500)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Can't get data from selected uri"`)))
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Can't get data from selected uri"}`)))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -4015,7 +4015,7 @@ func deleteWorkflowApp(resp http.ResponseWriter, request *http.Request) {
|
||||
log.Printf("ID: %s", fileId)
|
||||
app, err := getApp(ctx, fileId)
|
||||
if err != nil {
|
||||
log.Printf("Error getting app %s: %s", app.Name, err)
|
||||
log.Printf("Error getting app (delete) %s: %s", fileId, err)
|
||||
resp.WriteHeader(401)
|
||||
resp.Write([]byte(`{"success": false}`))
|
||||
return
|
||||
@@ -4169,7 +4169,7 @@ func getWorkflowAppConfig(resp http.ResponseWriter, request *http.Request) {
|
||||
ctx := context.Background()
|
||||
app, err := getApp(ctx, fileId)
|
||||
if err != nil {
|
||||
log.Printf("Error getting app: %s", app.Name)
|
||||
log.Printf("Error getting app (app config): %s", fileId)
|
||||
resp.WriteHeader(401)
|
||||
resp.Write([]byte(`{"success": false}`))
|
||||
return
|
||||
@@ -4438,7 +4438,7 @@ func updateWorkflowAppConfig(resp http.ResponseWriter, request *http.Request) {
|
||||
ctx := context.Background()
|
||||
app, err := getApp(ctx, fileId)
|
||||
if err != nil {
|
||||
log.Printf("Error getting app: %s (update app)", app.Name)
|
||||
log.Printf("Error getting app (update app): %s", fileId)
|
||||
resp.WriteHeader(401)
|
||||
resp.Write([]byte(`{"success": false}`))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user