From 80edd21fb402eb14dbac7725ee9047419d91532c Mon Sep 17 00:00:00 2001 From: btoews Date: Mon, 22 Jul 2024 10:26:30 -0600 Subject: [PATCH] reject requetss with no tokenized data --- tokenizer.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tokenizer.go b/tokenizer.go index 3184633..36496f3 100644 --- a/tokenizer.go +++ b/tokenizer.go @@ -59,7 +59,7 @@ func NewTokenizer(openKey string) *tokenizer { proxy := goproxy.NewProxyHttpServer() tkz := &tokenizer{ProxyHttpServer: proxy, priv: priv, pub: pub} - tkz.NonproxyHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + proxy.NonproxyHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "I'm not that kind of server") }) @@ -156,6 +156,13 @@ func (t *tokenizer) HandleRequest(req *http.Request, ctx *goproxy.ProxyCtx) (*ht processors = append(processors, reqProcessors...) } + if len(processors) == 0 { + pud.reqLog.Warn("no processors") + return nil, errorResponse(ErrBadRequest) + } + + pud.reqLog = pud.reqLog.WithField("processors", len(processors)) + for _, processor := range processors { if err := processor(req); err != nil { pud.reqLog.WithError(err).Warn("run processor")