Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1660591 Remove sensitive encryption info when logging #2077

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.base.Strings;
import com.google.common.io.ByteStreams;
import com.google.common.io.CountingOutputStream;
Expand Down Expand Up @@ -1338,12 +1339,23 @@ private static JsonNode parseCommandInGS(SFStatement statement, String command)
}

JsonNode jsonNode = (JsonNode) result;
logger.debug("Response: {}", jsonNode.toString());

logger.debug("Response: {}", removeSensitiveJsonElementsForLogging(jsonNode));

SnowflakeUtil.checkErrorAndThrowException(jsonNode);
return jsonNode;
}

/**
* @param jsonNode A JsonNode that needs to have sensitive data removed before logging.
* @return A string value of the JSON without any sensitive data for logging.
*/
private static String removeSensitiveJsonElementsForLogging(JsonNode jsonNode)
throws SnowflakeSQLException {
JsonNode result = jsonNode.deepCopy();
return ((ObjectNode) result.path("data")).remove("encryptionMaterial").toString();
}

/**
* @param rootNode JSON doc returned by GS
* @throws SnowflakeSQLException Will be thrown if we fail to parse the stage credentials
Expand Down
Loading