palantir / gradle-baseline

A set of Gradle plugins that configure default code quality tools for developers.
Apache License 2.0
307 stars 134 forks source link

Disallow Arg wrapped Args and exceptions #639

Open SerialVelocity opened 5 years ago

SerialVelocity commented 5 years ago

What happened?

Arg<?> someSharedArg = UnsafeArg.of("arg", arg);
log.error("ERROR", SafeArg.of("arg", someSharedArg));

This will have output similar to:

{"key":"arg","value":["arg-val"],"safeForLogging":false}

The same happens with exceptions (if the exception is "safe"):

log.error("ERROR", SafeArg.of("exception", e));

What did you want to happen?

Error-prone should complain that these are invalid.

iamdanfox commented 5 years ago

@SerialVelocity would you be able to put up a quick PR for this? I think it could look quite similar to https://github.com/palantir/gradle-baseline/blob/develop/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/DangerousThrowableMessageSafeArg.java

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not been touched in the last 60 days. Please comment if you'd like to keep it open, otherwise it'll be closed in 7 days time.