Added workflow storage set and get

This commit is contained in:
frikky
2021-05-25 18:36:43 +02:00
parent fe7e0910d2
commit d3834f52d5
5 changed files with 62 additions and 36 deletions
+13 -12
View File
@@ -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)
}
+15
View File
@@ -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"
}'
+19 -8
View File
@@ -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,9 +1454,10 @@ const AppCreator = (props) => {
//console.log("Name: ", parameterName)
const extraKeys =
<div style={{marginTop: 50}}>
<Typography variant="body1">Extra headers or queries</Typography>
<div style={{display: "flex"}}>
<Typography variant="body1">Extra authentication options</Typography>
{extraAuth.length === 0 ?
<Button color="primary" style={{maxWidth: 50, }} variant="contained" onClick={() => {
<Button color="primary" style={{maxWidth: 50, marginLeft: 15, }} variant="contained" onClick={() => {
console.log("ADD NEW!")
extraAuth.push(defaultAuth)
setExtraAuth(extraAuth)
@@ -1456,9 +1466,10 @@ const AppCreator = (props) => {
<AddIcon style={{}}/>
</Button>
: <span style={{width: 50, }}/>}
</div>
{extraAuth.map((value, index) => {
return (
<span style={{display: "flex", height: 50, marginTop: 5, }}>
<span key={index} style={{display: "flex", height: 50, marginTop: 5, }}>
<TextField
required
style={{height: 50, flex: 2, marginTop: 0, marginBottom: 0, backgroundColor: inputColor, marginRight: 5, }}
+1 -1
View File
@@ -84,7 +84,7 @@ export const GetIconInfo = (action) => {
{"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"]},
+5 -6
View File
@@ -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')