You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, as titled. We figured out that the library doesn't hide methods that aren't accessible by the interface definition. We would expect that interface boundaries are enforced.
Hello! Yes, I think this is a problem. Expr uses reflect to check if method is available on provided instance (not interface). As during runtime real object is present.
We need to improve the type checker, and enforce strict validation during compile time.
Nice idea with expr:"-". Please open separate issue to track it.
I hit this issue as well, but slightly different. In my case, I pass an interface to expr during compile time with expr.Env(...) and I observed, that compiling the expression fails, if I just pass a nil instance of the interface and the expression contains one of the methods defined in the interface. My use case for this is, that I want to validate an expression provided by the user, that later will be executed against a concrete instances implementing the interface. But these instances are not yet known when the user provides the expression.
panic: nil interface: unknown name Hi (1:1)
| Hi() == "Hi foo"
| ^
goroutine 1 [running]:
main.main()
/workspaces/migration-manager/internal/batch/test/main.go:39 +0x1f4
exit status 2
Side note: when I created the above reproducer, I found that expr also is not able to handle types derived from base types, which provide methods. My initial definition for say was like this (which also implements the above mentioned interface):
Hello, as titled. We figured out that the library doesn't hide methods that aren't accessible by the interface definition. We would expect that interface boundaries are enforced.
Simple example:
Pseudocode:
Workaround
It looks like
expr:"-"
can be used as a tag to prevent exposing fields. I haven't find it in the docs unfortunately.The text was updated successfully, but these errors were encountered: