-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Mask secret query parameter when it is the last parameter #4055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ public class DataUtils { | |
| public static <E> E handleDataWithSecret(E data) { | ||
| E dataForLog = data; | ||
| if(data instanceof String && StringUtils.contains((String)data, "&secret=")){ | ||
| dataForLog = (E) RegExUtils.replaceAll((String)data,"&secret=\\w+&","&secret=******&"); | ||
| dataForLog = (E) RegExUtils.replaceAll((String)data,"&secret=\\w+","&secret=******"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Severity: medium 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| } | ||
| return dataForLog; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
当待记录的请求参数中
secret值包含 URL 编码或-、.、+等非\w字符时,这个正则只会替换到第一个非 word 字符为止;例如appid=wx&secret=abc%2Fdef会被记录成appid=wx&secret=******%2Fdef,仍然泄露后半段密钥。这里是日志脱敏逻辑,建议按参数边界匹配值(如直到下一个&或字符串结尾),而不是按\w+匹配。Useful? React with 👍 / 👎.