Skip to content

Commit 0b72b8b

Browse files
committed
Fixed further usecase mappings
1 parent 25268b0 commit 0b72b8b

File tree

3 files changed

+38
-92
lines changed

3 files changed

+38
-92
lines changed

blobs.go

Lines changed: 13 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -312,29 +312,8 @@ func GetUsecaseData() string {
312312
"blogpost": "https://medium.com/shuffle-automation/introducing-shuffle-an-open-source-soar-platform-part-1-58a529de7d12",
313313
"reference_image": "/images/detectionframework.png",
314314
"items": {}
315-
},
316-
{
317-
"type": "cases",
318-
"last": "cases",
319-
"name": "2-way Ticket synchronization",
320-
"priority": 20,
321-
"items": {}
322-
},
323-
{
324-
"name": "ChatOps",
325-
"priority": 60,
326-
"type": "communication",
327-
"last": "cases",
328-
"items": {}
329-
},
330-
{
331-
"name": "Threat Intel received",
332-
"priority": 20,
333-
"type": "intel",
334-
"last": "cases",
335-
"items": {}
336-
}
337-
]
315+
}
316+
]
338317
},
339318
{
340319
"name": "2. Enrich",
@@ -451,79 +430,31 @@ func GetUsecaseData() string {
451430
"color": "#4885ed",
452431
"list": [
453432
{
454-
"name": "Eradicate malware",
455-
"priority": 90,
456-
"type": "intel",
457-
"last": "edr",
458-
"items": {}
459-
},
460-
{
461-
"name": "Quarantine host(s)",
462-
"priority": 90,
433+
"name": "Isolate Host",
434+
"old_name": "Quarantine host(s)",
435+
"priority": 80,
463436
"type": "edr",
464437
"items": {}
465438
},
466439
{
467-
"name": "Update Outdated Software",
468-
"priority": 70,
469-
"type": "assets",
470-
"items": {}
471-
},
472-
{
473-
"name": "Block IPs, URLs, Domains and Hashes",
474-
"priority": 90,
440+
"name": "Block an IP",
441+
"old_name": "Block IPs, URLs, Domains and Hashes",
442+
"priority": 75,
475443
"type": "network",
476444
"items": {}
477445
},
478446
{
479-
"name": "Trigger scans",
480-
"priority": 50,
481-
"type": "assets",
482-
"items": {}
483-
},
484-
{
485-
"name": "Update indicators (FW, EDR, SIEM...)",
486-
"priority": 50,
487-
"type": "intel",
488-
"last": "siem",
489-
"items": {}
490-
},
491-
{
492-
"name": "Autoblock activity when threat intel is received",
493-
"priority": 50,
494-
"type": "intel",
495-
"last": "iam",
496-
"items": {}
497-
},
498-
{
499-
"name": "Lock/Delete/Reset account",
500-
"priority": 50,
501-
"type": "iam",
502-
"items": {}
503-
},
504-
{
505-
"name": "Lock vault",
447+
"name": "Kill a process",
506448
"priority": 50,
507-
"type": "iam",
449+
"type": "edr",
508450
"items": {}
509451
},
510452
{
511-
"name": "Increase authentication",
512-
"priority": 50,
453+
"name": "Lock account",
454+
"old_name": "Lock/Delete/Reset account",
455+
"priority": 70,
513456
"type": "iam",
514457
"items": {}
515-
},
516-
{
517-
"name": "Get policies from assets",
518-
"priority": 50,
519-
"type": "assets",
520-
"items": {}
521-
},
522-
{
523-
"name": "Run ansible scripts",
524-
"type": "assets",
525-
"priority": 50,
526-
"items": {}
527458
}
528459
]
529460
},

codegen.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3790,7 +3790,9 @@ func DownloadDockerImageBackend(topClient *http.Client, imageName string) error
37903790
baseUrl := os.Getenv("BASE_URL")
37913791
log.Printf("[DEBUG] Trying to download image %s from backend %s as it doesn't exist. All images: %#v", imageName, baseUrl, downloadedImages)
37923792

3793-
downloadedImages = append(downloadedImages, imageName)
3793+
if !ArrayContains(downloadedImages, imageName) {
3794+
downloadedImages = append(downloadedImages, imageName)
3795+
}
37943796

37953797
data := fmt.Sprintf(`{"name": "%s"}`, imageName)
37963798
dockerImgUrl := fmt.Sprintf("%s/api/v1/get_docker_image", baseUrl)
@@ -3876,6 +3878,13 @@ func DownloadDockerImageBackend(topClient *http.Client, imageName string) error
38763878
return errors.New(string(body))
38773879
}
38783880

3881+
os.Remove(newFileName)
3882+
3883+
if strings.Contains(strings.ToLower(string(body)), "error") {
3884+
log.Printf("[ERROR] Error loading image %s: %s", imageName, string(body))
3885+
return errors.New(string(body))
3886+
}
3887+
38793888
baseTag := strings.Split(imageName, ":")
38803889
if len(baseTag) > 1 {
38813890
tag := baseTag[1]
@@ -3891,8 +3900,6 @@ func DownloadDockerImageBackend(topClient *http.Client, imageName string) error
38913900

38923901
}
38933902

3894-
os.Remove(newFileName)
3895-
38963903
log.Printf("[INFO] Successfully loaded image %s: %s", imageName, string(body))
38973904
return nil
38983905
}

shared.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,11 +3289,14 @@ func HandleGetEnvironments(resp http.ResponseWriter, request *http.Request) {
32893289
// Here as well as in db-connector due to cache handling
32903290
timenow := time.Now().Unix()
32913291
for envIndex, env := range newEnvironments {
3292-
if newEnvironments[envIndex].Type == "onprem" {
3293-
if env.Checkin > 0 && timenow-env.Checkin > 90 {
3294-
newEnvironments[envIndex].RunningIp = ""
3295-
newEnvironments[envIndex].Licensed = false
3296-
}
3292+
if newEnvironments[envIndex].Type != "onprem" {
3293+
continue
3294+
}
3295+
3296+
if env.Checkin > 0 && timenow-env.Checkin > 90 && len(newEnvironments[envIndex].RunningIp) > 0 {
3297+
log.Printf("[DEBUG] Resetting environment %s (%s) due to inactivity", env.Name, env.Id)
3298+
newEnvironments[envIndex].RunningIp = ""
3299+
newEnvironments[envIndex].Licensed = false
32973300
}
32983301
}
32993302

@@ -12886,6 +12889,7 @@ func GetOpenIdUrl(request *http.Request, org Org) string {
1288612889
}
1288712890

1288812891
func GetRequestIp(r *http.Request) string {
12892+
// Check the actual IP that is inbound
1288912893
forwardedFor := r.Header.Get("X-Forwarded-For")
1289012894
if forwardedFor != "" {
1289112895
// The X-Forwarded-For header can contain a comma-separated list of IP addresses.
@@ -12934,9 +12938,13 @@ func GetRequestIp(r *http.Request) string {
1293412938
}
1293512939
}
1293612940

12941+
// IPv6 / localhostm apping. Just returning raw.
12942+
if strings.Contains(r.RemoteAddr, "::") || strings.Contains(r.RemoteAddr, "127.0.0.1") || strings.Contains(r.RemoteAddr, "localhost") {
12943+
return r.RemoteAddr
12944+
}
12945+
1293712946
// If neither header is present, fall back to using the RemoteAddr field.
1293812947
// Check for IPv6 and split accordingly.
12939-
1294012948
re := regexp.MustCompile(`\[[^\]]+\]`)
1294112949
remoteAddr := re.ReplaceAllString(r.RemoteAddr, "")
1294212950
if remoteAddr != "" {
@@ -27839,7 +27847,7 @@ func DistributeAppToEnvironments(ctx context.Context, org Org, appnames []string
2783927847
request := ExecutionRequest{
2784027848
Type: "DOCKER_IMAGE_DOWNLOAD",
2784127849
ExecutionId: uuid.NewV4().String(),
27842-
ExecutionArgument: strings.Join(appnames, ","),
27850+
ExecutionArgument: fmt.Sprintf("%s,%s", strings.ToLower(strings.Join(appnames, ",")), strings.Join(appnames, ",")),
2784327851
Priority: 11,
2784427852
}
2784527853

0 commit comments

Comments
 (0)