From 8f69c6b2df5c1f87da2a1c94c9bc96a8dda1df8d Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Sat, 4 Oct 2014 08:25:32 +1000 Subject: [PATCH] go.tools/dashboard/app: require version=2 for commit updates This will prevent older, buggy builders from posting commits. LGTM=bradfitz R=bradfitz CC=golang-codereviews https://golang.org/cl/153930043 --- dashboard/app/build/handler.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dashboard/app/build/handler.go b/dashboard/app/build/handler.go index 282694f8..780d11e7 100644 --- a/dashboard/app/build/handler.go +++ b/dashboard/app/build/handler.go @@ -15,6 +15,7 @@ import ( "fmt" "io/ioutil" "net/http" + "strconv" "strings" "unicode/utf8" @@ -26,6 +27,7 @@ import ( ) const commitsPerPage = 30 +const watcherVersion = 2 // commitHandler retrieves commit data or records a new commit. // @@ -71,6 +73,16 @@ func commitHandler(r *http.Request) (interface{}, error) { return nil, errors.New("can only POST commits with master key") } + // For now, the commit watcher doesn't support gccgo, + // so only do this check for Go commits. + // TODO(adg,cmang): remove this check when gccgo is supported. + if dashboardForRequest(r) == goDash { + v, _ := strconv.Atoi(r.FormValue("version")) + if v != watcherVersion { + return nil, fmt.Errorf("rejecting POST from commit watcher; need version %v", watcherVersion) + } + } + // POST request body, err := ioutil.ReadAll(r.Body) r.Body.Close()