Merge lp:~dholbach/click-reviewers-tools/1530894 into lp:click-reviewers-tools

Proposed by Daniel Holbach
Status: Merged
Merged at revision: 564
Proposed branch: lp:~dholbach/click-reviewers-tools/1530894
Merge into: lp:click-reviewers-tools
Diff against target: 65 lines (+23/-5)
2 files modified
clickreviews/cr_common.py (+20/-4)
debian/changelog (+3/-1)
To merge this branch: bzr merge lp:~dholbach/click-reviewers-tools/1530894
Reviewer Review Type Date Requested Status
Jamie Strandboge (community) Needs Fixing
Canonical Store Reviewers Pending
Review via email: mp+281730@code.launchpad.net
To post a comment you must log in.
565. By Daniel Holbach

return False if message catalog can't be opened

Revision history for this message
Daniel Holbach (dholbach) wrote :

http://paste.ubuntu.com/14418943/ is a sketch of a test, but with _list_all_compiled_binaries not being run during tests currently not useful.

Revision history for this message
Daniel Holbach (dholbach) wrote :

<beuno> and I'll comment on the MP that I wouldn't even probe for .mo's to be mo's
<dholbach> so fn.endswith('.mo') would be good enough for you?
<beuno> dholbach, it would, yes

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

I agree that only checking for .mo is enough (it is cheap and sufficient). Marking as 'Needs fixing' for this comment, buy I will be merging an updated commit with a test case momentarily.

review: Needs Fixing
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

12:11 < jdstrand> beuno: I committed dholbach's change with some changes in r564. It
                  sounds like it would be a good time for a sync of the review tools
12:11 < jdstrand> beuno: and hi!
12:11 < beuno> jdstrand, o/
12:11 < beuno> ack

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'clickreviews/cr_common.py'
2--- clickreviews/cr_common.py 2015-12-02 19:27:17 +0000
3+++ clickreviews/cr_common.py 2016-01-06 09:32:03 +0000
4@@ -18,6 +18,7 @@
5 import atexit
6 import codecs
7 from debian.deb822 import Deb822
8+import gettext
9 import glob
10 import inspect
11 import json
12@@ -114,6 +115,12 @@
13 "security-template",
14 "security-override",
15 "security-policy"]
16+ magic_binary_file_descriptions = [
17+ 'application/x-executable; charset=binary',
18+ 'application/x-sharedlib; charset=binary',
19+ 'application/x-object; charset=binary',
20+ 'application/octet-stream; charset=binary'
21+ ]
22
23 def __init__(self, fn, review_type, peer_hooks=None, overrides=None,
24 peer_hooks_link=None):
25@@ -317,14 +324,23 @@
26 for f in filenames:
27 self.pkg_files.append(os.path.join(root, f))
28
29+ def _check_if_message_catalog(self, fn):
30+ '''Check if file is a message catalog (.mo file).'''
31+ if fn.endswith('.mo'):
32+ try:
33+ gettext.GNUTranslations(open(fn, 'rb'))
34+ return True
35+ except:
36+ return False
37+ return False
38+
39+
40 def _list_all_compiled_binaries(self):
41 '''List all compiled binaries in this click package.'''
42 for i in self.pkg_files:
43 res = self.mime.file(i)
44- if res in ['application/x-executable; charset=binary',
45- 'application/x-sharedlib; charset=binary',
46- 'application/x-object; charset=binary',
47- 'application/octet-stream; charset=binary']:
48+ if res in self.magic_binary_file_descriptions and \
49+ not self._check_if_message_catalog(i):
50 self.pkg_bin_files.append(i)
51
52 def _verify_manifest_structure(self):
53
54=== modified file 'debian/changelog'
55--- debian/changelog 2015-12-14 22:35:22 +0000
56+++ debian/changelog 2016-01-06 09:32:03 +0000
57@@ -1,6 +1,8 @@
58 click-reviewers-tools (0.36) UNRELEASED; urgency=medium
59
60- *
61+ [ Daniel Holbach ]
62+ * Add check if suspected (using python-magic) compiled binaries
63+ aren't actually just message catalogs (.mo files) (LP: #1530894).
64
65 -- Jamie Strandboge <jamie@ubuntu.com> Mon, 14 Dec 2015 16:34:46 -0600
66

Subscribers

People subscribed via source and target branches