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

bancheck: Does it work for methods of concrete types? #295

Open
kele opened this issue May 19, 2021 · 5 comments
Open

bancheck: Does it work for methods of concrete types? #295

kele opened this issue May 19, 2021 · 5 comments
Assignees
Labels

Comments

@kele
Copy link
Collaborator

kele commented May 19, 2021

Example:

package tools

type Fooer struct {}

func (*Fooer) Foo() {}
  1. Would adding tools.(*Fooer).Foo to the banned API list ban calls like f.Foo()?
  2. 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
}
@empijei
Copy link
Contributor

empijei commented May 20, 2021

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?

@kele
Copy link
Collaborator Author

kele commented May 20, 2021

empijei@:

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:

  1. 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.

@empijei
Copy link
Contributor

empijei commented May 21, 2021

So if you want to ban a method you have to ban the entire type?

@kele
Copy link
Collaborator Author

kele commented May 21, 2021

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.

@empijei
Copy link
Contributor

empijei commented May 21, 2021

+1 We should probably discuss this together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants