Lots of minor fixes
This commit is contained in:
@@ -66,7 +66,7 @@ class AppBase:
|
|||||||
self.logger.info(ret.text)
|
self.logger.info(ret.text)
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
#self.logger.exception("ConnectionError: %s" % e)
|
#self.logger.exception("ConnectionError: %s" % e)
|
||||||
self.logger.exception("Expected connectionerror happened")
|
self.logger.exception("Expected ConnectionError happened")
|
||||||
return
|
return
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
#self.logger.exception(e)
|
#self.logger.exception(e)
|
||||||
@@ -78,7 +78,7 @@ class AppBase:
|
|||||||
if ret.status_code != 200:
|
if ret.status_code != 200:
|
||||||
self.logger.info(ret.text)
|
self.logger.info(ret.text)
|
||||||
except http.client.RemoteDisconnected as e:
|
except http.client.RemoteDisconnected as e:
|
||||||
self.logger.exception("Expected connectionerror happened")
|
self.logger.exception("Expected Remotedisconnect happened")
|
||||||
return
|
return
|
||||||
|
|
||||||
async def cartesian_product(self, L):
|
async def cartesian_product(self, L):
|
||||||
@@ -432,7 +432,7 @@ class AppBase:
|
|||||||
|
|
||||||
content_path = "/api/v1/files/%s/content?execution_id=%s" % (item, full_execution["execution_id"])
|
content_path = "/api/v1/files/%s/content?execution_id=%s" % (item, full_execution["execution_id"])
|
||||||
ret2 = requests.get("%s%s" % (self.url, content_path), headers=headers)
|
ret2 = requests.get("%s%s" % (self.url, content_path), headers=headers)
|
||||||
print("RET2 (file get): %s" % ret2.text)
|
print("RET2 (file get) done")
|
||||||
if ret2.status_code == 200:
|
if ret2.status_code == 200:
|
||||||
tmpdata = ret1.json()
|
tmpdata = ret1.json()
|
||||||
returndata = {
|
returndata = {
|
||||||
@@ -1721,7 +1721,7 @@ class AppBase:
|
|||||||
#})
|
#})
|
||||||
|
|
||||||
#print("[INFO] APP_SDK DONE: Starting NORMAL execution of function")
|
#print("[INFO] APP_SDK DONE: Starting NORMAL execution of function")
|
||||||
print("[INFO] Running execition\n")
|
print("[INFO] Running normal execution\n")
|
||||||
newres = await func(**params)
|
newres = await func(**params)
|
||||||
print("\n[INFO] Returned from execution:", newres)
|
print("\n[INFO] Returned from execution:", newres)
|
||||||
if isinstance(newres, tuple):
|
if isinstance(newres, tuple):
|
||||||
|
|||||||
@@ -418,11 +418,14 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
|
|||||||
fileBalance,
|
fileBalance,
|
||||||
)
|
)
|
||||||
|
|
||||||
if strings.Contains(functionname, "filescan") {
|
// Use lowercase when checking
|
||||||
//log.Printf("FUNCTION: %s", data)
|
/*
|
||||||
log.Println(data)
|
if strings.Contains(functionname, "filter") {
|
||||||
log.Printf("Queries: %s", queryString)
|
//log.Printf("FUNCTION: %s", data)
|
||||||
}
|
log.Println(data)
|
||||||
|
log.Printf("Queries: %s", queryString)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//log.Printf(data)
|
//log.Printf(data)
|
||||||
return functionname, data
|
return functionname, data
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ func buildImage(tags []string, dockerfileFolder string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Tags: %s", tags)
|
log.Printf("[INFO] Docker Tags: %s", tags)
|
||||||
dockerfileSplit := strings.Split(dockerfileFolder, "/")
|
dockerfileSplit := strings.Split(dockerfileFolder, "/")
|
||||||
|
|
||||||
// Create a buffer
|
// Create a buffer
|
||||||
|
|||||||
@@ -6360,13 +6360,13 @@ func verifySwagger(resp http.ResponseWriter, request *http.Request) {
|
|||||||
|
|
||||||
// FIXME: Check whether it's in use.
|
// FIXME: Check whether it's in use.
|
||||||
if user.Id != app.Owner && user.Role != "admin" {
|
if user.Id != app.Owner && user.Role != "admin" {
|
||||||
log.Printf("Wrong user (%s) for app %s when verifying swagger", user.Username, app.Name)
|
log.Printf("[WARNING] Wrong user (%s) for app %s when verifying swagger", user.Username, app.Name)
|
||||||
resp.WriteHeader(401)
|
resp.WriteHeader(401)
|
||||||
resp.Write([]byte(`{"success": false}`))
|
resp.Write([]byte(`{"success": false}`))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("EDITING APP WITH ID %s", app.ID)
|
log.Printf("[INFO] EDITING APP WITH ID %s", app.ID)
|
||||||
newmd5 = app.ID
|
newmd5 = app.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6455,7 +6455,7 @@ func verifySwagger(resp http.ResponseWriter, request *http.Request) {
|
|||||||
|
|
||||||
identifier = strings.Replace(identifier, " ", "-", -1)
|
identifier = strings.Replace(identifier, " ", "-", -1)
|
||||||
identifier = strings.Replace(identifier, "_", "-", -1)
|
identifier = strings.Replace(identifier, "_", "-", -1)
|
||||||
log.Printf("Successfully parsed %s. Proceeding to docker container", identifier)
|
log.Printf("[INFO] Successfully parsed %s. Proceeding to docker container", identifier)
|
||||||
|
|
||||||
// Now that the baseline is setup, we need to make it into a cloud function
|
// Now that the baseline is setup, we need to make it into a cloud function
|
||||||
// 1. Upload the API to datastore for use
|
// 1. Upload the API to datastore for use
|
||||||
@@ -7517,7 +7517,7 @@ func runInit(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Downloading OpenAPI data for search - EXTRA APPS")
|
log.Printf("[INFO] Downloading OpenAPI data for search - EXTRA APPS")
|
||||||
apis := "https://github.com/frikky/security-openapis"
|
apis := "https://github.com/frikky/security-openapis"
|
||||||
|
|
||||||
// THis gets memory problems hahah
|
// THis gets memory problems hahah
|
||||||
|
|||||||
+70
-12
@@ -2062,7 +2062,7 @@ func updateAppAuth(auth AppAuthenticationStorage, workflowId, nodeId string, add
|
|||||||
// FIXME: Add a way to use !add to remove
|
// FIXME: Add a way to use !add to remove
|
||||||
updateAuth := false
|
updateAuth := false
|
||||||
if !workflowFound && add {
|
if !workflowFound && add {
|
||||||
log.Printf("Adding workflow things to auth!")
|
log.Printf("[INFO] Adding workflow things to auth!")
|
||||||
usageItem := AuthenticationUsage{
|
usageItem := AuthenticationUsage{
|
||||||
WorkflowId: workflowId,
|
WorkflowId: workflowId,
|
||||||
Nodes: []string{nodeId},
|
Nodes: []string{nodeId},
|
||||||
@@ -2073,14 +2073,14 @@ func updateAppAuth(auth AppAuthenticationStorage, workflowId, nodeId string, add
|
|||||||
auth.NodeCount += 1
|
auth.NodeCount += 1
|
||||||
updateAuth = true
|
updateAuth = true
|
||||||
} else if !nodeFound && add {
|
} else if !nodeFound && add {
|
||||||
log.Printf("Adding node things to auth!")
|
log.Printf("[INFO] Adding node things to auth!")
|
||||||
auth.Usage[workflowIndex].Nodes = append(auth.Usage[workflowIndex].Nodes, nodeId)
|
auth.Usage[workflowIndex].Nodes = append(auth.Usage[workflowIndex].Nodes, nodeId)
|
||||||
auth.NodeCount += 1
|
auth.NodeCount += 1
|
||||||
updateAuth = true
|
updateAuth = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if updateAuth {
|
if updateAuth {
|
||||||
log.Printf("Updating auth!")
|
log.Printf("[INFO] Updating auth!")
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
err := setWorkflowAppAuthDatastore(ctx, auth, auth.Id)
|
err := setWorkflowAppAuthDatastore(ctx, auth, auth.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -4825,7 +4825,7 @@ func getWorkflowAppConfig(resp http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Getting app %s (OpenAPI)", fileId)
|
log.Printf("[INFO] Getting app %s (OpenAPI)", fileId)
|
||||||
parsedApi, err := getOpenApiDatastore(ctx, fileId)
|
parsedApi, err := getOpenApiDatastore(ctx, fileId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("OpenApi doesn't exist for: %s - err: %s", fileId, err)
|
log.Printf("OpenApi doesn't exist for: %s - err: %s", fileId, err)
|
||||||
@@ -6813,18 +6813,76 @@ func getWorkflowExecutions(resp http.ResponseWriter, request *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Query for the specifci workflowId
|
// Query for the specifci workflowId
|
||||||
q := datastore.NewQuery("workflowexecution").Filter("workflow_id =", fileId).Order("-started_at").Limit(30)
|
maxAmount := 30
|
||||||
|
q := datastore.NewQuery("workflowexecution").Filter("workflow_id =", fileId).Order("-started_at").Limit(maxAmount)
|
||||||
var workflowExecutions []WorkflowExecution
|
var workflowExecutions []WorkflowExecution
|
||||||
_, err = dbclient.GetAll(ctx, q, &workflowExecutions)
|
_, err = dbclient.GetAll(ctx, q, &workflowExecutions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
if strings.Contains(fmt.Sprintf("%s", err), "ResourceExhausted") {
|
if strings.Contains(fmt.Sprintf("%s", err), "ResourceExhausted") {
|
||||||
q = datastore.NewQuery("workflowexecution").Filter("workflow_id =", fileId).Order("-started_at").Limit(15)
|
q = datastore.NewQuery("workflowexecution").Filter("workflow_id =", fileId).Order("-started_at").Limit(1)
|
||||||
_, err = dbclient.GetAll(ctx, q, &workflowExecutions)
|
/*
|
||||||
if err != nil {
|
_, err = dbclient.GetAll(ctx, q, &workflowExecutions)
|
||||||
log.Printf("Error getting workflowexec (2): %s", err)
|
if err != nil {
|
||||||
resp.WriteHeader(401)
|
log.Printf("Error getting workflowexec (2): %s", err)
|
||||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed getting all workflowexecutions for %s"}`, fileId)))
|
resp.WriteHeader(401)
|
||||||
return
|
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed getting all workflowexecutions for %s"}`, fileId)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
cursorStr := ""
|
||||||
|
for {
|
||||||
|
it := dbclient.Run(ctx, q)
|
||||||
|
//_, err = it.Next(&app)
|
||||||
|
for {
|
||||||
|
var workflowExecution WorkflowExecution
|
||||||
|
_, err := it.Next(&workflowExecution)
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
workflowExecutions = append(workflowExecutions, workflowExecution)
|
||||||
|
}
|
||||||
|
|
||||||
|
//log.Printf("Len: %d", len(workflowExecutions))
|
||||||
|
if len(workflowExecutions) > maxAmount {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
nextCursor, err := it.Cursor()
|
||||||
|
if err != iterator.Done && err != nil {
|
||||||
|
if strings.Contains(fmt.Sprintf("%s", err), "ResourceExhausted") {
|
||||||
|
//log.Printf("NEXT!")
|
||||||
|
nextStr := fmt.Sprintf("%s", nextCursor)
|
||||||
|
if cursorStr == nextStr {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
cursorStr = nextStr
|
||||||
|
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
log.Printf("BREAK: %s", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Cursorerror: %s", err)
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
//log.Printf("NEXTCURSOR: %s", nextCursor)
|
||||||
|
nextStr := fmt.Sprintf("%s", nextCursor)
|
||||||
|
if cursorStr == nextStr {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
cursorStr = nextStr
|
||||||
|
q = q.Start(nextCursor)
|
||||||
|
//cursorStr = nextCursor
|
||||||
|
//break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Error getting workflowexec: %s", err)
|
log.Printf("Error getting workflowexec: %s", err)
|
||||||
|
|||||||
@@ -785,7 +785,7 @@ const AngularWorkflow = (props) => {
|
|||||||
setSavingState(1)
|
setSavingState(1)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setSavingState(0)
|
setSavingState(0)
|
||||||
}, 2000);
|
}, 1500);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|||||||
@@ -926,6 +926,7 @@ const AppCreator = (props) => {
|
|||||||
//console.log(queryitem)
|
//console.log(queryitem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//data.paths[item.url][item.method.toLowerCase()].parameters.push(newitem)
|
||||||
|
|
||||||
if (item.paths.length > 0) {
|
if (item.paths.length > 0) {
|
||||||
for (querykey in item.paths) {
|
for (querykey in item.paths) {
|
||||||
@@ -1828,13 +1829,19 @@ const AppCreator = (props) => {
|
|||||||
}}
|
}}
|
||||||
onBlur={event => {
|
onBlur={event => {
|
||||||
var parsedurl = event.target.value
|
var parsedurl = event.target.value
|
||||||
|
console.log("URL: ", parsedurl)
|
||||||
|
if (parsedurl.includes("<") && parsedurl.includes(">")) {
|
||||||
|
console.log("REPLACE")
|
||||||
|
parsedurl = parsedurl.replace("<", "{")
|
||||||
|
parsedurl = parsedurl.replace(">", "}")
|
||||||
|
}
|
||||||
|
|
||||||
if (parsedurl.startsWith("PUT ") || parsedurl.startsWith("GET ") ||parsedurl.startsWith("POST ") || parsedurl.startsWith("DELETE ") ||parsedurl.startsWith("PATCH ") || parsedurl.startsWith("CONNECT ")) {
|
if (parsedurl.startsWith("PUT ") || parsedurl.startsWith("GET ") ||parsedurl.startsWith("POST ") || parsedurl.startsWith("DELETE ") ||parsedurl.startsWith("PATCH ") || parsedurl.startsWith("CONNECT ")) {
|
||||||
const tmp = parsedurl.split(" ")
|
const tmp = parsedurl.split(" ")
|
||||||
|
|
||||||
if (tmp.length > 1) {
|
if (tmp.length > 1) {
|
||||||
parsedurl = tmp[1]
|
parsedurl = tmp[1]
|
||||||
setActionField("url", parsedurl)
|
setActionField("url", parsedurl)
|
||||||
setUrlPath(parsedurl)
|
|
||||||
|
|
||||||
setCurrentActionMethod(tmp[0].toUpperCase())
|
setCurrentActionMethod(tmp[0].toUpperCase())
|
||||||
setActionField("method", tmp[0].toUpperCase())
|
setActionField("method", tmp[0].toUpperCase())
|
||||||
@@ -1900,12 +1907,15 @@ const AppCreator = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check URL query && headers
|
// Check URL query && headers
|
||||||
setActionField("url", parsedurl)
|
//setActionField("url", parsedurl)
|
||||||
setUrlPath(parsedurl)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.target.value !== parsedurl) {
|
||||||
|
setUrlPath(parsedurl)
|
||||||
|
setActionField("url", parsedurl)
|
||||||
|
}
|
||||||
//console.log("URL: ", request.url)
|
//console.log("URL: ", request.url)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -1980,7 +1990,7 @@ const AppCreator = (props) => {
|
|||||||
<Button color="primary" variant="outlined" style={{borderRadius: "0px"}} onClick={() => {
|
<Button color="primary" variant="outlined" style={{borderRadius: "0px"}} onClick={() => {
|
||||||
//console.log(urlPathQueries)
|
//console.log(urlPathQueries)
|
||||||
//console.log(urlPath)
|
//console.log(urlPath)
|
||||||
//console.log(currentAction)
|
console.log(currentAction)
|
||||||
const errors = getActionErrors()
|
const errors = getActionErrors()
|
||||||
addActionToView(errors)
|
addActionToView(errors)
|
||||||
setActionsModalOpen(false)
|
setActionsModalOpen(false)
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ const Apps = (props) => {
|
|||||||
return response.json()
|
return response.json()
|
||||||
})
|
})
|
||||||
.then((responseJson) => {
|
.then((responseJson) => {
|
||||||
console.log("Apps: ", responseJson)
|
//console.log("Apps: ", responseJson)
|
||||||
responseJson = sortByKey(responseJson, "large_image")
|
responseJson = sortByKey(responseJson, "large_image")
|
||||||
|
|
||||||
setApps(responseJson)
|
setApps(responseJson)
|
||||||
|
|||||||
Reference in New Issue
Block a user