MCPcopy Create free account
hub / github.com/idank/explainshell / shouldShed

Function shouldShed

prod/botshed/module.go:232–238  ·  view source on GitHub ↗

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{})

Source from the content-addressed store, hash-verified

230// ServeHTTP and the unit tests both call through here so the rule cannot
231// drift between production and the tests.
232func 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
240func countHits(cmd string, bn map[string]struct{}) int {
241 fields := strings.FieldsFunc(cmd, func(r rune) bool {

Callers 2

ServeHTTPMethod · 0.85
TestShouldShedFunction · 0.85

Calls 1

countHitsFunction · 0.85

Tested by 1

TestShouldShedFunction · 0.68