Open vivi365 opened 4 months ago
To find calls via identifiers like m
we need to type check the file.
v := reflect.ValueOf(f)
m := v.MethodByName("Method"
m.Call(nil)
This is implemented with packages go/importer
and go/types
.
This parser now catches the POC case!
CAVEATS:
// LIMITATION/TODO: not all files can be type checked due to import issues
if err != nil {
//fmt.Printf("Error type-checking file %s: %v\n", path, err)
}
go-ethereum/accounts
, capslock finds 9 occurrences, whereas gosurface finds 19. I should look into the exact reported cases we get...
Regarding point 2. Reported occurrences
As previously known, capslock does not check subdirectories. This is the reason it finds fewer occurrences (also capslock checks transitive uses as well, we do not do this, so it would still probably differ if checking subdirs).
Note: should probably have proper tests...
This is not quite ready.
The blacklisted function approach is not sufficient. It e.g. does not catch m.Call() where m is of type reflect.Value and thus misses to catch the POC case.
I need to look into this a bit more