public ConfigurationWithLogging(Configuration conf) { super(conf); log = LOG; redactor = new ConfigRedactor(conf); }
/** * Given a key / value pair, decides whether or not to redact and returns * either the original value or text indicating it has been redacted. * * @param key * @param value * @return Original value, or text indicating it has been redacted */ public String redact(String key, String value) { if (configIsSensitive(key)) { return REDACTED_TEXT; } return value; }
parent.getChangedProperties(newConf, oldConf); Map<PropertyChange, Optional<String>> results = Maps.newHashMap(); ConfigRedactor oldRedactor = new ConfigRedactor(oldConf); ConfigRedactor newRedactor = new ConfigRedactor(newConf); for (PropertyChange change : changes) { String errorMessage = null; String oldValRedacted = oldRedactor.redact(change.prop, change.oldVal); String newValRedacted = newRedactor.redact(change.prop, change.newVal); if (!parent.isPropertyReconfigurable(change.prop)) { LOG.info(String.format(
this.parent.getChangedProperties(newConf, oldConf); Map<PropertyChange, Optional<String>> results = Maps.newHashMap(); ConfigRedactor oldRedactor = new ConfigRedactor(oldConf); ConfigRedactor newRedactor = new ConfigRedactor(newConf); for (PropertyChange change : changes) { String errorMessage = null; String oldValRedacted = oldRedactor.redact(change.prop, change.oldVal); String newValRedacted = newRedactor.redact(change.prop, change.newVal); if (!this.parent.isPropertyReconfigurable(change.prop)) { errorMessage = "Property " + change.prop +
parent.getChangedProperties(newConf, oldConf); Map<PropertyChange, Optional<String>> results = Maps.newHashMap(); ConfigRedactor oldRedactor = new ConfigRedactor(oldConf); ConfigRedactor newRedactor = new ConfigRedactor(newConf); for (PropertyChange change : changes) { String errorMessage = null; String oldValRedacted = oldRedactor.redact(change.prop, change.oldVal); String newValRedacted = newRedactor.redact(change.prop, change.newVal); if (!parent.isPropertyReconfigurable(change.prop)) { LOG.info(String.format(
/** * @see Configuration#get(String). */ @Override public String get(String name) { String value = super.get(name); log.info("Got {} = '{}'", name, redactor.redact(name, value)); return value; }
dumpGenerator.writeStartArray(); dumpGenerator.flush(); ConfigRedactor redactor = new ConfigRedactor(config); synchronized (config) { for (Map.Entry<Object,Object> item: config.getProps().entrySet()) {
/** * Given a key / value pair, decides whether or not to redact and returns * either the original value or text indicating it has been redacted. * * @param key * @param value * @return Original value, or text indicating it has been redacted */ public String redact(String key, String value) { if (configIsSensitive(key)) { return REDACTED_TEXT; } return value; }
ConfigRedactor redactor = new ConfigRedactor(config); for (String name : System.getProperties().stringPropertyNames()) { String value = System.getProperty(name); if (name.startsWith(getPrefix() + ".")) { config.set(name, value); String redacted = redactor.redact(name, value); log.info("System property sets {}: {}", name, redacted); String name = entry.getKey(); String value = config.get(entry.getKey()); String redacted = redactor.redact(name, value); log.debug(" {}: {}", entry.getKey(), redacted);
/** * @see Configuration#set(String, String, String). */ @Override public void set(String name, String value, String source) { log.info("Set {} to '{}'{}", name, redactor.redact(name, value), source == null ? "" : " from " + source); super.set(name, value, source); } }
dumpGenerator.writeFieldName("property"); appendJSONProperty(dumpGenerator, config, propertyName, new ConfigRedactor(config)); dumpGenerator.writeEndObject(); dumpGenerator.flush();
/** * Given a key / value pair, decides whether or not to redact and returns * either the original value or text indicating it has been redacted. * * @param key * @param value * @return Original value, or text indicating it has been redacted */ public String redact(String key, String value) { if (configIsSensitive(key)) { return REDACTED_TEXT; } return value; }
this.parent.getChangedProperties(newConf, oldConf); Map<PropertyChange, Optional<String>> results = Maps.newHashMap(); ConfigRedactor oldRedactor = new ConfigRedactor(oldConf); ConfigRedactor newRedactor = new ConfigRedactor(newConf); for (PropertyChange change : changes) { String errorMessage = null; String oldValRedacted = oldRedactor.redact(change.prop, change.oldVal); String newValRedacted = newRedactor.redact(change.prop, change.newVal); if (!this.parent.isPropertyReconfigurable(change.prop)) { errorMessage = "Property " + change.prop +
/** * Write property and its attributes as json format to given * {@link JsonGenerator}. * * @param jsonGen json writer * @param config configuration * @param name property name * @throws IOException */ private static void appendJSONProperty(JsonGenerator jsonGen, Configuration config, String name, ConfigRedactor redactor) throws IOException { // skip writing if given property name is empty or null if(!Strings.isNullOrEmpty(name) && jsonGen != null) { jsonGen.writeStartObject(); jsonGen.writeStringField("key", name); jsonGen.writeStringField("value", redactor.redact(name, config.get(name))); jsonGen.writeBooleanField("isFinal", config.finalParameters.contains(name)); String[] resources = config.updatingResource != null ? config.updatingResource.get(name) : null; String resource = UNKNOWN_RESOURCE; if (resources != null && resources.length > 0) { resource = resources[0]; } jsonGen.writeStringField("resource", resource); jsonGen.writeEndObject(); } }
dumpGenerator.writeFieldName("property"); appendJSONProperty(dumpGenerator, config, propertyName, new ConfigRedactor(config)); dumpGenerator.writeEndObject(); dumpGenerator.flush();
/** * Given a key / value pair, decides whether or not to redact and returns * either the original value or text indicating it has been redacted. * * @param key * @param value * @return Original value, or text indicating it has been redacted */ public String redact(String key, String value) { if (configIsSensitive(key)) { return REDACTED_TEXT; } return value; }
@Test public void redact() throws Exception { Configuration conf = new Configuration(); ConfigRedactor redactor = new ConfigRedactor(conf); String processedText; ); for (String key : sensitiveKeys) { processedText = redactor.redact(key, ORIGINAL_VALUE); Assert.assertEquals( "Config parameter wasn't redacted and should be: " + key, ); for (String key : normalKeys) { processedText = redactor.redact(key, ORIGINAL_VALUE); Assert.assertEquals( "Config parameter was redacted and shouldn't be: " + key,
/** * Write property and its attributes as json format to given * {@link JsonGenerator}. * * @param jsonGen json writer * @param config configuration * @param name property name * @throws IOException */ private static void appendJSONProperty(JsonGenerator jsonGen, Configuration config, String name, ConfigRedactor redactor) throws IOException { // skip writing if given property name is empty or null if(!Strings.isNullOrEmpty(name) && jsonGen != null) { jsonGen.writeStartObject(); jsonGen.writeStringField("key", name); jsonGen.writeStringField("value", redactor.redact(name, config.get(name))); jsonGen.writeBooleanField("isFinal", config.finalParameters.contains(name)); String[] resources = config.updatingResource != null ? config.updatingResource.get(name) : null; String resource = UNKNOWN_RESOURCE; if (resources != null && resources.length > 0) { resource = resources[0]; } jsonGen.writeStringField("resource", resource); jsonGen.writeEndObject(); } }
dumpGenerator.writeStartArray(); dumpGenerator.flush(); ConfigRedactor redactor = new ConfigRedactor(config); synchronized (config) { for (Map.Entry<Object,Object> item: config.getProps().entrySet()) {