diff --git a/core/http.go b/core/http.go index 35c590801..f71827617 100644 --- a/core/http.go +++ b/core/http.go @@ -283,6 +283,10 @@ func (self *WebService) HandleQuery(w http.ResponseWriter, r *http.Request) { http.Error(w, "Provide a database (db)", http.StatusNotFound) return } + if !self.service.Cluster.IsValidDatabase(database_name) { + http.Error(w, "Unknown Database:"+database_name, http.StatusNotFound) + return + } pql := r.Form.Get("pql") if pql == "" { http.Error(w, "Provide a valid query string (pql)", http.StatusNotFound) diff --git a/db/topology.go b/db/topology.go index fa5f235ac..d5ad4d8c5 100644 --- a/db/topology.go +++ b/db/topology.go @@ -117,6 +117,16 @@ func (self *Cluster) GetDatabases() map[string]*Database { } +func (self *Cluster) IsValidDatabase(dbname string) bool { + for name, _ := range self.GetDatabases() { + if name == dbname { + return true + } + + } + return false +} + /////////// DATABASES //////////////////////////////////////////////////////////////////// // A database is a collection of all the frames within a given profile space diff --git a/executor/executor.go b/executor/executor.go index ad15ac8c2..d6080971d 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -97,7 +97,12 @@ func (self *Executor) runQuery(database *db.Database, qry *query.Query) error { msg.Data = qs switch step := qs.(type) { case query.PortableQueryStep: - self.service.Transport.Send(msg, step.GetLocation().ProcessId) + loc := step.GetLocation() + if loc != nil { + self.service.Transport.Send(msg, loc.ProcessId) + } else { + log.Println("Problem with querystep(nil location)", spew.Sdump(step)) + } } } return nil