You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quite often developers are using logging statements like
public ... ... (Orderorder) ... {
log.debug("Order is processed: {}", order) // where order.getCustomer() may return sensitive/personal data
}
Template ObfuscationRequired allows to specify what exactly objects are not allowed to be placed as arguments to the logging methods:
<rulename="ObfuscationRequired"since="0.1.0"language="java"externalInfoUrl="https://github.com/dgroup/arch4u-pmd/discussions/64"message="Sensitive data might be exposed to the logs: https://github.com/dgroup/arch4u-pmd/discussions/64"class="io.github.dgroup.arch4u.pmd.ObfuscationRequired">
<priority>3</priority>
<properties>
<propertyname="loggerClasses"delimiter="|"value="org.slf4j.Logger|java.util.logging.Logger|org.apache.log4j.Logger|org.apache.logging.log4j.Logger"/>
<propertyname="sensitiveClasses"value="io.github.dgroup.Person|io.github.dgroup.justpackage"/>
</properties>
</rule>
and rule will throw the following violation
publicclassMyClass {
privatestaticfinalorg.slf4j.Loggerlog = org.slf4j.LoggerFactory.getLogger(MyClass.class);
privateFunc<Person, String> obfuscation = ... ;
public ... ...(io.github.dgroup.Personperson, io.github.dgroup.justpackage.Credentialscredentials) ... {
log.debug("Got {}", person); // violationlog.debug("Got {}", this.obfuscation.apply(person)); // ok log.debug("Got person with id {}", person.getId()); // oklog.debug("Got creds {}", credentials); // violationlog.debug("Got creds {}", this.obfuscation.apply(credentials)); // ok
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
Why?
Quite often developers are using logging statements like
Template
ObfuscationRequired
allows to specify what exactly objects are not allowed to be placed as arguments to the logging methods:and rule will throw the following violation
Beta Was this translation helpful? Give feedback.
All reactions