Browse Source

Enhance size estimation for various field types in cost.go

Signed-off-by: maksim.nabokikh <max.nabokih@gmail.com>
pull/4607/head
maksim.nabokikh 2 weeks ago
parent
commit
61c706dd96
  1. 8
      pkg/cel/cost.go

8
pkg/cel/cost.go

@ -65,8 +65,16 @@ func (defaultCostEstimator) EstimateSize(element checker.AstNode) *checker.SizeE
field := path[1]
switch field {
case "groups", "scopes":
// list(string) fields
return &checker.SizeEstimate{Min: 0, Max: DefaultListMaxLength}
case "email_verified":
// bool field — size is always 1
return &checker.SizeEstimate{Min: 1, Max: 1}
case "redirect_uris":
// list(string) field on request
return &checker.SizeEstimate{Min: 0, Max: DefaultListMaxLength}
default:
// string fields (email, username, user_id, client_id, etc.)
return &checker.SizeEstimate{Min: 0, Max: DefaultStringMaxLength}
}
}

Loading…
Cancel
Save