shouldShed is the single source of truth for the detector decision. ServeHTTP and the unit tests both call through here so the rule cannot drift between production and the tests.
(cmd string, bn map[string]struct{})
| 230 | // ServeHTTP and the unit tests both call through here so the rule cannot |
| 231 | // drift between production and the tests. |
| 232 | func shouldShed(cmd string, bn map[string]struct{}) (shed bool, hits int) { |
| 233 | if cmd == "" || len(cmd) > 5000 { |
| 234 | return false, 0 |
| 235 | } |
| 236 | hits = countHits(cmd, bn) |
| 237 | return hits >= 4 || (hits >= 2 && len(cmd) > 250), hits |
| 238 | } |
| 239 | |
| 240 | func countHits(cmd string, bn map[string]struct{}) int { |
| 241 | fields := strings.FieldsFunc(cmd, func(r rune) bool { |