dgryski/semgrep-go

detect map param where a singular key is also a param?

dnwe opened this issue · 0 comments

dnwe commented

I'm not sure how tricky this would be to detect via ruleguard/semgrep, but one pattern I noticed whilst refactoring a large legacy codebase recently were instances of a large map being passed into func calls when only a single value was actually being used in the body of the func, and they key was available at call time

e.g.,

func process(id string, labels map[string]string) {
     label := labels[id]
     // ...
}