Skip to content

Commit

Permalink
Merge pull request #354 from lmenezes/censor-password
Browse files Browse the repository at this point in the history
Stop logging ES password on errors
  • Loading branch information
moliware authored Apr 4, 2019
2 parents 7268ce5 + 39e38dd commit 8111136
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/controllers/BaseController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import controllers.auth.{AuthRequest, AuthenticationModule}
import exceptions.MissingRequiredParamException
import models.{CerebroRequest, CerebroResponse, Hosts}
import play.api.Logger
import play.api.libs.json.{JsValue, Json}
import play.api.libs.json._
import play.api.mvc.{Controller, InjectedController, Result}
import services.exception.RequestFailedException

Expand Down Expand Up @@ -41,7 +41,11 @@ trait BaseController extends InjectedController with AuthSupport {
}

private def formatRequest(request: AuthRequest[JsValue]): String = {
s"path: ${request.uri}, body: ${request.body.toString}"
val body = request.body.transform(censorPassword) getOrElse request.body
s"path: ${request.uri}, body: ${body.toString()}"
}

private def censorPassword: Reads[JsObject] =
(__ \ "password").json.update(__.read[JsString].map(_ => JsString("xxxxxx")))

}

0 comments on commit 8111136

Please sign in to comment.