Skip to content
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

If Cloudcode function failed, log may print the password clearly. #3789

Closed
youngerong opened this issue May 8, 2017 · 4 comments
Closed

Comments

@youngerong
Copy link
Contributor

I add a cloudcode function, the input params has username, password and so on. If the cloudcode function went error, I will log the error like this:
res.error(1002,'verify code error');
But I see Parse Server record the error information in the log file like this:
Failed running cloud function signUp for user undefined with:
Input: {"phone":"13151594883","password":"********","verifyCode":"773172","username":"86-13151594883","area":"86"}
Error: {"code":1002,"message":"verify code error"} functionName=signUp, code=1002, message=verify code error, phone=13151594883, password=123456, verifyCode=773172, username=86-13151594883, area=86, user=undefined

We can see the error information change the input password to "********",but print the password in the param list clearly.

So I debug the code and find out the reason.
Controllers/LoggerController.js has a function called maskSensitive, every log message will be checked if need to make it sensitive. But when log the param list, input parameter is an Object with params including username ,password and so on. The function just check "if (e.body)", did not check "e.params", so I add it to solve this problem.
if (e.body) {
for (let key of Object.keys(e.body)) {
if (key === 'password') {
e.body[key] = '********';
break;
}
}
}

if (e.params) {
  for (let key of Object.keys(e.params)) {
    if (key === 'password') {
      e.params[key] = '********';
      break;
    }
  }
}

image

@flovilmart
Copy link
Contributor

Can you open a pull request for that issue?

@youngerong
Copy link
Contributor Author

youngerong commented May 8, 2017 via email

@flovilmart
Copy link
Contributor

Thanks!

This was referenced May 9, 2017
@jpv123
Copy link

jpv123 commented Jun 30, 2017

@youngerong How are you debugging your cloud code? I can't find how and I need exactly what you use in your screenshot

thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants