Skip to content

Commit

Permalink
feat(API): Verify input of the base64 encoded kubeconfig.
Browse files Browse the repository at this point in the history
  • Loading branch information
liqiang-fit2cloud committed Feb 8, 2021
1 parent 7e8209c commit fb9d94a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gotty/server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package server
import (
"bytes"
"context"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -305,6 +306,13 @@ func (server *Server) handleKubeConfigApi(w http.ResponseWriter, r *http.Request
w.WriteHeader(406)
return
}
if _, base64err := base64.StdEncoding.DecodeString(request.KubeConfig); base64err != nil {
result.Message = "Invalid Base64 Content"
json.NewEncoder(w).Encode(result)
w.WriteHeader(406)
return
}

//fmt.Printf("%+v", requst)
token := randomstring.Generate(20)
ttyParameter := cache.TtyParameter{
Expand Down

0 comments on commit fb9d94a

Please sign in to comment.