Skip to content

Commit 8c19ff7

Browse files
committed
fix: resolve range variable address bug in holdout loop (CWE-118)
- Changed loop from 'for _, holdout := range holdouts' to 'for i := range holdouts' - Created proper pointer 'holdout := &holdouts[i]' to avoid address-of-iteration-variable issue - This fixes the security warning where all iterations would point to the same memory location - All tests passing Resolves Prisma Cloud security scan: Incorrect access of indexable resource
1 parent 68b5735 commit 8c19ff7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/decision/holdout_service.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ func (h HoldoutService) GetDecision(decisionContext FeatureDecisionContext, user
5252

5353
holdouts := decisionContext.ProjectConfig.GetHoldoutsForFlag(feature.Key)
5454

55-
for _, holdout := range holdouts {
55+
for i := range holdouts {
56+
holdout := &holdouts[i]
5657
h.logger.Debug(fmt.Sprintf("Evaluating holdout %s for feature %s", holdout.Key, feature.Key))
5758

5859
// Check if holdout is running
@@ -63,7 +64,7 @@ func (h HoldoutService) GetDecision(decisionContext FeatureDecisionContext, user
6364
}
6465

6566
// Check audience conditions
66-
inAudience := h.checkIfUserInHoldoutAudience(&holdout, userContext, decisionContext.ProjectConfig, options)
67+
inAudience := h.checkIfUserInHoldoutAudience(holdout, userContext, decisionContext.ProjectConfig, options)
6768
reasons.Append(inAudience.reasons)
6869

6970
if !inAudience.result {

0 commit comments

Comments
 (0)