From cb3f5f8b932156df9078085e77bef493eca1581b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Sun, 16 Apr 2017 18:49:06 +0300 Subject: [PATCH] cmd/faucet: double check user against the GH website --- cmd/faucet/faucet.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go index fd34cdec16..c418da818f 100644 --- a/cmd/faucet/faucet.go +++ b/cmd/faucet/faucet.go @@ -306,7 +306,7 @@ func (f *faucet) apiHandler(conn *websocket.Conn) { websocket.JSON.Send(conn, map[string]string{"error": "URL doesn't link to GitHub Gists"}) continue } - log.Info("Faucet funds requested", "gist", msg.URL) + log.Info("Faucet funds requested", "addr", conn.RemoteAddr(), "gist", msg.URL) // Retrieve the gist from the GitHub Gist APIs parts := strings.Split(msg.URL, "/") @@ -348,6 +348,17 @@ func (f *faucet) apiHandler(conn *websocket.Conn) { websocket.JSON.Send(conn, map[string]string{"error": "No Ethereum address found to fund"}) continue } + // Validate the user's existence since the API is unhelpful here + if res, err = http.Head("https://github.com/%s", gist.Owner.Login); err != nil { + websocket.JSON.Send(conn, map[string]string{"error": err.Error()}) + continue + } + res.Body.Close() + + if res.StatusCode != 200 { + websocket.JSON.Send(conn, map[string]string{"error": "Invalid user... boom!"}) + continue + } // Ensure the user didn't request funds too recently f.lock.Lock() var (