Skip to content

Commit

Permalink
sanitiez user input
Browse files Browse the repository at this point in the history
  • Loading branch information
cblomart committed Dec 23, 2021
1 parent c0cbd95 commit 60b8127
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/cblomart/vsphere-graphite/utils"
"log"
"net/http"
"strconv"
"strings"
"time"

"github.com/cblomart/vsphere-graphite/utils"

"github.com/cblomart/vsphere-graphite/backend/thininfluxclient"
"github.com/fluent/fluent-logger-golang/fluent"

Expand Down Expand Up @@ -465,6 +466,9 @@ func (backend *Config) scrapeHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, "'target' parameter must be specified", 400)
return
}
// sanitize target
target = strings.Replace(target, "\n", "", -1)
target = strings.Replace(target, "\r", "", -1)

if _, found := backend.promCollectors[target]; !found {
http.Error(w, "VCenter not found", 400)
Expand Down

0 comments on commit 60b8127

Please sign in to comment.