diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 7d6f8455..72fa2ae8 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4888,7 +4888,7 @@ func runInit(ctx context.Context) { cloneOptions.ReferenceName = plumbing.ReferenceName(branch) } - log.Printf("Getting apps from %s", url) + log.Printf("[DEBUG] Getting apps from %s", url) r, err := git.Clone(storer, fs, cloneOptions) @@ -5793,20 +5793,28 @@ func initHandlers() { r.HandleFunc("/api/v1/validate_openapi", shuffle.ValidateSwagger).Methods("POST", "OPTIONS") r.HandleFunc("/api/v1/get_openapi/{key}", getOpenapi).Methods("GET", "OPTIONS") - // NEW for 0.8.0 + // Specific triggers + r.HandleFunc("/api/v1/triggers/outlook/register", handleNewOutlookRegister).Methods("GET", "OPTIONS") + r.HandleFunc("/api/v1/triggers/outlook/getFolders", shuffle.HandleGetOutlookFolders).Methods("GET", "OPTIONS") + r.HandleFunc("/api/v1/triggers/outlook/{key}", handleGetSpecificTrigger).Methods("GET", "OPTIONS") + //r.HandleFunc("/api/v1/triggers/outlook/{key}/callback", handleOutlookCallback).Methods("POST", "OPTIONS") + //r.HandleFunc("/api/v1/stats/{key}", handleGetSpecificStats).Methods("GET", "OPTIONS") + + // EVERYTHING below here is NEW for 0.8.0 (written 25.05.2021) r.HandleFunc("/api/v1/workflows/{key}/publish", makeWorkflowPublic).Methods("POST", "OPTIONS") r.HandleFunc("/api/v1/cloud/setup", handleCloudSetup).Methods("POST", "OPTIONS") r.HandleFunc("/api/v1/orgs", shuffle.HandleGetOrgs).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/orgs/", shuffle.HandleGetOrgs).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/orgs/{orgId}", shuffle.HandleGetOrg).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/orgs/{orgId}", shuffle.HandleEditOrg).Methods("POST", "OPTIONS") + // This is a new API that validates if a key has been seen before. // Not sure what the best course of action is for it. r.HandleFunc("/api/v1/orgs/{orgId}/validate_app_values", shuffle.HandleKeyValueCheck).Methods("POST", "OPTIONS") + r.HandleFunc("/api/v1/orgs/{orgId}/get_cache", shuffle.HandleGetCacheKey).Methods("POST", "OPTIONS") + r.HandleFunc("/api/v1/orgs/{orgId}/set_cache", shuffle.HandleSetCacheKey).Methods("POST", "OPTIONS") - //r.HandleFunc("/api/v1/orgs/{orgId}", handleEditOrg).Methods("POST", "OPTIONS") - - // Docker orborus specific + // Docker orborus specific - downloads an image r.HandleFunc("/api/v1/get_docker_image", getDockerImage).Methods("POST", "OPTIONS") //r.HandleFunc("/api/v1/migrate_database", migrateDatabase).Methods("POST", "OPTIONS") @@ -5821,13 +5829,6 @@ func initHandlers() { r.HandleFunc("/api/v1/files/{fileId}", shuffle.HandleDeleteFile).Methods("DELETE", "OPTIONS") r.HandleFunc("/api/v1/files", shuffle.HandleGetFiles).Methods("GET", "OPTIONS") - // Trigger hmm - r.HandleFunc("/api/v1/triggers/outlook/register", handleNewOutlookRegister).Methods("GET", "OPTIONS") - r.HandleFunc("/api/v1/triggers/outlook/getFolders", shuffle.HandleGetOutlookFolders).Methods("GET", "OPTIONS") - r.HandleFunc("/api/v1/triggers/outlook/{key}", handleGetSpecificTrigger).Methods("GET", "OPTIONS") - //r.HandleFunc("/api/v1/triggers/outlook/{key}/callback", handleOutlookCallback).Methods("POST", "OPTIONS") - //r.HandleFunc("/api/v1/stats/{key}", handleGetSpecificStats).Methods("GET", "OPTIONS") - http.Handle("/", r) } diff --git a/backend/tests/cache.sh b/backend/tests/cache.sh new file mode 100644 index 00000000..401d9ce1 --- /dev/null +++ b/backend/tests/cache.sh @@ -0,0 +1,15 @@ +curl -XPOST http://192.168.3.8:5001/api/v1/orgs/6a6a99f5-6630-4f91-88ff-571c9f030ea0/set_cache -H "Authorization: Bearer e663cf93-7f10-4560-bef0-303f14aad982" -d '{ + "workflow_id": "61825389-a125-43a5-9119-97c401e9934b", + "execution_id": "2c8ca1b7-6658-4742-86a1-105c9467702d", + "org_id": "6a6a99f5-6630-4f91-88ff-571c9f030ea0", + "key": "test", + "value": "THIS IS SOME DATA HELLO" +}' + +curl -XPOST http://192.168.3.8:5001/api/v1/orgs/6a6a99f5-6630-4f91-88ff-571c9f030ea0/get_cache -H "Authorization: Bearer e663cf93-7f10-4560-bef0-303f14aad982" -d '{ + "workflow_id": "61825389-a125-43a5-9119-97c401e9934b", + "execution_id": "2c8ca1b7-6658-4742-86a1-105c9467702d", + "org_id": "6a6a99f5-6630-4f91-88ff-571c9f030ea0", + "key": "test" +}' + diff --git a/frontend/src/views/AppCreator.jsx b/frontend/src/views/AppCreator.jsx index 873ec947..0f0981d0 100644 --- a/frontend/src/views/AppCreator.jsx +++ b/frontend/src/views/AppCreator.jsx @@ -871,16 +871,18 @@ const AppCreator = (props) => { } } + + console.log("SECURITYSCHEMES: ", securitySchemes) if (securitySchemes !== undefined) { // FIXME: Should add Oauth2 (Microsoft) and JWT (Wazuh) //console.log("SECURITY: ", securitySchemes) //if (Object.entries(securitySchemes) > 1 && + var newauth = [] for (const [key, value] of Object.entries(securitySchemes)) { if (value.scheme === "bearer") { setAuthenticationOption("Bearer auth") setAuthenticationRequired(true) - break - } else if (value.type === "apiKey") { + } else if (key === "ApiKeyAuth") { setAuthenticationOption("API key") value.in = value.in.charAt(0).toUpperCase() + value.in.slice(1); @@ -893,17 +895,24 @@ const AppCreator = (props) => { console.log("PARAM NAME: ", value.name) setParameterName(value.name) setAuthenticationRequired(true) - break } else if (value.scheme === "basic") { setAuthenticationOption("Basic auth") setAuthenticationRequired(true) - break } else if (value.scheme === "oauth2") { setAuthenticationOption("Oauth2") setAuthenticationRequired(true) - break + } else { + newauth.push({ + "name": key, + "type": value.in, + "example": "", + }) } } + + if (newauth.length > 0) { + setExtraAuth(newauth) + } } if (newActions.length > increaseAmount-1) { @@ -1445,20 +1454,22 @@ const AppCreator = (props) => { //console.log("Name: ", parameterName) const extraKeys =
- Extra headers or queries - {extraAuth.length === 0 ? - - : } +
+ Extra authentication options + {extraAuth.length === 0 ? + + : } +
{extraAuth.map((value, index) => { return ( - + { {"key": "download", "values": ["get", "download", "return", "hello_world", "curl",]}, {"key": "search", "values": ["search", "find"]}, {"key": "delete", "values": ["delete", "remove"]}, - {"key": "send", "values": ["send", "dispatch", "mail", "forward", "post", "submit", "mark"]}, + {"key": "send", "values": ["send", "dispatch", "mail", "forward", "post", "submit", "mark", "set"]}, {"key": "repeat", "values": ["repeat", "retry", "pause",]}, {"key": "execute", "values": ["execute", "run", "play", "raise",]}, {"key": "extract", "values": ["extract", "unpack", "decompress"]}, diff --git a/functions/extensions/wazuh/custom-shuffle.py b/functions/extensions/wazuh/custom-shuffle.py index 06fa4c7d..e7900a4d 100644 --- a/functions/extensions/wazuh/custom-shuffle.py +++ b/functions/extensions/wazuh/custom-shuffle.py @@ -74,8 +74,7 @@ def debug(msg): # Skips container kills to stop self-recursion def filter_msg(alert): # These are things that recursively happen because Shuffle starts Docker containers - # Docker integration rules: https://github.com/wazuh/wazuh-ruleset/blob/ae36745db1d3f312db0392f5925c2f2b0ec009a9/rules/0560-docker_integration_rules.xml - skip = ["87924", "87900", "87901", "87902", "87903", "87904", "86001", "86002", "86003", "87932", "80710", "87929", "87928",] + skip = ["87924", "87900", "87901", "87902", "87903", "87904", "86001", "86002", "86003", "87932", "80710", "87929", "87928", "5710"] if alert["rule"]["id"] in skip: return False @@ -96,14 +95,14 @@ def generate_msg(alert): level = alert['rule']['level'] if (level <= 4): - color = "good" + severity = 1 elif (level >= 5 and level <= 7): - color = "warning" + severity = 2 else: - color = "danger" + severity = 3 msg = {} - msg['color'] = color + msg['severity'] = severity msg['pretext'] = "WAZUH Alert" msg['title'] = alert['rule']['description'] if 'description' in alert['rule'] else "N/A" msg['text'] = alert.get('full_log')