From e4a8a55c4be9a64ac196b6d74f356eee09bdece4 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Mon, 18 May 2026 12:38:49 +0530 Subject: [PATCH] Check Less and LessEq in version compare. (#4532) * Check Less and LessEq in version compare. Thank you @cnderrauber for catching this. * add test --- CHANGELOG.md | 2 +- pkg/clientconfiguration/conf_test.go | 18 ++++++++++++++---- pkg/clientconfiguration/match.go | 4 ++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5ef3e4b6..96370bba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [1.12.0] - 2026-05-16 -## ATTENTION: This releases introduces important changes to how TURN authentication and permissions are handled. These changes make the system more secure. This release maintains backwards compatiblity. However, backwards compatibility will be removed in the next release. So, please plan accordingly. +## ATTENTION: This releases introduces important changes to how TURN authentication and permissions are handled. These changes make the system more secure. This release maintains backwards compatibility. However, backwards compatibility will be removed in the next release. So, please plan accordingly. ### TURN permission handling changes diff --git a/pkg/clientconfiguration/conf_test.go b/pkg/clientconfiguration/conf_test.go index 55d3812a0..453d57cb8 100644 --- a/pkg/clientconfiguration/conf_test.go +++ b/pkg/clientconfiguration/conf_test.go @@ -82,10 +82,12 @@ func TestScriptMatchConfiguration(t *testing.T) { func TestScriptMatch(t *testing.T) { client := &livekit.ClientInfo{ - Protocol: 6, - Browser: "chrome", - Sdk: 3, // android - DeviceModel: "12345", + Protocol: 6, + Browser: "chrome", + Sdk: 3, // android + DeviceModel: "12345", + BrowserVersion: "13.2", + Version: "2.17.1", } type testcase struct { @@ -101,6 +103,14 @@ func TestScriptMatch(t *testing.T) { {name: "unexist field", expr: `c.protocols > 5`, err: true}, {name: "combined condition", expr: `c.protocol > 5 && (c.sdk=="android" || c.sdk=="ios")`, result: true}, {name: "combined condition2", expr: `(c.device_model == "xiaomi 2201117ti" && c.os == "android") || ((c.browser == "firefox" || c.browser == "firefox mobile") && (c.os == "linux" || c.os == "android"))`, result: false}, + {name: "string lesser", expr: `c.browser_version < "11.3"`, result: false}, + {name: "string lesser eq", expr: `c.browser_version <= "13.2"`, result: true}, + {name: "string greater", expr: `c.browser_version > "11.3"`, result: true}, + {name: "string greater eq", expr: `c.browser_version >= "13.2"`, result: true}, + {name: "semantic lesser", expr: `c.version < "2.16.10"`, result: false}, + {name: "semantic lesser eq", expr: `c.version <= "2.17.1"`, result: true}, + {name: "semantic greater", expr: `c.version > "2.16.10"`, result: true}, + {name: "semantic greater eq", expr: `c.version >= "2.17.1"`, result: true}, } for _, c := range cases { diff --git a/pkg/clientconfiguration/match.go b/pkg/clientconfiguration/match.go index b79559fa8..c0cf25f35 100644 --- a/pkg/clientconfiguration/match.go +++ b/pkg/clientconfiguration/match.go @@ -136,6 +136,10 @@ func (r *ruleSdkVersion) BinaryOp(op token.Token, rhs tengo.Object) (tengo.Objec isMatch = cmp > 0 case token.GreaterEq: isMatch = cmp >= 0 + case token.Less: + isMatch = cmp < 0 + case token.LessEq: + isMatch = cmp <= 0 default: return nil, tengo.ErrInvalidOperator }