Skip to content

Password may not be obscured by inspect if it contains meta-characters #421

Open
@sebbASF

Description

@sebbASF

The LDAP::inspect method uses gsub to obscure the password:

inspected.gsub! @auth[:password], "*******" if @auth[:password]

This works in most cases; however if the password contains certain meta-characters, replacement can fail. For example, using

password = "abcd\efgh"

will cause the replacement to fail. I think this is because the inspect output for such passwords is different from the original.

The following code works better, though it does also replace the enclosing double-quotes:

inspected.gsub! @auth[:password].inspect, "*******" if @auth[:password]

There is a further issue: if the password should happen to match another part of the inspect output, that will also be replaced. This is not particularly likely, however it would be good to fix it.

Maybe consider cloning the instance and zapping the password before passing it to inspect.
That would keep the enclosing quotes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions