launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19675
[Merge] lp:~james-w/python-oops-datedir-repo/str-time into lp:python-oops-datedir-repo
James Westby has proposed merging lp:~james-w/python-oops-datedir-repo/str-time into lp:python-oops-datedir-repo.
Commit message:
Ignore timestamps that aren't datetimes.
If a bad client sends a timestamp as a string/int or
something then we need to ignore it, not crash.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~james-w/python-oops-datedir-repo/str-time/+merge/275883
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~james-w/python-oops-datedir-repo/str-time into lp:python-oops-datedir-repo.
=== modified file 'oops_datedir_repo/repository.py'
--- oops_datedir_repo/repository.py 2015-10-26 11:32:20 +0000
+++ oops_datedir_repo/repository.py 2015-10-27 16:26:25 +0000
@@ -287,6 +287,7 @@
report = serializer.read(report_file)
report_time = report.get('time', None)
if (report_time is None or
+ getattr(report_time, 'date', None) is None or
report_time.date() < dirdate or
report_time.date() > dirdate):
# The report is oddly filed or missing a precise
=== modified file 'oops_datedir_repo/tests/test_repository.py'
--- oops_datedir_repo/tests/test_repository.py 2015-10-26 15:02:42 +0000
+++ oops_datedir_repo/tests/test_repository.py 2015-10-27 16:26:25 +0000
@@ -391,8 +391,10 @@
old = now - datetime.timedelta(minutes=2)
badtime = {'time': now - datetime.timedelta(weeks=2)}
missingtime = {}
+ strtime = {'time': "some-time"}
repo.publish(badtime, now)
repo.publish(missingtime, now)
+ repo.publish(strtime, now)
repo.prune_unreferenced(old, now, [])
self.assertThat(lambda: repo.oldest_date(), raises(ValueError))