Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Perfect multi-expression functions #6

Merged
merged 1 commit into from
Mar 7, 2022

Conversation

XinRoom
Copy link
Contributor

@XinRoom XinRoom commented Mar 7, 2022

尽管使用全局变量ResultMap的方式修复了 || 的短路逻辑 #5 34528b2

且不说ResultMap作为全局变量本身就有问题:

ResultMap = make(map[string]bool)

此外这种方式对于&&逻辑或者更为复杂的逻辑依然是无效的 :
expression: (r0() && r1() && r2()) || r3()

在r0()为false时依然会发送r1()、 r2()的请求

所以,我们可以直接将r0、r1、r2定义为实际处理的可变函数:

https://github.com/XinRoom/pocV/blob/1d6d9149bb50812291bead31b18ede27cefa2c1e/pkg/xray/cel/cel.go#L126-L146

然后让cel自己去判断和执行就行了:

https://github.com/XinRoom/pocV/blob/1d6d9149bb50812291bead31b18ede27cefa2c1e/internal/common/check/xray.go#L404-L419

@WAY29
Copy link
Owner

WAY29 commented Mar 7, 2022

感谢pr

@WAY29 WAY29 merged commit 67c1bd2 into WAY29:main Mar 7, 2022
@XinRoom XinRoom deleted the fix-cel-multi-expression branch March 8, 2022 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants