Skip to content

Commit 5b1b3a7

Browse files
committed
Attempted sanitization cleanup to only run once
1 parent 22d10a3 commit 5b1b3a7

File tree

2 files changed

+41
-26
lines changed

2 files changed

+41
-26
lines changed

shared.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16380,12 +16380,14 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut
1638016380
return &workflowExecution, true, nil
1638116381
}
1638216382

16383+
1638316384
// 1. CHECK cache if it happened in another?
1638416385
// 2. Set cache
1638516386
// 3. Find executed without a result
1638616387
// 4. Ensure the result is NOT set when running an action)
1638716388

1638816389
actionResult = FixActionResultOutput(actionResult)
16390+
actionResult.Sanitized = false
1638916391
actionCacheId := fmt.Sprintf("%s_%s_result", actionResult.ExecutionId, actionResult.Action.ID)
1639016392

1639116393
// Done elsewhere
@@ -32164,16 +32166,27 @@ func cleanupProtectedKeys(exec WorkflowExecution) WorkflowExecution {
3216432166
return exec
3216532167
}
3216632168

32167-
for _, protectedKey := range protectedKeys {
3216832169

32169-
for resultKey, _ := range exec.Results {
32170+
for resultKey, _ := range exec.Results {
32171+
if exec.Results[resultKey].Status != "FINISHED" && exec.Results[resultKey].Status != "SUCCESS" {
32172+
continue
32173+
}
32174+
32175+
if exec.Results[resultKey].Sanitized {
32176+
continue
32177+
}
32178+
32179+
for _, protectedKey := range protectedKeys {
32180+
3217032181
if len(protectedKey.Value) <= 8 {
3217132182
exec.Results[resultKey].Result = strings.ReplaceAll(exec.Results[resultKey].Result, protectedKey.Value, "***")
3217232183
} else {
3217332184
exec.Results[resultKey].Result = SanitizeFuzzySubstring(exec.Results[resultKey].Result, protectedKey.Value, 2)
3217432185
}
3217532186
}
3217632187

32188+
exec.Results[resultKey].Sanitized = true
32189+
3217732190
}
3217832191

3217932192
return exec

structs.go

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,16 +1604,18 @@ type SimilarAction struct {
16041604
}
16051605

16061606
type ActionResult struct {
1607-
Action Action `json:"action" datastore:"action"`
1608-
ExecutionId string `json:"execution_id" datastore:"execution_id"`
1609-
Authorization string `json:"authorization" datastore:"authorization"`
1610-
Result string `json:"result" datastore:"result,noindex"`
1611-
StartedAt int64 `json:"started_at" datastore:"started_at"`
1612-
CompletedAt int64 `json:"completed_at" datastore:"completed_at"`
1613-
Status string `json:"status" datastore:"status"`
1607+
Action Action `json:"action" datastore:"action"`
1608+
ExecutionId string `json:"execution_id" datastore:"execution_id"`
1609+
Authorization string `json:"authorization" datastore:"authorization"`
1610+
Result string `json:"result" datastore:"result,noindex"`
1611+
StartedAt int64 `json:"started_at" datastore:"started_at"`
1612+
CompletedAt int64 `json:"completed_at" datastore:"completed_at"`
1613+
Status string `json:"status" datastore:"status"`
1614+
16141615
AttackTechniques []string `json:"attack_techniques" datastore:"attack_techniques"`
16151616
AttackTactics []string `json:"attack_tactics" datastore:"attack_tactics"`
16161617
SimilarActions []SimilarAction `json:"similar_actions" datastore:"similar_actions"`
1618+
Sanitized bool `json:"sanitized" datastore:"sanitized"`
16171619
}
16181620

16191621
type AuthenticationUsage struct {
@@ -1640,9 +1642,9 @@ type Notification struct {
16401642
Personal bool `json:"personal" datastore:"personal"`
16411643
Read bool `json:"read" datastore:"read"`
16421644

1643-
ModifiedBy string `json:"modified_by" datastore:"modified_by"`
1644-
Ignored bool `json:"ignored" datastore:"ignored"`
1645-
ExecutionId string `json:"execution_id" datastore:"execution_id"`
1645+
ModifiedBy string `json:"modified_by" datastore:"modified_by"`
1646+
Ignored bool `json:"ignored" datastore:"ignored"`
1647+
ExecutionId string `json:"execution_id" datastore:"execution_id"`
16461648
}
16471649

16481650
type NotificationCached struct {
@@ -4292,17 +4294,17 @@ type AppHealth struct {
42924294
}
42934295

42944296
type DatastoreHealth struct {
4295-
Create bool `json:"create"`
4296-
Read bool `json:"read"`
4297-
Result string `json:"result"`
4298-
Delete bool `json:"delete"`
4297+
Create bool `json:"create"`
4298+
Read bool `json:"read"`
4299+
Result string `json:"result"`
4300+
Delete bool `json:"delete"`
42994301
}
43004302

43014303
type FileHealth struct {
4302-
Create bool `json:"create"`
4303-
FileId string `json:"fileId"`
4304-
Upload bool `json:"get_file"`
4305-
Delete bool `json:"delete"`
4304+
Create bool `json:"create"`
4305+
FileId string `json:"fileId"`
4306+
Upload bool `json:"get_file"`
4307+
Delete bool `json:"delete"`
43064308
}
43074309

43084310
type WorkflowHealth struct {
@@ -4336,13 +4338,13 @@ type LiveExecutionStatus struct {
43364338
}
43374339

43384340
type HealthCheck struct {
4339-
Success bool `json:"success"`
4340-
Updated int64 `json:"updated"`
4341-
Apps AppHealth `json:"apps"`
4342-
Workflows WorkflowHealth `json:"workflows"`
4341+
Success bool `json:"success"`
4342+
Updated int64 `json:"updated"`
4343+
Apps AppHealth `json:"apps"`
4344+
Workflows WorkflowHealth `json:"workflows"`
43434345
PythonApps AppHealth `json:"python_apps"`
4344-
Datastore DatastoreHealth `json:"datastore"`
4345-
FileOps FileHealth `json:"fileops"`
4346+
Datastore DatastoreHealth `json:"datastore"`
4347+
FileOps FileHealth `json:"fileops"`
43464348
}
43474349

43484350
type HealthCheckDB struct {

0 commit comments

Comments
 (0)