-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Hide password values from raw HTTP logs. #4066
Hide password values from raw HTTP logs. #4066
Conversation
Status
|
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.
This is actually a good idea.
A few thoughts:
- If we just check for the presence of
NULL
key in the data, there will be many false positives (sinceNULL
will be used by the people while using modifier keys). To get around this, I was earlier thinking of adding a pattern of keys to value if we want to redact it, but a better solution would be to add theNULL
key at the starting of the value instead of at the end because normally users would never use aNULL
key at the start. With that, just check if thevalue
starts with aNULL
key and if so, mark it for redaction.
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.
This looks good now. Just a bunch of refactoring changes.
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.
Looks good!
One last thing, we should also add a test to make sure that the final generated report does not contain the actual password but *
s in rawHttpOutput
. We can get the rawHttpOutput
by defining a reporter
function in globals
config and then accessing results.modules.<moduleName>.rawHttpOutput
.
See the last test case of test/src/api/commands/element/testWaitForElementNotPresent.js
file for reference.
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.
There is still some scope for improvements in the tests. But I think this will make you really good at writing Nightwatch tests in the future :)
Please feel free to ask if you don't understand the reasoning behind anything.
0c1631c
to
60eb36f
Compare
I did a few refactors myself in the PR, but the major takeaway from the refactors is that while writing mocks we should also specify how many times we want the mock to run. By default, the mock will run for indefinite times, passing But thanks a lot for this PR, this looks really great now. |
Thanks @garg3133 for all the help 🙌 |
This is a supposed fix for #3935
So as explained in the issue (#3935 (comment)) there is no straightforward way to do this.
But here is something that works.
So basically there is called Modifier keys in Selenium webdriver and there is one that we can use,
Key.NULL
https://github.com/SeleniumHQ/selenium/blob/da62a402d0565dd2dda2ced71cf74965caa4391c/javascript/node/selenium-webdriver/lib/webdriver.js#L2644-L2646
Passing this key along without string DOES NOT affect the actual string that is sent to textbox, but comes as a
or ('\uE000') special Unicode character in the final response after executing the command on selenium.
I check for this character in the data, and any data containing this is flagged to be redacted.
Other potential solution (garg3133)
We could potentially also achieve this by adding a static variable to
HttpRequest
class (lib/http/request.js
) and setting/unsetting it just before and after runningelement.sendKeys()
command for.setPassword()
insidemethod-mappings.js
file. Using this static variable, we could decide at the time of logging of request whether or not to redact the request data.Instead of creating a separate static variable above, we could also call
HttpRequest.updateGlobalSettings({redact: true});
just before and afterelement.sendKeys()
command to setthis.httpOpts.redact
in therequest.js
file, and then use this option at the time of logging of request to decide whether or not to redact the request data.