fix: Perfect multi-expression functions #6
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
尽管使用全局变量ResultMap的方式修复了
||
的短路逻辑 #5 34528b2且不说ResultMap作为全局变量本身就有问题:
pocV/pkg/xray/cel/cel.go
Line 25 in 34528b2
此外这种方式对于
&&
逻辑或者更为复杂的逻辑依然是无效的 :expression: (r0() && r1() && r2()) || r3()
所以,我们可以直接将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