From d05f9f9a4bee0ff7d409c78d5c83b94403512c89 Mon Sep 17 00:00:00 2001 From: Ioannis Kakavas Date: Wed, 22 Jan 2020 07:47:19 +0200 Subject: [PATCH] Truncate SAML Response in trace log (#51237) When not truncated, a long SAML response XML document can fill max line length and mask the actual exception message that the trace statement is meant to inform about. The same XML Document is also printed in full on trace level in SamlRequestHandler#parseSamlMessage() so there is no loss of information --- .../xpack/security/authc/saml/SamlAuthenticator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/saml/SamlAuthenticator.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/saml/SamlAuthenticator.java index 0ddc1054de9c2..77fe28f870145 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/saml/SamlAuthenticator.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/saml/SamlAuthenticator.java @@ -68,7 +68,8 @@ SamlAttributes authenticate(SamlToken token) { try { return authenticateResponse(root, token.getAllowedSamlRequestIds()); } catch (ElasticsearchSecurityException e) { - logger.trace("Rejecting SAML response {} because {}", SamlUtils.toString(root), e.getMessage()); + logger.trace("Rejecting SAML response [{}...] because {}", Strings.cleanTruncate(SamlUtils.toString(root), 512), + e.getMessage()); throw e; } } else {