mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 00:10:25 +08:00 
			
		
		
		
	Perf: hide mongodb passwords when printing logs
This commit is contained in:
		@@ -34,6 +34,11 @@ func (m *Mongo) Save(rc *ctx.ReqCtx) {
 | 
				
			|||||||
	form := &form.Mongo{}
 | 
						form := &form.Mongo{}
 | 
				
			||||||
	ginx.BindJsonAndValid(rc.GinCtx, form)
 | 
						ginx.BindJsonAndValid(rc.GinCtx, form)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 密码脱敏记录日志
 | 
				
			||||||
 | 
						form.Uri = func(str string) string {
 | 
				
			||||||
 | 
							reg := regexp.MustCompile(`(^mongodb://.+?:)(.+)(@.+$)`)
 | 
				
			||||||
 | 
							return reg.ReplaceAllString(str, `${1}****${3}`)
 | 
				
			||||||
 | 
						}(form.Uri)
 | 
				
			||||||
	rc.ReqParam = form
 | 
						rc.ReqParam = form
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mongo := new(entity.Mongo)
 | 
						mongo := new(entity.Mongo)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user