. .....
.=OO:....$ZZ..
.O........,~=+Z.
=Z ..,:~=~~=+???Z.
.Z .,+++++++???I7IZ.
.O.~7??????????7$7Z.
.?.+ZO+~,???..+Z.$Z.
.,.OZOOOZI?IOZ$ZII7.
.O,7,O7,+~Z=??:I7?ZI7+Z.
.O7+.$=~=+O++??+==~=7ZO.
.ZZ..IIIOOZI?IIO7+=IIZO.
.O..?O$ZI7?????7$II7Z.
OZ.,77Z=$$$I?I??7?ZOO
.Z..O$ZIZZ$????=I7ZO.
O...O~Z+~:=+II$$7~
Z,Z:+.OZ7ZZ$7Z?O.
O.ZOZOOOOOZ7I+?O...
.Z.$OZZOO77$7+=?Z.O~.
......OO..$OZOOZ7I$?~+?=$Z...
.,OZZO$,.... .,...OOOOI???++++O. =..ZZZZOO+...
.=OI. . .OZ$???$OZ. .,~ ..,:~~~=ZO.
.O.. ..:===OO.
,Z.. ,===:O.
.O.,. .. .~===,Z
.Z.,,.OZOZZOOZZ. ... .,====:Z
.Z..,O..?...++=?=Z. ...~. .,::==Z:.
.O:...Z...?...=?+++IO.. ....+ZZOOO..... .Z:+:.......~==O.
.Z..,:,ZZ+:.+Z7?????=O,IOZZZO..,+??????++++=ZZ,~OOI??++7OZ===~Z.
Z..OOI. .IZ$ZZI...... ..:+???????????????????+7Z7??~~+++ZZ==O.
O.O.,+ ..,~=+???~.,=?????????????????IZZ7????II?I$??==+++IZOO~Z
OO. .,~??????????????????????+++?I$Z77ZZZZOOOZZ7I?+??I??++?$$?ZO
O:.:7$I???????????????II?+++?IZZZ7ZO?$ZZZZ7+======+++++===?77?$O
.O+ZZZ$III7$ZZZZZZ7I?+++?I$OOO$O$??????++++++++??????????+?I?+O.
.OZOOOOOOZZ$$7I?++++?I$ZOOO$ZZ??+????????????????????????????$.
,ZZOOOOZ$I?????????$ZOOZ7+~:,....,I7II??+++==~:,..,+?????????Z.
.OZZZZOZZZZ+,..... :::~...Z$$.$$.=$II$$=........$$.,==++++??+Z.
OOZZZZOOO$.$$..$..= .$$$$$=,$=.,......$$$Z.$7.$$.ZIIII????+O.
OZZZ$ZZZ+.$$.~$.$. .$$$ .$$..I$ZZ.Z$.Z$.$$..$.$IOOOOOOZOOO
.,ZOOZZ:~.$$IZ$...$$$ .$$.$$.$7=$..$$.$$ $Z.ZZZZZ$$7ZO,
.$.$.I.. .$$$. $$.$$$Z..$$.$$=,$..$$.O?$OZZZZ..
...7OOO..$$$. .$$.$$ ..$$$7$.7,...,Z.$~
.. .$$$. .$$.$$$$,......OZZ,.
.$$$. ..$$......ZO.$..
Z$$$$$$Z..OZ....
..?$$$..OZ
$OOOZ,.
Mr. Clean
===
Let Mr. Clean keep your logs clean of sensitive data.
Imagine you have the following model
```kotlin
data class SensitiveData(val creditCardNumber: String, val socialSecurityNumber: String)
```
This model might be inadvertently logged, leaking sensitive data to the world.
One way to get around this is to override `toString` and manage your state.
```kotlin
data class SensitiveData(val creditCardNumber: String, val socialSecurityNumber: String) {
override toString(): String {
if (BuildConfig.DEBUG) {
return "SensitiveData(
creditCardNumber='$creditCardNumber'
socialSecurityNumber='$socialSecurityNumber'
)"
}
else {
return "SensitiveData@${Integer.toHexString(hashCode())}"
}
}
}
```
But now you have to make sure this stays updated when you add/remove properties.
**Enter Mr. Clean**
Annotate your class with `@Sanitize` and delegate to the generated `sanitizedToString` function:
```kotlin
@Sanitize
data class SensitiveData(val creditCardNumber: String, val socialSecurityNumber: String) {
override toString() = sanitizedToString()
}
```
**Note**: You don't have to build to get this function! The Gradle plugin will generate a default `Any.sanitizedToString` for use in the IDE.
Mr. Clean manages the implementation of the `toString` for you.
In debug builds, by default, Mr. Clean will utilize reflection to generate the toString on the fly.
You can disable this behavior by adding this to your build.gradle
```groovy
mrclean {
useReflectInDebug = false
}
```
By disabling reflection, you'll enable the annotation processor that generates code for you.
```kotlin
// in a debuggable build with reflect disabled
inline fun SensitiveData.sanitizedToString(condition: Boolean): String =
"SensitiveData(creditCardNumber = $creditCardNumber, socialSecurityNumber = $socialSecurityNumber)"
// in a non-debuggable build
inline fun SensitiveData.sanitizedToString(condition: Boolean): String = "SensitiveData@${Integer.toHexString(hashCode())}"
```
Don't leak sensitive info ever again, trust in Mr. Clean.
# Usage
```groovy
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.trello.mrclean:mr-clean-plugin:0.9.5'
}
}
```
and then apply to your modules
```groovy
apply plugin: 'com.trello.mrclean'
```
# Contributors
Pull requests, issues and comments welcome. For pull requests:
* Add tests for new features and bug fixes
* Follow the existing style
* Separate unrelated changes into multiple pull requests
See the existing issues for things to start contributing.
For bigger changes, make sure you start a discussion first by creating an issue and explaining the intended change.
Atlassian requires contributors to sign a Contributor License Agreement, known as a CLA. This serves as a record stating that the contributor is entitled to contribute the code/documentation/translation to the project and is willing to have it used in distributions and derivative works (or is willing to transfer ownership).
Prior to accepting your contributions we ask that you please follow the appropriate link below to digitally sign the CLA. The Corporate CLA is for those who are contributing as a member of an organization and the individual CLA is for those contributing as an individual.
* [CLA for corporate contributors](https://na2.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=e1c17c66-ca4d-4aab-a953-2c231af4a20b)
* [CLA for individuals](https://na2.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=3f94fbdc-2fbe-46ac-b14c-5d152700ae5d)
# License
Copyright (c) 2018 Atlassian and others. Apache 2.0 licensed, see LICENSE file.
没有合适的资源?快使用搜索试试~ 我知道了~
mr-clean,不要泄露敏感数据。.zip
共41个文件
kt:13个
gradle:7个
properties:7个
需积分: 10 0 下载量 114 浏览量
2019-09-25
03:52:05
上传
评论
收藏 90KB ZIP 举报
温馨提示
让clean先生保持日志中敏感数据的干净。
资源推荐
资源详情
资源评论
收起资源包目录
mr-clean.zip (41个子文件)
mr-clean-master
.gitignore 87B
gradle
wrapper
gradle-wrapper.jar 53KB
gradle-wrapper.properties 200B
gradle-mvn-push.gradle 5KB
README.md 8KB
.buildscript
deploy_snapshot.sh 936B
build.gradle 1KB
CHANGELOG.md 526B
mr-clean-processor
.gitignore 7B
build.gradle 581B
src
test
java
com
trello
mrclean
SanitizeGeneratorTest.kt 5KB
main
java
com
trello
mrclean
Metadata.kt 7KB
MrCleanProcessor.kt 4KB
KotlinTypes.kt 1KB
SanitizeGenerator.kt 1KB
gradle.properties 81B
gradlew.bat 2KB
gradlew 5KB
LICENSE 560B
RELEASING.md 950B
mr-clean-reflect
build.gradle 447B
src
test
java
com
trello
mrclean
reflect
ReflectTest.kt 3KB
main
java
com
trello
mrclean
reflect
Sanitizer.kt 409B
gradle.properties 77B
CODE_OF_CONDUCT.md 2KB
gradle.properties 556B
mr-clean-annotations
.gitignore 6B
build.gradle 256B
src
main
java
com
trello
mrclean
annotations
Sanitize.kt 1004B
gradle.properties 85B
bitbucket-pipelines.yml 615B
mr-clean-plugin
build.gradle 1KB
src
test
java
com
trello
mrclean
plugin
RootFunctionGeneratorTest.kt 1KB
main
resources
META-INF
gradle-plugins
com.trello.mrclean.properties 60B
java
com
trello
mrclean
plugin
MrCleanPlugin.kt 4KB
RootFunctionGenerator.kt 1KB
GenerateRootFunctions.kt 749B
MrCleanExtension.kt 107B
gradle.properties 75B
.travis.yml 2KB
settings.gradle 117B
共 41 条
- 1
资源评论
weixin_38744207
- 粉丝: 343
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功