Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -182,7 +182,7 @@ class Graph(
Mono.fromCallable {
printLog(config)

log.info("graph initialized with config: {}", config)
log.info("graph initialized with config: {}", config.redacted())
log.info("DEFAULT_BOUNDED_ELASTIC_SIZE: {}", Schedulers.DEFAULT_BOUNDED_ELASTIC_SIZE)
log.info("DEFAULT_BOUNDED_ELASTIC_QUEUESIZE: {}", Schedulers.DEFAULT_BOUNDED_ELASTIC_QUEUESIZE)

Expand Down Expand Up @@ -215,7 +215,7 @@ class Graph(
config.tenant,
config.phase,
)
log.info("graph initialized with config: {}", config)
log.info("graph initialized with config: {}", config.redacted())
log.info("DEFAULT_BOUNDED_ELASTIC_SIZE: {}", Schedulers.DEFAULT_BOUNDED_ELASTIC_SIZE)
log.info("DEFAULT_BOUNDED_ELASTIC_QUEUESIZE: {}", Schedulers.DEFAULT_BOUNDED_ELASTIC_QUEUESIZE)
}
Expand Down Expand Up @@ -929,7 +929,7 @@ class Graph(
DefaultStorageBackendFactory.initialize(config.hbase)
log.info("phase: {}", config.phase)
log.info("tenant: {}", config.tenant)
log.info("graph config: {}", config)
log.info("graph config: {}", config.redacted())
log.info("kafkaClientFactory: {}", kafkaClientFactory)
log.info("webClientFactory: {}", webClientFactory)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,25 @@ data class GraphConfig(
val useJdbcMetastore: Boolean = true,
val featureFlags: List<FeatureFlags.Item> = emptyList(),
) {
/**
* A copy safe to log. The generated [toString] renders every field, so logging this config directly puts the
* metastore credentials in the log in plain text. Only the credentials are replaced - every other field stays
* visible, because that line is the primary record of how an instance was configured. An empty credential stays
* empty rather than masked, so "not configured" remains distinguishable from "configured".
*/
fun redacted(): GraphConfig =
copy(
metastoreUser = mask(metastoreUser),
metastorePassword = mask(metastorePassword),
)

companion object {
private const val MASK = "****"

val builder: Builder
get() = Builder()

private fun mask(credential: String): String = if (credential.isEmpty()) "" else MASK
}

class Builder {
Expand Down
Loading