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
package tools
type Fooer struct {}
func (*Fooer) Foo() {}
Would adding tools.(*Fooer).Foo to the banned API list ban calls like f.Foo()?
Do we want to explicitly discourage this? Seems easy to bypass.
package bypassing
func caller() {
f := &tools.Fooer{}
f.Foo() // <- currently banned.
}
type FooInterface interface { Foo() }
func bypass() {
var f tools.FooInterface
f = &tools.Fooer{}
f.Foo() // <- there is no way we can ban this
}
The text was updated successfully, but these errors were encountered:
Can we actually prevent this from happening?
Blocking the whole signature, regardless the package it comes from, might have some false positives, don't you think?
This is what I was pointing at with:
Do we want to explicitly discourage this? Seems easy to bypass.
Either you have something that is trivial to bypass with creating your own interface, or you end up with lots of false positives. Therefore I would completely remove the option of banning methods.
I don't know whether we can ban types (i.e. whether this is technically feasible and non-bypassable trivially).
If one owns the API they wish to ban, they can always provide top-level methods that have access to package-private fields of the type they wish to interact with. This, unfortunately, requires some forethought.
Example:
tools.(*Fooer).Foo
to the banned API list ban calls likef.Foo()
?The text was updated successfully, but these errors were encountered: