diff options
Diffstat (limited to 'internal/ipc')
| -rw-r--r-- | internal/ipc/server.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/ipc/server.go b/internal/ipc/server.go index 9602912..94073da 100644 --- a/internal/ipc/server.go +++ b/internal/ipc/server.go @@ -229,6 +229,18 @@ func (s *Server) handleConn(conn net.Conn) { continue } r := *req.Rule + // A rule with a regex that fails to compile silently never + // matches anything at apply time (rules.apply treats a + // compile error the same as "no match") - the user would see + // it saved and enabled with no indication it's actually + // inert. Reject it here instead, at the point they can still + // fix it. + if r.IsRegex { + if _, err := regexp.Compile(r.Match); err != nil { + enc.Encode(Response{Type: "error", Error: "invalid regex: " + err.Error()}) + continue + } + } var err error if r.ID == 0 { r.ID, err = s.db.AddRule(r) |