Added automated authentication selection if it exists
This commit is contained in:
+13
-12
@@ -1447,7 +1447,7 @@ class AppBase:
|
||||
params = {}
|
||||
try:
|
||||
for item in action["authentication"]:
|
||||
print("AUTH: ", key, value)
|
||||
#print("AUTH: ", key, value)
|
||||
params[item["key"]] = item["value"]
|
||||
except KeyError:
|
||||
print("No authentication specified!")
|
||||
@@ -1469,11 +1469,11 @@ class AppBase:
|
||||
if "||" in parameter["value"]:
|
||||
splitvalue = parameter["value"].split("||")
|
||||
if len(splitvalue) > 1:
|
||||
print(f'[INFO] Parsed split || options of actions["parameters"]["name"]')
|
||||
#print(f'[INFO] Parsed split || options of actions["parameters"]["name"]')
|
||||
action["parameters"][counter]["value"] = splitvalue[1]
|
||||
|
||||
except (IndexError, KeyError, TypeError) as e:
|
||||
print("Options err: {e}")
|
||||
print("[WARNING] Options err: {e}")
|
||||
|
||||
# This part is purely for OpenAPI accessibility.
|
||||
# It replaces the data back into the main item
|
||||
@@ -1487,12 +1487,12 @@ class AppBase:
|
||||
if values != None:
|
||||
added = 0
|
||||
for val in values:
|
||||
print(f"VAL: {val}")
|
||||
#print(f"VAL: {val}")
|
||||
#parameter["value"].replace(val["key"], val["value"], -1)
|
||||
print(f'PARAM1: {action["parameters"][counter]["value"]}')
|
||||
#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"]}')
|
||||
#print(f'PARAM2: {action["parameters"][counter]["value"]}')
|
||||
#newparams.append({
|
||||
# "name": val["key"],
|
||||
# "value": val["value"],
|
||||
@@ -1503,7 +1503,8 @@ class AppBase:
|
||||
# },
|
||||
#})
|
||||
|
||||
print(f'[INFO] Added param {val["key"]} for body with value {val["value"]} (using OpenAPI)')
|
||||
#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
|
||||
|
||||
#action["parameters"]["body"]
|
||||
@@ -1515,7 +1516,7 @@ class AppBase:
|
||||
|
||||
break
|
||||
|
||||
print(action["parameters"])
|
||||
#print(action["parameters"])
|
||||
for parameter in newparams:
|
||||
action["parameters"].append(parameter)
|
||||
|
||||
@@ -1841,10 +1842,10 @@ class AppBase:
|
||||
#print(f"Error with subparam deletion of {subparam} in {multi_parameters} (2)")
|
||||
pass
|
||||
|
||||
print()
|
||||
print(f"Param: {params}")
|
||||
print(f"Multiparams: {multi_parameters}")
|
||||
print()
|
||||
#print()
|
||||
#print(f"Param: {params}")
|
||||
#print(f"Multiparams: {multi_parameters}")
|
||||
#print()
|
||||
|
||||
if not multiexecution:
|
||||
#newparams.append({
|
||||
|
||||
@@ -6103,6 +6103,11 @@ func handleAppHotloadRequest(resp http.ResponseWriter, request *http.Request) {
|
||||
|
||||
log.Printf("[INFO] Starting app hotloading")
|
||||
|
||||
cacheKey := fmt.Sprintf("workflowapps-sorted-100")
|
||||
requestCache.Delete(cacheKey)
|
||||
cacheKey = fmt.Sprintf("workflowapps-sorted-500")
|
||||
requestCache.Delete(cacheKey)
|
||||
|
||||
// Just need to be logged in
|
||||
// FIXME - should have some permissions?
|
||||
user, err := handleApiAuthentication(resp, request)
|
||||
@@ -6135,6 +6140,11 @@ func handleAppHotloadRequest(resp http.ResponseWriter, request *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cacheKey = fmt.Sprintf("workflowapps-sorted-100")
|
||||
requestCache.Delete(cacheKey)
|
||||
cacheKey = fmt.Sprintf("workflowapps-sorted-500")
|
||||
requestCache.Delete(cacheKey)
|
||||
|
||||
resp.WriteHeader(200)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": true}`)))
|
||||
}
|
||||
@@ -6737,7 +6747,7 @@ func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra strin
|
||||
|
||||
if len(removeApps) > 0 {
|
||||
for _, item := range removeApps {
|
||||
log.Printf("[WARNING] Removing duplicate: %s", item)
|
||||
log.Printf("[WARNING] Removing duplicate app: %s", item)
|
||||
err = DeleteKey(ctx, "workflowapp", item)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Failed deleting duplicate %s: %s", item, err)
|
||||
@@ -6758,6 +6768,7 @@ func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra strin
|
||||
continue
|
||||
}
|
||||
|
||||
/*
|
||||
err = increaseStatisticsField(ctx, "total_apps_created", workflowapp.ID, 1, "")
|
||||
if err != nil {
|
||||
log.Printf("Failed to increase total apps created stats: %s", err)
|
||||
@@ -6767,6 +6778,7 @@ func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra strin
|
||||
if err != nil {
|
||||
log.Printf("Failed to increase total apps loaded stats: %s", err)
|
||||
}
|
||||
*/
|
||||
|
||||
//log.Printf("Added %s:%s to the database", workflowapp.Name, workflowapp.AppVersion)
|
||||
|
||||
@@ -6801,6 +6813,12 @@ func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra strin
|
||||
return buildLaterFirst, buildLaterList, err
|
||||
}
|
||||
|
||||
// This is getting silly
|
||||
cacheKey := fmt.Sprintf("workflowapps-sorted-100")
|
||||
requestCache.Delete(cacheKey)
|
||||
cacheKey = fmt.Sprintf("workflowapps-sorted-500")
|
||||
requestCache.Delete(cacheKey)
|
||||
|
||||
//log.Printf("BUILDLATERFIRST: %d, BUILDLATERLIST: %d", len(buildLaterFirst), len(buildLaterList))
|
||||
if len(extra) == 0 {
|
||||
log.Printf("[INFO] Starting build of %d containers (FIRST)", len(buildLaterFirst))
|
||||
@@ -6811,6 +6829,7 @@ func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra strin
|
||||
} else {
|
||||
if len(item.Tags) > 0 {
|
||||
log.Printf("[INFO] Successfully built image %s", item.Tags[0])
|
||||
|
||||
} else {
|
||||
log.Printf("[INFO] Successfully built Docker image")
|
||||
}
|
||||
|
||||
@@ -2450,7 +2450,8 @@ const AngularWorkflow = (props) => {
|
||||
authentication: [],
|
||||
execution_variable: undefined,
|
||||
example: example,
|
||||
category: app.categories !== null && app.categories !== undefined && app.categories.length > 0 ? app.categories[0] : ""
|
||||
category: app.categories !== null && app.categories !== undefined && app.categories.length > 0 ? app.categories[0] : "",
|
||||
authentication_id: "",
|
||||
}
|
||||
|
||||
// FIXME: overwrite category if the ACTION chosen has a different category
|
||||
@@ -2512,6 +2513,56 @@ const AngularWorkflow = (props) => {
|
||||
cy.add(edgeToBeAdded)
|
||||
}
|
||||
|
||||
// AUTHENTICATION
|
||||
if (app.authentication.required) {
|
||||
// Setup auth here :)
|
||||
const authenticationOptions = []
|
||||
var findAuthId = ""
|
||||
if (newAppData.authentication_id !== null && newAppData.authentication_id !== undefined && newAppData.authentication_id.length > 0) {
|
||||
findAuthId = newAppData.authentication_id
|
||||
}
|
||||
|
||||
var tmpAuth = JSON.parse(JSON.stringify(appAuthentication))
|
||||
for (var key in tmpAuth) {
|
||||
var item = tmpAuth[key]
|
||||
|
||||
const newfields = {}
|
||||
for (var filterkey in item.fields) {
|
||||
newfields[item.fields[filterkey].key] = item.fields[filterkey].value
|
||||
}
|
||||
|
||||
item.fields = newfields
|
||||
if (item.app.name === app.name) {
|
||||
authenticationOptions.push(item)
|
||||
if (item.id === findAuthId) {
|
||||
newAppData.selectedAuthentication = item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (authenticationOptions !== undefined && authenticationOptions !== null && authenticationOptions.length > 0) {
|
||||
for (var key in authenticationOptions) {
|
||||
const option = authenticationOptions[key]
|
||||
if (option.active) {
|
||||
newAppData.selectedAuthentication = option
|
||||
newAppData.authentication_id = option.id
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//newAppData.authentication = authenticationOptions
|
||||
//if (newAppData.selectedAuthentication === null || newAppData.selectedAuthentication === undefined || newAppData.selectedAuthentication.length === "") {
|
||||
// newAppData.selectedAuthentication = {}
|
||||
//} else {
|
||||
// console.log("CAN WE SELECT AUTH?: ", authenticationOptions)
|
||||
//}
|
||||
} else {
|
||||
newAppData.authentication = []
|
||||
newAppData.authentication_id = ""
|
||||
newAppData.selectedAuthentication = {}
|
||||
}
|
||||
|
||||
workflow.actions.push(newAppData)
|
||||
setWorkflow(workflow)
|
||||
|
||||
|
||||
@@ -2010,11 +2010,11 @@ const AppCreator = (props) => {
|
||||
const categories = [
|
||||
"Communication",
|
||||
"Cases",
|
||||
"EDR",
|
||||
"Intel",
|
||||
"SIEM",
|
||||
"Network",
|
||||
"Assets",
|
||||
"Intel",
|
||||
"IAM",
|
||||
"Network",
|
||||
"Eradication",
|
||||
"Other",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user