You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by si chen <si...@gmail.com> on 2011/02/10 00:03:01 UTC

how to avoid a password field in toString

Hi
I am using thrift to pass a struct like below:

struct User {
1: string user;
2: string password;
}

It works as expected, however, the "toString" method generated by thrift
always add the password field in plain text, how can I instruct thrift NOT
to include password field in toString method? I mean, if I log the struct, I
don't want to see the password being printed to log in plain text.

User u;
u.setUser("user");
u.setPassword("1234");
log.info(u);

Thanks
Si

Re: how to avoid a password field in toString

Posted by Joshua Kehn <jo...@kobemail.com>.
You don't want to be logging passwords in cleartext. Instead remove the password from it prior to logging or hash the password. 

Regards,

-Josh
___________________________
http://joshuakehn.com
Currently mobile

On Feb 9, 2011, at 6:09 PM, si chen <si...@gmail.com> wrote:

> Thanks, Josh.
> Generally, is there a way we can control how thrift generate toString
> method?
> 
> On Wed, Feb 9, 2011 at 3:04 PM, Joshua Kehn <jo...@kobemail.com> wrote:
> 
>> My solution would be to not pass a password around in plaintext.
>> 
>> Regards,
>> 
>> -Josh
>> ____________________________________
>> Joshua Kehn | Josh@kobemail.com
>> "Wielder of the Programming Broomstick"
>> 
>> On Feb 9, 2011, at 6:03 PM, si chen wrote:
>> 
>>> Hi
>>> I am using thrift to pass a struct like below:
>>> 
>>> struct User {
>>> 1: string user;
>>> 2: string password;
>>> }
>>> 
>>> It works as expected, however, the "toString" method generated by thrift
>>> always add the password field in plain text, how can I instruct thrift
>> NOT
>>> to include password field in toString method? I mean, if I log the
>> struct, I
>>> don't want to see the password being printed to log in plain text.
>>> 
>>> User u;
>>> u.setUser("user");
>>> u.setPassword("1234");
>>> log.info(u);
>>> 
>>> Thanks
>>> Si
>> 
>> 

Re: how to avoid a password field in toString

Posted by Joshua Kehn <jo...@gmail.com>.
You don't want to be logging passwords in cleartext. Instead remove the password from it prior to logging or hash the password. 

Regards,

-Josh
___________________________
http://joshuakehn.com
Currently mobile

On Feb 9, 2011, at 6:09 PM, si chen <si...@gmail.com> wrote:

> Thanks, Josh.
> Generally, is there a way we can control how thrift generate toString
> method?
> 
> On Wed, Feb 9, 2011 at 3:04 PM, Joshua Kehn <jo...@kobemail.com> wrote:
> 
>> My solution would be to not pass a password around in plaintext.
>> 
>> Regards,
>> 
>> -Josh
>> ____________________________________
>> Joshua Kehn | Josh@kobemail.com
>> "Wielder of the Programming Broomstick"
>> 
>> On Feb 9, 2011, at 6:03 PM, si chen wrote:
>> 
>>> Hi
>>> I am using thrift to pass a struct like below:
>>> 
>>> struct User {
>>> 1: string user;
>>> 2: string password;
>>> }
>>> 
>>> It works as expected, however, the "toString" method generated by thrift
>>> always add the password field in plain text, how can I instruct thrift
>> NOT
>>> to include password field in toString method? I mean, if I log the
>> struct, I
>>> don't want to see the password being printed to log in plain text.
>>> 
>>> User u;
>>> u.setUser("user");
>>> u.setPassword("1234");
>>> log.info(u);
>>> 
>>> Thanks
>>> Si
>> 
>> 

Re: how to avoid a password field in toString

Posted by Chris Morgan <ch...@gmail.com>.
Yes I think the point was conveyed clearly. I agree on both accounts.

Chris


On Wed, Feb 9, 2011 at 6:50 PM, Dheeraj Goswami
<dh...@yahoo.com> wrote:
> a) I think it is obvious that security sensitive information like password should never be used in toString or should never be logged etc.
> b) But his question is still valid and that is - "Is there a way to control the toString() in thrift"
> Looks like we are mixing a) & b)
>
> cheers,
>
> --dheeraj
>
> --- On Wed, 2/9/11, Chris Morgan <ch...@gmail.com> wrote:
>
> From: Chris Morgan <ch...@gmail.com>
> Subject: Re: how to avoid a password field in toString
> To: "user@thrift.apache.org" <us...@thrift.apache.org>
> Date: Wednesday, February 9, 2011, 3:40 PM
>
> Josh is pointing you in the right direction. You should hash the password.
>
> What kind of system is this? Security has to be considered from end to
> end. Are you communicating between two systems? Who are you worried
> about calling tostring()?
>
> Chris
>
>
> On Feb 9, 2011, at 6:10 PM, si chen <si...@gmail.com> wrote:
>
>> Thanks, Josh.
>> Generally, is there a way we can control how thrift generate toString
>> method?
>>
>> On Wed, Feb 9, 2011 at 3:04 PM, Joshua Kehn <jo...@kobemail.com> wrote:
>>
>>> My solution would be to not pass a password around in plaintext.
>>>
>>> Regards,
>>>
>>> -Josh
>>> ____________________________________
>>> Joshua Kehn | Josh@kobemail.com
>>> "Wielder of the Programming Broomstick"
>>>
>>> On Feb 9, 2011, at 6:03 PM, si chen wrote:
>>>
>>>> Hi
>>>> I am using thrift to pass a struct like below:
>>>>
>>>> struct User {
>>>> 1: string user;
>>>> 2: string password;
>>>> }
>>>>
>>>> It works as expected, however, the "toString" method generated by thrift
>>>> always add the password field in plain text, how can I instruct thrift
>>> NOT
>>>> to include password field in toString method? I mean, if I log the
>>> struct, I
>>>> don't want to see the password being printed to log in plain text.
>>>>
>>>> User u;
>>>> u.setUser("user");
>>>> u.setPassword("1234");
>>>> log.info(u);
>>>>
>>>> Thanks
>>>> Si
>>>
>>>
>

Re: how to avoid a password field in toString

Posted by Joshua Kehn <jo...@kobemail.com>.
Nice answer.

My guess would have been no because it's just suppose to handle everything it is given without discrimination. 

Regards,

-Josh
____________________________________
Joshua Kehn | Josh@kobemail.com
"Wielder of the Programming Broomstick"

On Feb 9, 2011, at 6:56 PM, Bryan Duxbury wrote:

> No.
> 
> On Wed, Feb 9, 2011 at 3:55 PM, si chen <si...@gmail.com> wrote:
> 
>> Exactly, let's forget about the password. Is there a way to control how
>> thrift generate toString?
>> 
>> On Wed, Feb 9, 2011 at 3:50 PM, Dheeraj Goswami <dheerajgoswami@yahoo.com
>>> wrote:
>> 
>>> a) I think it is obvious that security sensitive information like
>> password
>>> should never be used in toString or should never be logged etc.
>>> b) But his question is still valid and that is - "Is there a way to
>> control
>>> the toString() in thrift"
>>> Looks like we are mixing a) & b)
>>> 
>>> cheers,
>>> 
>>> --dheeraj
>>> 
>>> --- On Wed, 2/9/11, Chris Morgan <ch...@gmail.com> wrote:
>>> 
>>> From: Chris Morgan <ch...@gmail.com>
>>> Subject: Re: how to avoid a password field in toString
>>> To: "user@thrift.apache.org" <us...@thrift.apache.org>
>>> Date: Wednesday, February 9, 2011, 3:40 PM
>>> 
>>> Josh is pointing you in the right direction. You should hash the
>> password.
>>> 
>>> What kind of system is this? Security has to be considered from end to
>>> end. Are you communicating between two systems? Who are you worried
>>> about calling tostring()?
>>> 
>>> Chris
>>> 
>>> 
>>> On Feb 9, 2011, at 6:10 PM, si chen <si...@gmail.com> wrote:
>>> 
>>>> Thanks, Josh.
>>>> Generally, is there a way we can control how thrift generate toString
>>>> method?
>>>> 
>>>> On Wed, Feb 9, 2011 at 3:04 PM, Joshua Kehn <jo...@kobemail.com> wrote:
>>>> 
>>>>> My solution would be to not pass a password around in plaintext.
>>>>> 
>>>>> Regards,
>>>>> 
>>>>> -Josh
>>>>> ____________________________________
>>>>> Joshua Kehn | Josh@kobemail.com
>>>>> "Wielder of the Programming Broomstick"
>>>>> 
>>>>> On Feb 9, 2011, at 6:03 PM, si chen wrote:
>>>>> 
>>>>>> Hi
>>>>>> I am using thrift to pass a struct like below:
>>>>>> 
>>>>>> struct User {
>>>>>> 1: string user;
>>>>>> 2: string password;
>>>>>> }
>>>>>> 
>>>>>> It works as expected, however, the "toString" method generated by
>>> thrift
>>>>>> always add the password field in plain text, how can I instruct
>> thrift
>>>>> NOT
>>>>>> to include password field in toString method? I mean, if I log the
>>>>> struct, I
>>>>>> don't want to see the password being printed to log in plain text.
>>>>>> 
>>>>>> User u;
>>>>>> u.setUser("user");
>>>>>> u.setPassword("1234");
>>>>>> log.info(u);
>>>>>> 
>>>>>> Thanks
>>>>>> Si
>>>>> 
>>>>> 
>>> 
>> 


Re: how to avoid a password field in toString

Posted by Bryan Duxbury <br...@rapleaf.com>.
No.

On Wed, Feb 9, 2011 at 3:55 PM, si chen <si...@gmail.com> wrote:

> Exactly, let's forget about the password. Is there a way to control how
> thrift generate toString?
>
> On Wed, Feb 9, 2011 at 3:50 PM, Dheeraj Goswami <dheerajgoswami@yahoo.com
> >wrote:
>
> > a) I think it is obvious that security sensitive information like
> password
> > should never be used in toString or should never be logged etc.
> > b) But his question is still valid and that is - "Is there a way to
> control
> > the toString() in thrift"
> > Looks like we are mixing a) & b)
> >
> > cheers,
> >
> > --dheeraj
> >
> > --- On Wed, 2/9/11, Chris Morgan <ch...@gmail.com> wrote:
> >
> > From: Chris Morgan <ch...@gmail.com>
> > Subject: Re: how to avoid a password field in toString
> > To: "user@thrift.apache.org" <us...@thrift.apache.org>
> > Date: Wednesday, February 9, 2011, 3:40 PM
> >
> > Josh is pointing you in the right direction. You should hash the
> password.
> >
> > What kind of system is this? Security has to be considered from end to
> > end. Are you communicating between two systems? Who are you worried
> > about calling tostring()?
> >
> > Chris
> >
> >
> > On Feb 9, 2011, at 6:10 PM, si chen <si...@gmail.com> wrote:
> >
> > > Thanks, Josh.
> > > Generally, is there a way we can control how thrift generate toString
> > > method?
> > >
> > > On Wed, Feb 9, 2011 at 3:04 PM, Joshua Kehn <jo...@kobemail.com> wrote:
> > >
> > >> My solution would be to not pass a password around in plaintext.
> > >>
> > >> Regards,
> > >>
> > >> -Josh
> > >> ____________________________________
> > >> Joshua Kehn | Josh@kobemail.com
> > >> "Wielder of the Programming Broomstick"
> > >>
> > >> On Feb 9, 2011, at 6:03 PM, si chen wrote:
> > >>
> > >>> Hi
> > >>> I am using thrift to pass a struct like below:
> > >>>
> > >>> struct User {
> > >>> 1: string user;
> > >>> 2: string password;
> > >>> }
> > >>>
> > >>> It works as expected, however, the "toString" method generated by
> > thrift
> > >>> always add the password field in plain text, how can I instruct
> thrift
> > >> NOT
> > >>> to include password field in toString method? I mean, if I log the
> > >> struct, I
> > >>> don't want to see the password being printed to log in plain text.
> > >>>
> > >>> User u;
> > >>> u.setUser("user");
> > >>> u.setPassword("1234");
> > >>> log.info(u);
> > >>>
> > >>> Thanks
> > >>> Si
> > >>
> > >>
> >
>

Re: how to avoid a password field in toString

Posted by si chen <si...@gmail.com>.
Exactly, let's forget about the password. Is there a way to control how
thrift generate toString?

On Wed, Feb 9, 2011 at 3:50 PM, Dheeraj Goswami <dh...@yahoo.com>wrote:

> a) I think it is obvious that security sensitive information like password
> should never be used in toString or should never be logged etc.
> b) But his question is still valid and that is - "Is there a way to control
> the toString() in thrift"
> Looks like we are mixing a) & b)
>
> cheers,
>
> --dheeraj
>
> --- On Wed, 2/9/11, Chris Morgan <ch...@gmail.com> wrote:
>
> From: Chris Morgan <ch...@gmail.com>
> Subject: Re: how to avoid a password field in toString
> To: "user@thrift.apache.org" <us...@thrift.apache.org>
> Date: Wednesday, February 9, 2011, 3:40 PM
>
> Josh is pointing you in the right direction. You should hash the password.
>
> What kind of system is this? Security has to be considered from end to
> end. Are you communicating between two systems? Who are you worried
> about calling tostring()?
>
> Chris
>
>
> On Feb 9, 2011, at 6:10 PM, si chen <si...@gmail.com> wrote:
>
> > Thanks, Josh.
> > Generally, is there a way we can control how thrift generate toString
> > method?
> >
> > On Wed, Feb 9, 2011 at 3:04 PM, Joshua Kehn <jo...@kobemail.com> wrote:
> >
> >> My solution would be to not pass a password around in plaintext.
> >>
> >> Regards,
> >>
> >> -Josh
> >> ____________________________________
> >> Joshua Kehn | Josh@kobemail.com
> >> "Wielder of the Programming Broomstick"
> >>
> >> On Feb 9, 2011, at 6:03 PM, si chen wrote:
> >>
> >>> Hi
> >>> I am using thrift to pass a struct like below:
> >>>
> >>> struct User {
> >>> 1: string user;
> >>> 2: string password;
> >>> }
> >>>
> >>> It works as expected, however, the "toString" method generated by
> thrift
> >>> always add the password field in plain text, how can I instruct thrift
> >> NOT
> >>> to include password field in toString method? I mean, if I log the
> >> struct, I
> >>> don't want to see the password being printed to log in plain text.
> >>>
> >>> User u;
> >>> u.setUser("user");
> >>> u.setPassword("1234");
> >>> log.info(u);
> >>>
> >>> Thanks
> >>> Si
> >>
> >>
>

Re: how to avoid a password field in toString

Posted by Dheeraj Goswami <dh...@yahoo.com>.
a) I think it is obvious that security sensitive information like password should never be used in toString or should never be logged etc.
b) But his question is still valid and that is - "Is there a way to control the toString() in thrift"
Looks like we are mixing a) & b)

cheers,

--dheeraj

--- On Wed, 2/9/11, Chris Morgan <ch...@gmail.com> wrote:

From: Chris Morgan <ch...@gmail.com>
Subject: Re: how to avoid a password field in toString
To: "user@thrift.apache.org" <us...@thrift.apache.org>
Date: Wednesday, February 9, 2011, 3:40 PM

Josh is pointing you in the right direction. You should hash the password.

What kind of system is this? Security has to be considered from end to
end. Are you communicating between two systems? Who are you worried
about calling tostring()?

Chris


On Feb 9, 2011, at 6:10 PM, si chen <si...@gmail.com> wrote:

> Thanks, Josh.
> Generally, is there a way we can control how thrift generate toString
> method?
>
> On Wed, Feb 9, 2011 at 3:04 PM, Joshua Kehn <jo...@kobemail.com> wrote:
>
>> My solution would be to not pass a password around in plaintext.
>>
>> Regards,
>>
>> -Josh
>> ____________________________________
>> Joshua Kehn | Josh@kobemail.com
>> "Wielder of the Programming Broomstick"
>>
>> On Feb 9, 2011, at 6:03 PM, si chen wrote:
>>
>>> Hi
>>> I am using thrift to pass a struct like below:
>>>
>>> struct User {
>>> 1: string user;
>>> 2: string password;
>>> }
>>>
>>> It works as expected, however, the "toString" method generated by thrift
>>> always add the password field in plain text, how can I instruct thrift
>> NOT
>>> to include password field in toString method? I mean, if I log the
>> struct, I
>>> don't want to see the password being printed to log in plain text.
>>>
>>> User u;
>>> u.setUser("user");
>>> u.setPassword("1234");
>>> log.info(u);
>>>
>>> Thanks
>>> Si
>>
>>

Re: how to avoid a password field in toString

Posted by Chris Morgan <ch...@gmail.com>.
Josh is pointing you in the right direction. You should hash the password.

What kind of system is this? Security has to be considered from end to
end. Are you communicating between two systems? Who are you worried
about calling tostring()?

Chris


On Feb 9, 2011, at 6:10 PM, si chen <si...@gmail.com> wrote:

> Thanks, Josh.
> Generally, is there a way we can control how thrift generate toString
> method?
>
> On Wed, Feb 9, 2011 at 3:04 PM, Joshua Kehn <jo...@kobemail.com> wrote:
>
>> My solution would be to not pass a password around in plaintext.
>>
>> Regards,
>>
>> -Josh
>> ____________________________________
>> Joshua Kehn | Josh@kobemail.com
>> "Wielder of the Programming Broomstick"
>>
>> On Feb 9, 2011, at 6:03 PM, si chen wrote:
>>
>>> Hi
>>> I am using thrift to pass a struct like below:
>>>
>>> struct User {
>>> 1: string user;
>>> 2: string password;
>>> }
>>>
>>> It works as expected, however, the "toString" method generated by thrift
>>> always add the password field in plain text, how can I instruct thrift
>> NOT
>>> to include password field in toString method? I mean, if I log the
>> struct, I
>>> don't want to see the password being printed to log in plain text.
>>>
>>> User u;
>>> u.setUser("user");
>>> u.setPassword("1234");
>>> log.info(u);
>>>
>>> Thanks
>>> Si
>>
>>

Re: how to avoid a password field in toString

Posted by si chen <si...@gmail.com>.
Thanks, Josh.
Generally, is there a way we can control how thrift generate toString
method?

On Wed, Feb 9, 2011 at 3:04 PM, Joshua Kehn <jo...@kobemail.com> wrote:

> My solution would be to not pass a password around in plaintext.
>
> Regards,
>
> -Josh
> ____________________________________
> Joshua Kehn | Josh@kobemail.com
> "Wielder of the Programming Broomstick"
>
> On Feb 9, 2011, at 6:03 PM, si chen wrote:
>
> > Hi
> > I am using thrift to pass a struct like below:
> >
> > struct User {
> > 1: string user;
> > 2: string password;
> > }
> >
> > It works as expected, however, the "toString" method generated by thrift
> > always add the password field in plain text, how can I instruct thrift
> NOT
> > to include password field in toString method? I mean, if I log the
> struct, I
> > don't want to see the password being printed to log in plain text.
> >
> > User u;
> > u.setUser("user");
> > u.setPassword("1234");
> > log.info(u);
> >
> > Thanks
> > Si
>
>

Re: how to avoid a password field in toString

Posted by Joshua Kehn <jo...@kobemail.com>.
My solution would be to not pass a password around in plaintext.

Regards,

-Josh
____________________________________
Joshua Kehn | Josh@kobemail.com
"Wielder of the Programming Broomstick"

On Feb 9, 2011, at 6:03 PM, si chen wrote:

> Hi
> I am using thrift to pass a struct like below:
> 
> struct User {
> 1: string user;
> 2: string password;
> }
> 
> It works as expected, however, the "toString" method generated by thrift
> always add the password field in plain text, how can I instruct thrift NOT
> to include password field in toString method? I mean, if I log the struct, I
> don't want to see the password being printed to log in plain text.
> 
> User u;
> u.setUser("user");
> u.setPassword("1234");
> log.info(u);
> 
> Thanks
> Si