fixed security bugs
This commit is contained in:
parent
efb57041e5
commit
efbf536ceb
|
@ -4,9 +4,9 @@ import (
|
||||||
log "github.com/cihub/seelog"
|
log "github.com/cihub/seelog"
|
||||||
httprouter "infini.sh/framework/core/api/router"
|
httprouter "infini.sh/framework/core/api/router"
|
||||||
"infini.sh/framework/core/elastic"
|
"infini.sh/framework/core/elastic"
|
||||||
|
"infini.sh/framework/core/radix"
|
||||||
"infini.sh/framework/core/util"
|
"infini.sh/framework/core/util"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
|
@ -46,11 +46,7 @@ func (handler APIHandler) HandleGetIndicesAction(w http.ResponseWriter, req *htt
|
||||||
handler.WriteJSON(w, []interface{}{} , http.StatusOK)
|
handler.WriteJSON(w, []interface{}{} , http.StatusOK)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strIndices := ""
|
catIndices, err := client.GetIndices("")
|
||||||
if !hasAllPrivilege {
|
|
||||||
strIndices = strings.Join(allowedIndices, ",")
|
|
||||||
}
|
|
||||||
catIndices, err := client.GetIndices(strIndices)
|
|
||||||
resBody := util.MapStr{}
|
resBody := util.MapStr{}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
@ -58,6 +54,16 @@ func (handler APIHandler) HandleGetIndicesAction(w http.ResponseWriter, req *htt
|
||||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !hasAllPrivilege {
|
||||||
|
filterIndices := map[string]elastic.IndexInfo{}
|
||||||
|
pattern := radix.Compile(allowedIndices...)
|
||||||
|
for indexName, indexInfo := range *catIndices {
|
||||||
|
if pattern.Match(indexName){
|
||||||
|
filterIndices[indexName] = indexInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catIndices = &filterIndices
|
||||||
|
}
|
||||||
handler.WriteJSON(w, catIndices, http.StatusOK)
|
handler.WriteJSON(w, catIndices, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue