Merge lp:~nataliabidart/ubuntuone-client/careful-logging into lp:ubuntuone-client

Proposed by Natalia Bidart
Status: Merged
Approved by: Roberto Alsina
Approved revision: 1119
Merged at revision: 1120
Proposed branch: lp:~nataliabidart/ubuntuone-client/careful-logging
Merge into: lp:ubuntuone-client
Diff against target: 92 lines (+25/-8)
2 files modified
ubuntuone/logger.py (+15/-3)
ubuntuone/platform/credentials/__init__.py (+10/-5)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-client/careful-logging
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+73407@code.launchpad.net

Commit message

- Do not log sensible data in CredentialsMangementTool (LP: #837488).

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntuone/logger.py'
--- ubuntuone/logger.py 2011-08-17 12:41:58 +0000
+++ ubuntuone/logger.py 2011-08-30 16:22:23 +0000
@@ -240,9 +240,11 @@
240 return True240 return True
241241
242242
243def log_call(log_func):243def log_call(log_func, with_args=True, with_result=True):
244 """Decorator to add a log entry using 'log_func'.244 """Decorator to add a log entry using 'log_func'.
245245
246 If not 'with_args', do not log arguments. Same apply to 'with_result'.
247
246 An example of use would be:248 An example of use would be:
247249
248 @log_call(logger.debug)250 @log_call(logger.debug)
@@ -257,9 +259,19 @@
257 @functools.wraps(f)259 @functools.wraps(f)
258 def inner(*args, **kwargs):260 def inner(*args, **kwargs):
259 """Call f(*args, **kwargs)."""261 """Call f(*args, **kwargs)."""
260 log_func('%s: args %r, kwargs %r.', f.__name__, args, kwargs)262 if with_args:
263 a, kw = args, kwargs
264 else:
265 a, kw = '<hidden args>', '<hidden kwargs>'
266 log_func('%s: args %r, kwargs %r.', f.__name__, a, kw)
267
261 res = f(*args, **kwargs)268 res = f(*args, **kwargs)
262 log_func('%s: result %r.', f.__name__, res)269
270 if with_result:
271 log_func('%s: result %r.', f.__name__, res)
272 else:
273 log_func('%s: result %r.', f.__name__, '<hidden result>')
274
263 return res275 return res
264276
265 return inner277 return inner
266278
=== modified file 'ubuntuone/platform/credentials/__init__.py'
--- ubuntuone/platform/credentials/__init__.py 2011-08-25 12:25:02 +0000
+++ ubuntuone/platform/credentials/__init__.py 2011-08-30 16:22:23 +0000
@@ -122,7 +122,8 @@
122 self._proxy = yield source.get_creds_proxy()122 self._proxy = yield source.get_creds_proxy()
123 defer.returnValue(self._proxy)123 defer.returnValue(self._proxy)
124124
125 @log_call(logger.debug)125 # do not log returned credentials
126 @log_call(logger.debug, with_result=False)
126 @defer.inlineCallbacks127 @defer.inlineCallbacks
127 def find_credentials(self):128 def find_credentials(self):
128 """Find credentials for Ubuntu One.129 """Find credentials for Ubuntu One.
@@ -199,7 +200,8 @@
199200
200 yield d201 yield d
201202
202 @log_call(logger.debug)203 # do not log token
204 @log_call(logger.debug, with_args=False)
203 @defer.inlineCallbacks205 @defer.inlineCallbacks
204 def store_credentials(self, token):206 def store_credentials(self, token):
205 """Store credentials for Ubuntu One.207 """Store credentials for Ubuntu One.
@@ -234,7 +236,8 @@
234236
235 yield d237 yield d
236238
237 @log_call(logger.debug)239 # do not log returned credentials
240 @log_call(logger.debug, with_result=False)
238 @defer.inlineCallbacks241 @defer.inlineCallbacks
239 def register(self, window_id=0):242 def register(self, window_id=0):
240 """Register to Ubuntu One.243 """Register to Ubuntu One.
@@ -281,7 +284,8 @@
281 result = yield d284 result = yield d
282 defer.returnValue(result)285 defer.returnValue(result)
283286
284 @log_call(logger.debug)287 # do not log returned credentials
288 @log_call(logger.debug, with_result=False)
285 @defer.inlineCallbacks289 @defer.inlineCallbacks
286 def login(self, window_id=0):290 def login(self, window_id=0):
287 """Login to Ubuntu One.291 """Login to Ubuntu One.
@@ -329,7 +333,8 @@
329 result = yield d333 result = yield d
330 defer.returnValue(result)334 defer.returnValue(result)
331335
332 @log_call(logger.debug)336 # do not log password nor returned credentials
337 @log_call(logger.debug, with_args=False, with_result=False)
333 @defer.inlineCallbacks338 @defer.inlineCallbacks
334 def login_email_password(self, email, password):339 def login_email_password(self, email, password):
335 """Login to Ubuntu One.340 """Login to Ubuntu One.

Subscribers

People subscribed via source and target branches