Switch defaults and model for logging sensitive data

Issue: SPR-17029
This commit is contained in:
Rossen Stoyanchev
2018-07-10 16:18:31 -04:00
parent a40d25a760
commit 1b1bc7f5b5
34 changed files with 241 additions and 229 deletions

View File

@@ -54,7 +54,7 @@ public class ByteArrayEncoder extends AbstractEncoder<byte[]> {
return Flux.from(inputStream).map(bytes -> {
DataBuffer dataBuffer = bufferFactory.wrap(bytes);
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
String logPrefix = Hints.getLogPrefix(hints);
logger.debug(logPrefix + "Writing " + dataBuffer.readableByteCount() + " bytes");
}

View File

@@ -55,7 +55,7 @@ public class ByteBufferEncoder extends AbstractEncoder<ByteBuffer> {
return Flux.from(inputStream).map(byteBuffer -> {
DataBuffer dataBuffer = bufferFactory.wrap(byteBuffer);
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
String logPrefix = Hints.getLogPrefix(hints);
logger.debug(logPrefix + "Writing " + dataBuffer.readableByteCount() + " bytes");
}

View File

@@ -68,7 +68,7 @@ public final class CharSequenceEncoder extends AbstractEncoder<CharSequence> {
Charset charset = getCharset(mimeType);
return Flux.from(inputStream).map(charSequence -> {
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
String logPrefix = Hints.getLogPrefix(hints);
logger.debug(logPrefix + "Writing '" + charSequence + "'");
}

View File

@@ -54,7 +54,7 @@ public class DataBufferEncoder extends AbstractEncoder<DataBuffer> {
Flux<DataBuffer> flux = Flux.from(inputStream);
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
flux = flux.doOnNext(buffer -> {
String logPrefix = Hints.getLogPrefix(hints);
logger.debug(logPrefix + "Writing " + buffer.readableByteCount() + " bytes");

View File

@@ -99,7 +99,7 @@ public abstract class Hints {
* @param hints the hints map
* @return whether logging of data is allowed
*/
public static boolean suppressLogging(@Nullable Map<String, Object> hints) {
public static boolean isLoggingSuppressed(@Nullable Map<String, Object> hints) {
return hints != null && (boolean) hints.getOrDefault(SUPPRESS_LOGGING_HINT, false);
}

View File

@@ -68,7 +68,7 @@ public class ResourceEncoder extends AbstractSingleValueEncoder<Resource> {
protected Flux<DataBuffer> encode(Resource resource, DataBufferFactory dataBufferFactory,
ResolvableType type, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
String logPrefix = Hints.getLogPrefix(hints);
logger.debug(logPrefix + "Writing [" + resource + "]");
}

View File

@@ -122,7 +122,7 @@ public class ResourceRegionEncoder extends AbstractEncoder<ResourceRegion> {
long position = region.getPosition();
long count = region.getCount();
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
logger.debug(Hints.getLogPrefix(hints) +
"Writing region " + position + "-" + (position + count) + " of [" + resource + "]");
}