Merge lp:~jdstrand/click-reviewers-tools/click-reviewers-tools.snappy1604 into lp:click-reviewers-tools

Proposed by Jamie Strandboge
Status: Merged
Merged at revision: 555
Proposed branch: lp:~jdstrand/click-reviewers-tools/click-reviewers-tools.snappy1604
Merge into: lp:click-reviewers-tools
Diff against target: 3029 lines (+1432/-469)
23 files modified
check-names.list (+2/-6)
clickreviews/cr_common.py (+82/-30)
clickreviews/cr_content_hub.py (+4/-0)
clickreviews/cr_desktop.py (+11/-4)
clickreviews/cr_framework.py (+13/-11)
clickreviews/cr_functional.py (+9/-10)
clickreviews/cr_lint.py (+113/-109)
clickreviews/cr_online_accounts.py (+10/-0)
clickreviews/cr_push_helper.py (+7/-0)
clickreviews/cr_scope.py (+4/-0)
clickreviews/cr_security.py (+210/-104)
clickreviews/cr_tests.py (+41/-1)
clickreviews/cr_url_dispatcher.py (+4/-0)
clickreviews/tests/test_cr_content_hub.py (+25/-0)
clickreviews/tests/test_cr_desktop.py (+28/-0)
clickreviews/tests/test_cr_lint.py (+386/-112)
clickreviews/tests/test_cr_online_accounts.py (+24/-0)
clickreviews/tests/test_cr_push_helper.py (+20/-0)
clickreviews/tests/test_cr_scope.py (+24/-0)
clickreviews/tests/test_cr_security.py (+334/-62)
clickreviews/tests/test_cr_url_dispatcher.py (+24/-0)
clickreviews/tests/utils.py (+28/-20)
debian/changelog (+29/-0)
To merge this branch: bzr merge lp:~jdstrand/click-reviewers-tools/click-reviewers-tools.snappy1604
Reviewer Review Type Date Requested Status
Jamie Strandboge (community) Approve
Michael Vogt Pending
Review via email: mp+278218@code.launchpad.net

Description of the change

This is a big branch to support all snaps and squashfs. In particular:

* add kernel and os as valid snap types
* remove package filename checks. They were meaningless and hard to maintain
* several changes for squashfs snaps that won't have a click manifest, etc.
  Importantly, this means that only package.yaml is looked at and a lot of
  click specific tests can be skipped
  - cr_common.py:
    + rename a few variable to not be click specific
    + add self.pkgfmt
    + adjust __init__() to conditionally use package.yaml on squashfs,
      otherwise click manifest
    + make click data structure initialization conditional on if click
      or not (eg, don't run hooks code on squashfs images)
  - adjust clickreviews/cr_* to conditionally run certain click-only tests
    on click packages
  - adjust architecture checks to use self.pkg_arch and rename
    control_architecture_specified_needed as architecture_specified_needed
  - cr_security.py:
    + revamp to use package.yaml on non-click instead of now nonexistent
      security manifest
    + update push-helper template test to not make hooks specific
    + network-client should not be allowed with push helpers either
    + conditionally look for INSTALL_DIR on 16.04 systems in security-policy
    + adjust security-override checks on 16.04 to follow 16.04 yaml
    + make click manifest checks conditional on if click
  - cr_tests.py: mock _pkgfmt_type(), _pkgfmt_version() and _is_squashfs()

Testing consisted of:
* comparing the output of 'click-review -v' on all clicks in the store with trunk and with this branch
* comparing the output of 'click-review -v' on all non-squashfs snaps in the store with trunk and with this branch
* comparing the output of 'click-review -v' on hello-world.canonial snap (click format) and hello-world.mvo snap (squashfs format) to make sure the correct tests are being run
* testing 'click-review -v' on all squashfs snaps

I don't necessarily expect people to go through this whole branch, but I wanted people to see it before committing. I'm going on holiday next week and will address feedback and pursue a store sync after that.

For those that want to test:
$ bzr branch lp:~jdstrand/click-reviewers-tools/click-reviewers-tools.snappy1604 review-tools
$ cd ./review-tools
$ PYTHONPATH=./ ./bin/click-review -v /path/to/app

To post a comment you must log in.
576. By Jamie Strandboge

merge r551 from trunk: lp:~jamestait/click-reviewers-tools/add-askubuntu-links

577. By Jamie Strandboge

merge r552 from trunk: add changelog entry

578. By Jamie Strandboge

merge r553 from trunk: Allow "accounts" hook since the 15.04.1 framework

579. By Jamie Strandboge

Merge from trunk: Forbid the internal "DebugMode" scope.ini key from making its
way into the store (LP: #1511063)

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

Ok, this has not received reviews but is well tested. It is important that this land sooner rather than later so committing. Please ping me if there are any issues and I'll sort them out immediately.

review: Approve
580. By Jamie Strandboge

clickreviews/tests/test_cr_scope.py: update for last commit

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'check-names.list'
--- check-names.list 2015-12-01 14:44:03 +0000
+++ check-names.list 2015-12-01 15:03:49 +0000
@@ -44,9 +44,9 @@
44framework:policy_metadata|44framework:policy_metadata|
45framework:policy_unknown|45framework:policy_unknown|
46framework:policy_valid_name|46framework:policy_valid_name|
47lint:architecture_specified_needed|
47lint:click_local_extensions|48lint:click_local_extensions|
48lint:control_architecture_match|49lint:control_architecture_match|
49lint:control_architecture_specified_needed|
50lint:control_architecture_valid|50lint:control_architecture_valid|
51lint:control_architecture_valid_contents|51lint:control_architecture_valid_contents|
52lint:control_click_version_up_to_date|http://askubuntu.com/questions/417366/what-does-lint-control-click-version-up-to-date-mean/41736752lint:control_click_version_up_to_date|http://askubuntu.com/questions/417366/what-does-lint-control-click-version-up-to-date-mean/417367
@@ -77,10 +77,6 @@
77lint:manifest_icon_absolute_path|77lint:manifest_icon_absolute_path|
78lint:manifest_icon_empty|78lint:manifest_icon_empty|
79lint:manifest_icon_present|79lint:manifest_icon_present|
80lint:package_filename_arch_match|
81lint:package_filename_arch_valid|http://askubuntu.com/questions/685103/what-does-lint-package-filename-arch-valid-mean/685104
82lint:package_filename_format|http://askubuntu.com/questions/685049/what-does-lint-package-filename-format-mean/685050
83lint:package_filename_version_match|http://askubuntu.com/questions/417384/what-does-lint-package-filename-version-match-mean/417385
84lint:package yaml_architecture_valid|80lint:package yaml_architecture_valid|
85lint:package_yaml_icon_absolute_path|81lint:package_yaml_icon_absolute_path|
86lint:package_yaml_icon_empty|82lint:package_yaml_icon_empty|
@@ -153,7 +149,6 @@
153security:template_account_provider|149security:template_account_provider|
154security:template_account_qml_plugin|150security:template_account_qml_plugin|
155security:template_exists|151security:template_exists|
156security:template_push_helper|
157security:template_valid|http://askubuntu.com/q/671403152security:template_valid|http://askubuntu.com/q/671403
158security:template_with_policy_version|153security:template_with_policy_version|
159security:yaml_and_click|154security:yaml_and_click|
@@ -163,6 +158,7 @@
163security:yaml_combinations|158security:yaml_combinations|
164security:yaml_override_click|159security:yaml_override_click|
165security:yaml_override_format|160security:yaml_override_format|
161security:yaml_override_present|https://developer.ubuntu.com/en/snappy/guides/security-policy/
166security:yaml_policy_format|162security:yaml_policy_format|
167security:yaml_policy_present|https://developer.ubuntu.com/en/snappy/guides/security-policy/163security:yaml_policy_present|https://developer.ubuntu.com/en/snappy/guides/security-policy/
168security:yaml_security-template|164security:yaml_security-template|
169165
=== modified file 'clickreviews/cr_common.py'
--- clickreviews/cr_common.py 2015-11-11 16:05:23 +0000
+++ clickreviews/cr_common.py 2015-12-01 15:03:49 +0000
@@ -96,9 +96,13 @@
96 "binaries",96 "binaries",
97 "caps",97 "caps",
98 "config",98 "config",
99 "firmware",
99 "frameworks",100 "frameworks",
100 "icon",101 "icon",
101 "immutable-config",102 "immutable-config",
103 "initrd",
104 "kernel",
105 "modules",
102 "oem",106 "oem",
103 "services",107 "services",
104 "source",108 "source",
@@ -112,11 +116,11 @@
112116
113 def __init__(self, fn, review_type, peer_hooks=None, overrides=None,117 def __init__(self, fn, review_type, peer_hooks=None, overrides=None,
114 peer_hooks_link=None):118 peer_hooks_link=None):
115 self.click_package = fn119 self.pkg_filename = fn
116 self._check_path_exists()120 self._check_path_exists()
117 if not self.click_package.endswith(".click") and \121 if not self.pkg_filename.endswith(".click") and \
118 not self.click_package.endswith(".snap"):122 not self.pkg_filename.endswith(".snap"):
119 if self.click_package.endswith(".deb"):123 if self.pkg_filename.endswith(".deb"):
120 error("filename does not end with '.click', but '.deb' "124 error("filename does not end with '.click', but '.deb' "
121 "instead. See http://askubuntu.com/a/485544/94326 for "125 "instead. See http://askubuntu.com/a/485544/94326 for "
122 "how click packages are different.")126 "how click packages are different.")
@@ -141,28 +145,29 @@
141 RAW_UNPACK_DIR = raw_unpack_pkg(fn)145 RAW_UNPACK_DIR = raw_unpack_pkg(fn)
142 self.raw_unpack_dir = RAW_UNPACK_DIR146 self.raw_unpack_dir = RAW_UNPACK_DIR
143147
144 # Get some basic information from the control file148 self.pkgfmt = {"type": "", "version": ""}
145 control_file = self._extract_control_file()149 self.manifest = None
146 tmp = list(Deb822.iter_paragraphs(control_file))150 self.click_pkgname = None
147 if len(tmp) != 1:151 self.click_version = None
148 error("malformed control file: too many paragraphs")152 self.pkg_arch = []
149 control = tmp[0]153
150 self.click_pkgname = control['Package']154 # Parse and store the package.yaml, if it exists
151 self.click_version = control['Version']
152 self.click_arch = control['Architecture']
153
154 # Parse and store the manifest
155 manifest_json = self._extract_manifest_file()
156 try:
157 self.manifest = json.load(manifest_json)
158 except Exception:
159 error("Could not load manifest file. Is it properly formatted?")
160 self._verify_manifest_structure()
161
162 # Parse and store the package.yaml
163 pkg_yaml = self._extract_package_yaml()155 pkg_yaml = self._extract_package_yaml()
164 self.is_snap = False156 self.is_snap = False
165 if pkg_yaml is not None:157 if pkg_yaml is None:
158 self.pkgfmt["type"] = "click"
159 else:
160 self.pkgfmt["type"] = "snap"
161 # Some day we will be able to introspect the version, but not
162 # today.... For now, decide on if it is a squashfs and if so,
163 # assume it is 16.04
164 if is_squashfs(fn):
165 self.pkgfmt["version"] = "16.04"
166 self.peer_hooks = None
167 self.peer_hooks_link = None
168 else:
169 self.pkgfmt["version"] = "15.04"
170
166 try:171 try:
167 self.pkg_yaml = yaml.safe_load(pkg_yaml)172 self.pkg_yaml = yaml.safe_load(pkg_yaml)
168 except Exception:173 except Exception:
@@ -174,6 +179,45 @@
174 if 'type' not in self.pkg_yaml:179 if 'type' not in self.pkg_yaml:
175 self.pkg_yaml['type'] = 'app'180 self.pkg_yaml['type'] = 'app'
176181
182 if 'architectures' in self.pkg_yaml:
183 self.pkg_arch = self.pkg_yaml['architectures']
184 elif 'architecture' in self.pkg_yaml:
185 if isinstance(self.pkg_yaml['architecture'], str):
186 self.pkg_arch = [self.pkg_yaml['architecture']]
187 elif isinstance(self.pkg_yaml['architecture'], list):
188 self.pkg_arch = self.pkg_yaml['architecture']
189 else:
190 error("Could not load package.yaml: invalid 'architecture'")
191 else:
192 self.pkg_arch = ['all']
193
194 if self._pkgfmt_type() == "click" or self._pkgfmt_version() == "15.04":
195 # Get some basic information from the control file
196 control_file = self._extract_control_file()
197 tmp = list(Deb822.iter_paragraphs(control_file))
198 if len(tmp) != 1:
199 error("malformed control file: too many paragraphs")
200 control = tmp[0]
201 self.click_pkgname = control['Package']
202 self.click_version = control['Version']
203 if self._pkgfmt_type() == "click":
204 if control['Architecture'] not in self.pkg_arch:
205 self.pkg_arch.append(control['Architecture'])
206 self.pkgfmt["version"] = str(control['Click-Version'])
207
208 # Parse and store the manifest
209 manifest_json = self._extract_manifest_file()
210 try:
211 self.manifest = json.load(manifest_json)
212 except Exception:
213 error("Could not load manifest file. Is it properly formatted?")
214 self._verify_manifest_structure()
215
216 self.valid_frameworks = self._extract_click_frameworks()
217
218 self.peer_hooks = peer_hooks
219 self.peer_hooks_link = peer_hooks_link
220
177 self.is_snap_oem = False221 self.is_snap_oem = False
178 if self.is_snap and 'type' in self.pkg_yaml and \222 if self.is_snap and 'type' in self.pkg_yaml and \
179 self.pkg_yaml['type'] == 'oem':223 self.pkg_yaml['type'] == 'oem':
@@ -191,11 +235,7 @@
191 # it now235 # it now
192 # self._list_all_compiled_binaries()236 # self._list_all_compiled_binaries()
193237
194 self.valid_frameworks = self._extract_click_frameworks()
195
196 self.peer_hooks = peer_hooks
197 self.overrides = overrides if overrides is not None else {}238 self.overrides = overrides if overrides is not None else {}
198 self.peer_hooks_link = peer_hooks_link
199239
200 def _extract_click_frameworks(self):240 def _extract_click_frameworks(self):
201 '''Extract installed click frameworks'''241 '''Extract installed click frameworks'''
@@ -248,10 +288,22 @@
248 return None288 return None
249 return out.split()[0]289 return out.split()[0]
250290
291 def _pkgfmt_type(self):
292 '''Return the package format type'''
293 if "type" not in self.pkgfmt:
294 return ""
295 return self.pkgfmt["type"]
296
297 def _pkgfmt_version(self):
298 '''Return the package format version'''
299 if "version" not in self.pkgfmt:
300 return ""
301 return self.pkgfmt["version"]
302
251 def _check_path_exists(self):303 def _check_path_exists(self):
252 '''Check that the provided path exists'''304 '''Check that the provided path exists'''
253 if not os.path.exists(self.click_package):305 if not os.path.exists(self.pkg_filename):
254 error("Could not find '%s'" % self.click_package)306 error("Could not find '%s'" % self.pkg_filename)
255307
256 def _extract_control_file(self):308 def _extract_control_file(self):
257 '''Extract '''309 '''Extract '''
258310
=== modified file 'clickreviews/cr_content_hub.py'
--- clickreviews/cr_content_hub.py 2015-08-13 21:07:13 +0000
+++ clickreviews/cr_content_hub.py 2015-12-01 15:03:49 +0000
@@ -37,6 +37,10 @@
3737
38 self.content_hub_files = dict() # click-show-files and tests38 self.content_hub_files = dict() # click-show-files and tests
39 self.content_hub = dict()39 self.content_hub = dict()
40
41 if self.manifest is None:
42 return
43
40 for app in self.manifest['hooks']:44 for app in self.manifest['hooks']:
41 if 'content-hub' not in self.manifest['hooks'][app]:45 if 'content-hub' not in self.manifest['hooks'][app]:
42 # msg("Skipped missing content-hub hook for '%s'" % app)46 # msg("Skipped missing content-hub hook for '%s'" % app)
4347
=== modified file 'clickreviews/cr_desktop.py'
--- clickreviews/cr_desktop.py 2015-08-18 16:04:05 +0000
+++ clickreviews/cr_desktop.py 2015-12-01 15:03:49 +0000
@@ -41,6 +41,10 @@
41 self.desktop_files = dict() # click-show-files and a couple tests41 self.desktop_files = dict() # click-show-files and a couple tests
42 self.desktop_entries = dict()42 self.desktop_entries = dict()
43 self.desktop_hook_entries = 043 self.desktop_hook_entries = 0
44
45 if self.manifest is None:
46 return
47
44 for app in self.manifest['hooks']:48 for app in self.manifest['hooks']:
45 if 'desktop' not in self.manifest['hooks'][app]:49 if 'desktop' not in self.manifest['hooks'][app]:
46 # msg("Skipped missing desktop hook for '%s'" % app)50 # msg("Skipped missing desktop hook for '%s'" % app)
@@ -196,24 +200,27 @@
196 de.getExec()200 de.getExec()
197 l = 'http://askubuntu.com/questions/417381/what-does-desktop-exec-mean/417382'201 l = 'http://askubuntu.com/questions/417381/what-does-desktop-exec-mean/417382'
198 elif de.getExec().split()[0] not in self.expected_execs:202 elif de.getExec().split()[0] not in self.expected_execs:
199 if self.click_arch == "all": # interpreted file203 if self.pkg_arch[0] == "all": # interpreted file
200 if de.getExec().split()[0] not in self.deprecated_execs:204 if de.getExec().split()[0] not in self.deprecated_execs:
201 s = "found unexpected Exec with architecture '%s': %s" % \205 s = "found unexpected Exec with architecture '%s': %s" % \
202 (self.click_arch, de.getExec().split()[0])206 (self.pkg_arch[0], de.getExec().split()[0])
203 else:207 else:
204 s = "found deprecated Exec with architecture '%s': %s" % \208 s = "found deprecated Exec with architecture '%s': %s" % \
205 (self.click_arch, de.getExec().split()[0])209 (self.pkg_arch[0], de.getExec().split()[0])
206 t = 'warn'210 t = 'warn'
207 else: # compiled211 else: # compiled
208 # TODO: this can be a lot smarter212 # TODO: this can be a lot smarter
209 s = "Non-standard Exec with architecture " + \213 s = "Non-standard Exec with architecture " + \
210 "'%s': %s (ok for compiled code)" % \214 "'%s': %s (ok for compiled code)" % \
211 (self.click_arch, de.getExec().split()[0])215 (self.pkg_arch[0], de.getExec().split()[0])
212 t = 'info'216 t = 'info'
213 self._add_result(t, n, s, l)217 self._add_result(t, n, s, l)
214218
215 def check_desktop_exec_webapp_container(self):219 def check_desktop_exec_webapp_container(self):
216 '''Check Exec=webapp-container entry'''220 '''Check Exec=webapp-container entry'''
221 if self.manifest is None:
222 return
223
217 fwk = self.manifest['framework']224 fwk = self.manifest['framework']
218225
219 for app in sorted(self.desktop_entries):226 for app in sorted(self.desktop_entries):
220227
=== modified file 'clickreviews/cr_framework.py'
--- clickreviews/cr_framework.py 2015-08-20 20:52:17 +0000
+++ clickreviews/cr_framework.py 2015-12-01 15:03:49 +0000
@@ -23,22 +23,24 @@
2323
2424
25class ClickReviewFramework(ClickReview):25class ClickReviewFramework(ClickReview):
26 '''This class represents click lint reviews'''26 '''This class represents click framework reviews'''
27 def __init__(self, fn, overrides=None):27 def __init__(self, fn, overrides=None):
28 ClickReview.__init__(self, fn, "framework", overrides=overrides)28 ClickReview.__init__(self, fn, "framework", overrides=overrides)
2929
30 self.frameworks_file = dict()30 self.frameworks_file = dict()
31 self.frameworks = dict()31 self.frameworks = dict()
32 for app in self.manifest['hooks']:32
33 if 'framework' not in self.manifest['hooks'][app]:33 if self.manifest is not None:
34 # msg("Skipped missing framework hook for '%s'" % app)34 for app in self.manifest['hooks']:
35 continue35 if 'framework' not in self.manifest['hooks'][app]:
36 if not isinstance(self.manifest['hooks'][app]['framework'], str):36 # msg("Skipped missing framework hook for '%s'" % app)
37 error("manifest malformed: hooks/%s/framework is not str" %37 continue
38 app)38 if not isinstance(self.manifest['hooks'][app]['framework'], str):
39 (full_fn, data) = self._extract_framework(app)39 error("manifest malformed: hooks/%s/framework is not str" %
40 self.frameworks_file[app] = full_fn40 app)
41 self.frameworks[app] = data41 (full_fn, data) = self._extract_framework(app)
42 self.frameworks_file[app] = full_fn
43 self.frameworks[app] = data
4244
43 self.framework_policy_dirs = ['apparmor', 'seccomp']45 self.framework_policy_dirs = ['apparmor', 'seccomp']
44 self.framework_policy_subdirs = ['templates', 'policygroups']46 self.framework_policy_subdirs = ['templates', 'policygroups']
4547
=== modified file 'clickreviews/cr_functional.py'
--- clickreviews/cr_functional.py 2015-08-13 21:07:13 +0000
+++ clickreviews/cr_functional.py 2015-12-01 15:03:49 +0000
@@ -39,6 +39,9 @@
3939
40 def check_applicationName(self):40 def check_applicationName(self):
41 '''Check applicationName matches click manifest'''41 '''Check applicationName matches click manifest'''
42 if self.manifest is None:
43 return
44
42 t = 'info'45 t = 'info'
43 n = self._get_check_name('qml_applicationName_matches_manifest')46 n = self._get_check_name('qml_applicationName_matches_manifest')
44 s = "OK"47 s = "OK"
@@ -100,18 +103,13 @@
100103
101 if len(appnames) == 0:104 if len(appnames) == 0:
102 s = "could not find applicationName in: %s" % \105 s = "could not find applicationName in: %s" % \
103 ", ".join(list(map(106 ", ".join(sorted(list(map(
104 lambda x: os.path.relpath(x,107 lambda x: os.path.relpath(x, self.unpack_dir), qmls))))
105 self.unpack_dir),
106 qmls)
107 ))
108 else: # not ok108 else: # not ok
109 s = "click manifest name '%s' not found in: " % \109 s = "click manifest name '%s' not found in: " % \
110 self.click_pkgname + "%s" % \110 self.click_pkgname + "%s" % \
111 ", ".join(list(map(111 ", ".join(sorted(list(map(
112 lambda x: "%s ('%s')" % (x, appnames[x]),112 lambda x: "%s ('%s')" % (x, appnames[x]), appnames))))
113 appnames)
114 ))
115113
116 if len(self.pkg_bin_files) == 0:114 if len(self.pkg_bin_files) == 0:
117 s += ". Application may not work properly when confined."115 s += ". Application may not work properly when confined."
@@ -148,7 +146,8 @@
148 s = "OK"146 s = "OK"
149 l = None147 l = None
150148
151 if self.manifest['framework'] == "ubuntu-sdk-13.10":149 if self.manifest is not None and \
150 self.manifest['framework'] == "ubuntu-sdk-13.10":
152 s = "SKIPPED (Oxide not available in ubuntu-sdk-13.10)"151 s = "SKIPPED (Oxide not available in ubuntu-sdk-13.10)"
153 else:152 else:
154 qmls = []153 qmls = []
155154
=== modified file 'clickreviews/cr_lint.py'
--- clickreviews/cr_lint.py 2015-11-24 12:13:36 +0000
+++ clickreviews/cr_lint.py 2015-12-01 15:03:49 +0000
@@ -76,7 +76,7 @@
76 'RCS*'76 'RCS*'
77 ]77 ]
7878
79 if 'maintainer' in self.manifest:79 if self.manifest is not None and 'maintainer' in self.manifest:
80 maintainer = self.manifest['maintainer']80 maintainer = self.manifest['maintainer']
81 self.email = maintainer.partition('<')[2].rstrip('>')81 self.email = maintainer.partition('<')[2].rstrip('>')
82 self.is_core_app = \82 self.is_core_app = \
@@ -125,13 +125,19 @@
125 # Valid values for 'type' in packaging yaml125 # Valid values for 'type' in packaging yaml
126 # - app126 # - app
127 # - framework127 # - framework
128 # - kernel
128 # - oem129 # - oem
130 # - os
129 self.snappy_valid_types = ['app',131 self.snappy_valid_types = ['app',
130 'framework',132 'framework',
133 'kernel',
131 'oem',134 'oem',
135 'os',
132 ]136 ]
133 self.snappy_redflagged_types = ['framework',137 self.snappy_redflagged_types = ['framework',
134 'oem', # TBD138 'kernel',
139 'oem',
140 'os',
135 ]141 ]
136142
137 def _list_control_files(self):143 def _list_control_files(self):
@@ -142,6 +148,10 @@
142148
143 def check_control_files(self):149 def check_control_files(self):
144 '''Check DEBIAN/* files'''150 '''Check DEBIAN/* files'''
151 if self._pkgfmt_type() == "snap" and \
152 float(self._pkgfmt_version()) > 15.04:
153 return
154
145 for f in self.control_files:155 for f in self.control_files:
146 t = 'info'156 t = 'info'
147 n = self._get_check_name(157 n = self._get_check_name(
@@ -169,6 +179,10 @@
169179
170 def check_control(self):180 def check_control(self):
171 '''Check control()'''181 '''Check control()'''
182 if self._pkgfmt_type() == "snap" and \
183 float(self._pkgfmt_version()) > 15.04:
184 return
185
172 fh = self._extract_control_file()186 fh = self._extract_control_file()
173 tmp = list(Deb822.iter_paragraphs(fh))187 tmp = list(Deb822.iter_paragraphs(fh))
174 t = 'info'188 t = 'info'
@@ -340,6 +354,10 @@
340354
341 def check_preinst(self):355 def check_preinst(self):
342 '''Check preinst()'''356 '''Check preinst()'''
357 if self._pkgfmt_type() == "snap" and \
358 float(self._pkgfmt_version()) > 15.04:
359 return
360
343 expected = '''#! /bin/sh361 expected = '''#! /bin/sh
344echo "Click packages may not be installed directly using dpkg."362echo "Click packages may not be installed directly using dpkg."
345echo "Use 'click install' instead."363echo "Use 'click install' instead."
@@ -361,6 +379,10 @@
361379
362 def check_hooks(self):380 def check_hooks(self):
363 '''Check click manifest hooks'''381 '''Check click manifest hooks'''
382 if self._pkgfmt_type() == "snap" and \
383 float(self._pkgfmt_version()) > 15.04:
384 return
385
364 # oem snaps don't have a hooks entry386 # oem snaps don't have a hooks entry
365 if self.is_snap_oem:387 if self.is_snap_oem:
366 return388 return
@@ -457,6 +479,10 @@
457479
458 def check_hooks_unknown(self):480 def check_hooks_unknown(self):
459 '''Check if have any unknown hooks'''481 '''Check if have any unknown hooks'''
482 if self._pkgfmt_type() == "snap" and \
483 float(self._pkgfmt_version()) > 15.04:
484 return
485
460 # oem snaps don't have a hooks entry486 # oem snaps don't have a hooks entry
461 if self.is_snap_oem:487 if self.is_snap_oem:
462 return488 return
@@ -478,6 +504,10 @@
478504
479 def check_hooks_redflagged(self):505 def check_hooks_redflagged(self):
480 '''Check if have any redflagged hooks'''506 '''Check if have any redflagged hooks'''
507 if self._pkgfmt_type() == "snap" and \
508 float(self._pkgfmt_version()) > 15.04:
509 return
510
481 t = 'info'511 t = 'info'
482 n = self._get_check_name('redflagged_hooks')512 n = self._get_check_name('redflagged_hooks')
483 s = 'OK'513 s = 'OK'
@@ -502,6 +532,9 @@
502532
503 def check_external_symlinks(self):533 def check_external_symlinks(self):
504 '''Check if symlinks in the click package go out to the system.'''534 '''Check if symlinks in the click package go out to the system.'''
535 if self.is_snap and self.pkg_yaml['type'] not in ['app', 'framework']:
536 return
537
505 t = 'info'538 t = 'info'
506 n = self._get_check_name('external_symlinks')539 n = self._get_check_name('external_symlinks')
507 s = 'OK'540 s = 'OK'
@@ -571,7 +604,11 @@
571 self._add_result(t, n, s)604 self._add_result(t, n, s)
572605
573 def check_version(self):606 def check_version(self):
574 '''Check package version is valid'''607 '''Check click package version is valid'''
608 if self._pkgfmt_type() == "snap" and \
609 float(self._pkgfmt_version()) > 15.04:
610 return
611
575 # deb-version(5)612 # deb-version(5)
576 t = 'info'613 t = 'info'
577 n = self._get_check_name('version_valid')614 n = self._get_check_name('version_valid')
@@ -586,13 +623,17 @@
586 self._add_result(t, n, s)623 self._add_result(t, n, s)
587624
588 def check_architecture(self):625 def check_architecture(self):
589 '''Check package architecture in DEBIAN/control is valid'''626 '''Check click package architecture in DEBIAN/control is valid'''
627 if self._pkgfmt_type() == "snap" and \
628 float(self._pkgfmt_version()) > 15.04:
629 return
630
590 t = 'info'631 t = 'info'
591 n = self._get_check_name('control_architecture_valid')632 n = self._get_check_name('control_architecture_valid')
592 s = 'OK'633 s = 'OK'
593 if self.click_arch not in self.valid_control_architectures:634 if self.pkg_arch[0] not in self.valid_control_architectures:
594 t = 'error'635 t = 'error'
595 s = "not a valid architecture: %s" % self.click_arch636 s = "not a valid architecture: %s" % self.pkg_arch[0]
596 self._add_result(t, n, s)637 self._add_result(t, n, s)
597638
598 def check_architecture_all(self):639 def check_architecture_all(self):
@@ -600,7 +641,7 @@
600 t = 'info'641 t = 'info'
601 n = self._get_check_name('control_architecture_valid_contents')642 n = self._get_check_name('control_architecture_valid_contents')
602 s = 'OK'643 s = 'OK'
603 if self.click_arch != "all":644 if self.pkg_arch[0] != "all":
604 self._add_result(t, n, s)645 self._add_result(t, n, s)
605 return646 return
606647
@@ -616,22 +657,27 @@
616657
617 def check_architecture_specified_needed(self):658 def check_architecture_specified_needed(self):
618 '''Check if the specified architecture is actually needed'''659 '''Check if the specified architecture is actually needed'''
619 t = 'info'660 for arch in self.pkg_arch:
620 n = self._get_check_name('control_architecture_specified_needed')661 t = 'info'
621 s = 'OK'662 n = self._get_check_name('architecture_specified_needed')
622 if self.click_arch == "all":663 s = 'OK'
623 s = "SKIPPED: architecture is 'all'"664 if arch == "all":
665 s = "SKIPPED: architecture is 'all'"
666 self._add_result(t, n, s)
667 return
668
669 if len(self.pkg_bin_files) == 0:
670 t = 'warn'
671 s = "Could not find compiled binaries for architecture '%s'" % \
672 arch
624 self._add_result(t, n, s)673 self._add_result(t, n, s)
625 return
626
627 if len(self.pkg_bin_files) == 0:
628 t = 'warn'
629 s = "Could not find compiled binaries for architecture '%s'" % \
630 self.click_arch
631 self._add_result(t, n, s)
632674
633 def check_maintainer(self):675 def check_maintainer(self):
634 '''Check maintainer()'''676 '''Check manifest maintainer()'''
677 if self._pkgfmt_type() == "snap" and \
678 float(self._pkgfmt_version()) > 15.04:
679 return
680
635 t = 'info'681 t = 'info'
636 n = self._get_check_name('maintainer_present')682 n = self._get_check_name('maintainer_present')
637 s = 'OK'683 s = 'OK'
@@ -671,7 +717,11 @@
671 self._add_result(t, n, s)717 self._add_result(t, n, s)
672718
673 def check_title(self):719 def check_title(self):
674 '''Check title()'''720 '''Check manifest title()'''
721 if self._pkgfmt_type() == "snap" and \
722 float(self._pkgfmt_version()) > 15.04:
723 return
724
675 t = 'info'725 t = 'info'
676 n = self._get_check_name('title_present')726 n = self._get_check_name('title_present')
677 s = 'OK'727 s = 'OK'
@@ -691,7 +741,11 @@
691 self._add_result(t, n, s)741 self._add_result(t, n, s)
692742
693 def check_description(self):743 def check_description(self):
694 '''Check description()'''744 '''Check manifest description()'''
745 if self._pkgfmt_type() == "snap" and \
746 float(self._pkgfmt_version()) > 15.04:
747 return
748
695 t = 'info'749 t = 'info'
696 n = self._get_check_name('description_present')750 n = self._get_check_name('description_present')
697 s = 'OK'751 s = 'OK'
@@ -717,7 +771,11 @@
717 self._add_result(t, n, s)771 self._add_result(t, n, s)
718772
719 def check_framework(self):773 def check_framework(self):
720 '''Check framework()'''774 '''Check manifest framework()'''
775 if self._pkgfmt_type() == "snap" and \
776 float(self._pkgfmt_version()) > 15.04:
777 return
778
721 n = self._get_check_name('framework')779 n = self._get_check_name('framework')
722 l = "http://askubuntu.com/questions/460512/what-framework-should-i-use-in-my-manifest-file"780 l = "http://askubuntu.com/questions/460512/what-framework-should-i-use-in-my-manifest-file"
723 framework_overrides = self.overrides.get('framework', {})781 framework_overrides = self.overrides.get('framework', {})
@@ -759,6 +817,10 @@
759817
760 def check_click_local_extensions(self):818 def check_click_local_extensions(self):
761 '''Report any click local extensions'''819 '''Report any click local extensions'''
820 if self._pkgfmt_type() == "snap" and \
821 float(self._pkgfmt_version()) > 15.04:
822 return
823
762 t = 'info'824 t = 'info'
763 n = self._get_check_name('click_local_extensions')825 n = self._get_check_name('click_local_extensions')
764 s = 'OK'826 s = 'OK'
@@ -781,90 +843,8 @@
781 s = 'found unofficial extension%s: %s' % (plural, ', '.join(found))843 s = 'found unofficial extension%s: %s' % (plural, ', '.join(found))
782 self._add_result(t, n, s)844 self._add_result(t, n, s)
783845
784 def check_package_filename(self):
785 '''Check filename of package'''
786 tmp = os.path.basename(self.click_package).split('_')
787 click_package_bn = os.path.basename(self.click_package)
788 t = 'info'
789 n = self._get_check_name('package_filename_format')
790 s = 'OK'
791 l = 'http://askubuntu.com/questions/685049/what-does-lint-package-filename-format-mean/685050'
792 if len(tmp) != 3:
793 t = 'warn'
794 s = "'%s' not of form $pkgname_$version_$arch.[click|snap]" % \
795 click_package_bn
796 self._add_result(t, n, s, l)
797
798 t = 'info'
799 n = self._get_check_name('package_filename_version_match')
800 s = 'OK'
801 l = None
802 if len(tmp) >= 2:
803 # handle $pkgname_$version.click or $pkgname_$version.snap
804 if self.click_package.endswith('.snap'):
805 version = tmp[1].partition('.snap')[0]
806 else:
807 version = tmp[1].partition('.click')[0]
808 if version != self.click_version:
809 t = 'error'
810 s = "'%s' != '%s' from DEBIAN/control" % (version,
811 self.click_version)
812 l = 'http://askubuntu.com/questions/417384/what-does-lint-package-filename-version-match-mean/417385'
813 else:
814 t = 'warn'
815 s = "could not determine version from '%s'" % \
816 os.path.basename(self.click_package)
817 self._add_result(t, n, s, l)
818
819 t = 'info'
820 n = self._get_check_name('package_filename_arch_valid')
821 s = 'OK'
822 l = 'http://askubuntu.com/questions/685103/what-does-lint-package-filename-arch-valid-mean/685104'
823 if len(tmp) >= 3:
824 if self.click_package.endswith('.snap'):
825 arch = tmp[2].partition('.snap')[0]
826 else:
827 arch = tmp[2].partition('.click')[0]
828 if arch == "unknown":
829 # short-circuit here since the appstore doesn't determine
830 # the version yet
831 t = 'info'
832 s = "SKIP: architecture 'unknown'"
833 self._add_result(t, n, s)
834 return
835 if arch not in self.valid_control_architectures:
836 t = 'warn'
837 s = "not a valid architecture: %s" % arch
838 else:
839 t = 'warn'
840 s = "could not determine architecture from '%s'" % \
841 os.path.basename(self.click_package)
842 self._add_result(t, n, s, l)
843
844 t = 'info'
845 n = self._get_check_name('package_filename_arch_match')
846 s = 'OK'
847 if len(tmp) >= 3:
848 if self.click_package.endswith('.snap'):
849 arch = tmp[2].partition('.snap')[0]
850 else:
851 arch = tmp[2].partition('.click')[0]
852 if arch != self.click_arch:
853 if arch == 'all' and self.click_arch == 'multi':
854 # The store creates filenames for fat packages with _all
855 pass
856 else:
857 t = 'error'
858 s = "'%s' != '%s' from DEBIAN/control" % (arch,
859 self.click_arch)
860 else:
861 t = 'warn'
862 s = "could not determine architecture from '%s'" % \
863 os.path.basename(self.click_package)
864 self._add_result(t, n, s)
865
866 def check_vcs(self):846 def check_vcs(self):
867 '''Check for VCS files in the click package'''847 '''Check for VCS files in the package'''
868 t = 'info'848 t = 'info'
869 n = self._get_check_name('vcs_files')849 n = self._get_check_name('vcs_files')
870 s = 'OK'850 s = 'OK'
@@ -881,6 +861,9 @@
881861
882 def check_click_in_package(self):862 def check_click_in_package(self):
883 '''Check for *.click files in the toplevel click package'''863 '''Check for *.click files in the toplevel click package'''
864 if self._pkgfmt_type() == "snap":
865 return
866
884 t = 'info'867 t = 'info'
885 n = self._get_check_name('click_files')868 n = self._get_check_name('click_files')
886 s = 'OK'869 s = 'OK'
@@ -896,6 +879,10 @@
896879
897 def check_dot_click(self):880 def check_dot_click(self):
898 '''Check for .click directory in the toplevel click package'''881 '''Check for .click directory in the toplevel click package'''
882 if self._pkgfmt_type() == "snap" and \
883 float(self._pkgfmt_version()) > 15.04:
884 return
885
899 t = 'info'886 t = 'info'
900 n = self._get_check_name('dot_click')887 n = self._get_check_name('dot_click')
901 s = 'OK'888 s = 'OK'
@@ -971,6 +958,10 @@
971958
972 def check_manifest_architecture(self):959 def check_manifest_architecture(self):
973 '''Check package architecture in manifest is valid'''960 '''Check package architecture in manifest is valid'''
961 if self._pkgfmt_type() == "snap" and \
962 float(self._pkgfmt_version()) > 15.04:
963 return
964
974 self._verify_architecture(self.manifest, "manifest")965 self._verify_architecture(self.manifest, "manifest")
975966
976 def _verify_icon(self, my_dict, test_str):967 def _verify_icon(self, my_dict, test_str):
@@ -1003,6 +994,10 @@
1003994
1004 def check_icon(self):995 def check_icon(self):
1005 '''Check icon()'''996 '''Check icon()'''
997 if self._pkgfmt_type() == "snap" and \
998 float(self._pkgfmt_version()) > 15.04:
999 return
1000
1006 self._verify_icon(self.manifest, "manifest")1001 self._verify_icon(self.manifest, "manifest")
10071002
1008 def check_snappy_name(self):1003 def check_snappy_name(self):
@@ -1111,7 +1106,8 @@
1111 unknown.append(f)1106 unknown.append(f)
1112 if len(unknown) > 0:1107 if len(unknown) > 0:
1113 t = 'warn'1108 t = 'warn'
1114 s = "unknown entries in package.yaml: '%s'" % (",".join(unknown))1109 s = "unknown entries in package.yaml: '%s'" % \
1110 (",".join(sorted(unknown)))
1115 obsoleted = ['maintainer', 'ports']1111 obsoleted = ['maintainer', 'ports']
1116 tmp = list(set(unknown) & set(obsoleted))1112 tmp = list(set(unknown) & set(obsoleted))
1117 if len(tmp) > 0:1113 if len(tmp) > 0:
@@ -1210,7 +1206,7 @@
12101206
1211 def check_is_squashfs(self):1207 def check_is_squashfs(self):
1212 '''Check snapfs'''1208 '''Check snapfs'''
1213 if is_squashfs(self.click_package):1209 if is_squashfs(self.pkg_filename):
1214 t = 'error'1210 t = 'error'
1215 n = self._get_check_name('is_squashfs')1211 n = self._get_check_name('is_squashfs')
1216 s = "(MANUAL REVIEW) squashfs pkg"1212 s = "(MANUAL REVIEW) squashfs pkg"
@@ -1219,10 +1215,14 @@
12191215
1220 def check_snappy_hashes(self):1216 def check_snappy_hashes(self):
1221 '''Check snappy hashes.yaml'''1217 '''Check snappy hashes.yaml'''
1218 if self._pkgfmt_type() == "snap" and \
1219 float(self._pkgfmt_version()) > 15.04:
1220 return
1221
1222 if not self.is_snap:1222 if not self.is_snap:
1223 return1223 return
1224 # no hashes.yaml for squashfs images1224 # no hashes.yaml for squashfs images
1225 if is_squashfs(self.click_package):1225 if is_squashfs(self.pkg_filename):
1226 return1226 return
12271227
1228 def _check_allowed_perms(mode, allowed):1228 def _check_allowed_perms(mode, allowed):
@@ -1387,3 +1387,7 @@
1387 s = 'found extra files not listed in hashes.yaml: %s' % \1387 s = 'found extra files not listed in hashes.yaml: %s' % \
1388 ", ".join(extra)1388 ", ".join(extra)
1389 self._add_result(t, n, s)1389 self._add_result(t, n, s)
1390
1391 def check_snappy_frameworks(self):
1392 '''TODO'''
1393 return False
13901394
=== modified file 'clickreviews/cr_online_accounts.py'
--- clickreviews/cr_online_accounts.py 2015-11-27 09:04:43 +0000
+++ clickreviews/cr_online_accounts.py 2015-12-01 15:03:49 +0000
@@ -78,6 +78,10 @@
78 'account-provider',78 'account-provider',
79 'account-qml-plugin',79 'account-qml-plugin',
80 'account-service']80 'account-service']
81
82 if self.manifest is None:
83 return
84
81 for app in self.manifest['hooks']:85 for app in self.manifest['hooks']:
82 for h in self.account_hooks:86 for h in self.account_hooks:
83 if h not in self.manifest['hooks'][app]:87 if h not in self.manifest['hooks'][app]:
@@ -120,6 +124,9 @@
120124
121 def _extract_account(self, app, account_type):125 def _extract_account(self, app, account_type):
122 '''Extract accounts'''126 '''Extract accounts'''
127 if self.manifest is None:
128 return
129
123 a = self.manifest['hooks'][app][account_type]130 a = self.manifest['hooks'][app][account_type]
124 fn = os.path.join(self.unpack_dir, a)131 fn = os.path.join(self.unpack_dir, a)
125132
@@ -158,6 +165,9 @@
158165
159 def check_hooks_versions(self):166 def check_hooks_versions(self):
160 '''Check hooks versions'''167 '''Check hooks versions'''
168 if self.manifest is None:
169 return
170
161 framework = self.manifest['framework']171 framework = self.manifest['framework']
162 if not framework.startswith("ubuntu-sdk"):172 if not framework.startswith("ubuntu-sdk"):
163 return173 return
164174
=== modified file 'clickreviews/cr_push_helper.py'
--- clickreviews/cr_push_helper.py 2015-08-13 21:07:13 +0000
+++ clickreviews/cr_push_helper.py 2015-12-01 15:03:49 +0000
@@ -38,6 +38,10 @@
3838
39 self.push_helper_files = dict() # click-show-files and tests39 self.push_helper_files = dict() # click-show-files and tests
40 self.push_helper = dict()40 self.push_helper = dict()
41
42 if self.manifest is None:
43 return
44
41 for app in self.manifest['hooks']:45 for app in self.manifest['hooks']:
42 if 'push-helper' not in self.manifest['hooks'][app]:46 if 'push-helper' not in self.manifest['hooks'][app]:
43 # msg("Skipped missing push-helper hook for '%s'" % app)47 # msg("Skipped missing push-helper hook for '%s'" % app)
@@ -121,6 +125,9 @@
121125
122 def check_hooks(self):126 def check_hooks(self):
123 '''Verify combinations of click hooks with the push-helper hook'''127 '''Verify combinations of click hooks with the push-helper hook'''
128 if self.manifest is None:
129 return
130
124 for app in sorted(self.manifest['hooks']):131 for app in sorted(self.manifest['hooks']):
125 if app not in self.push_helper:132 if app not in self.push_helper:
126 continue133 continue
127134
=== modified file 'clickreviews/cr_scope.py'
--- clickreviews/cr_scope.py 2015-12-01 07:45:05 +0000
+++ clickreviews/cr_scope.py 2015-12-01 15:03:49 +0000
@@ -41,6 +41,10 @@
41 overrides=overrides)41 overrides=overrides)
4242
43 self.scopes = dict()43 self.scopes = dict()
44
45 if self.manifest is None:
46 return
47
44 for app in self.manifest['hooks']:48 for app in self.manifest['hooks']:
45 if 'scope' not in self.manifest['hooks'][app]:49 if 'scope' not in self.manifest['hooks'][app]:
46 # msg("Skipped missing scope hook for '%s'" % app)50 # msg("Skipped missing scope hook for '%s'" % app)
4751
=== modified file 'clickreviews/cr_security.py'
--- clickreviews/cr_security.py 2015-11-24 12:13:36 +0000
+++ clickreviews/cr_security.py 2015-12-01 15:03:49 +0000
@@ -131,36 +131,79 @@
131 framework_overrides = self.overrides.get('framework', {})131 framework_overrides = self.overrides.get('framework', {})
132 self._override_framework_policies(framework_overrides)132 self._override_framework_policies(framework_overrides)
133133
134 # snappy
135 self.sec_skipped_types = ['oem',
136 'os',
137 'kernel'] # these don't need security items
138
134 self.security_manifests = dict()139 self.security_manifests = dict()
135 self.security_apps = []140 self.security_apps = []
136 for app in self.manifest['hooks']:
137 if 'apparmor' not in self.manifest['hooks'][app]:
138 # msg("Skipped missing apparmor hook for '%s'" % app)
139 continue
140 if not isinstance(self.manifest['hooks'][app]['apparmor'], str):
141 error("manifest malformed: hooks/%s/apparmor is not str" % app)
142 rel_fn = self.manifest['hooks'][app]['apparmor']
143 self.security_manifests[rel_fn] = \
144 self._extract_security_manifest(app)
145 self.security_apps.append(app)
146
147 self.security_profiles = dict()141 self.security_profiles = dict()
148 self.security_apps_profiles = []142 self.security_apps_profiles = []
149 for app in self.manifest['hooks']:143
150 if 'apparmor-profile' not in self.manifest['hooks'][app]:144 if self.manifest is None and self.is_snap:
151 # msg("Skipped missing apparmor hook for '%s'" % app)145 for exe_t in ['services', 'binaries']:
152 continue146 if exe_t not in self.pkg_yaml:
153 if not isinstance(self.manifest['hooks'][app]['apparmor-profile'],147 continue
154 str):148 for item in self.pkg_yaml[exe_t]:
155 error("manifest malformed: hooks/%s/apparmor-profile is not "149 if 'name' not in item:
156 "str" % app)150 continue
157 rel_fn = self.manifest['hooks'][app]['apparmor-profile']151 app = "%s/%s" % (exe_t, item['name'])
158 self.security_profiles[rel_fn] = \152
159 self._extract_security_profile(app)153 if 'security-policy' in item:
160 self.security_apps_profiles.append(app)154 if 'apparmor' not in item['security-policy']:
161155 continue
162 # snappy156 rel_fn = item['security-policy']['apparmor']
163 self.sec_skipped_types = ['oem'] # these don't need security items157 self.security_profiles[rel_fn] = \
158 self._extract_security_profile(app)
159 self.security_apps_profiles.append(app)
160 continue
161
162 # Fake a security manifest for code reuse
163 # FIXME: this needs to be updated when we have 'target'
164 m = dict()
165 m['policy_vendor'] = "ubuntu-core"
166 m['policy_version'] = self._pkgfmt_version()
167 if 'security-template' in item:
168 m['template'] = item['security-template']
169 else:
170 m['template'] = 'default'
171
172 if 'caps' in item:
173 m['policy_groups'] = item['caps']
174 elif self._pkgfmt_version() == "15.04":
175 m['policy_groups'] = ['networking']
176 else:
177 m['policy_groups'] = ['network-client']
178
179 self.security_manifests[app] = m
180 self.security_apps.append(app)
181 else:
182 self.security_manifests = dict()
183 self.security_apps = []
184 for app in self.manifest['hooks']:
185 if 'apparmor' not in self.manifest['hooks'][app]:
186 # msg("Skipped missing apparmor hook for '%s'" % app)
187 continue
188 if not isinstance(self.manifest['hooks'][app]['apparmor'], str):
189 error("manifest malformed: hooks/%s/apparmor is not str" % app)
190 rel_fn = self.manifest['hooks'][app]['apparmor']
191 self.security_manifests[rel_fn] = \
192 self._extract_security_manifest(app)
193 self.security_apps.append(app)
194
195 for app in self.manifest['hooks']:
196 if 'apparmor-profile' not in self.manifest['hooks'][app]:
197 # msg("Skipped missing apparmor hook for '%s'" % app)
198 continue
199 if not isinstance(self.manifest['hooks'][app]['apparmor-profile'],
200 str):
201 error("manifest malformed: hooks/%s/apparmor-profile is not "
202 "str" % app)
203 rel_fn = self.manifest['hooks'][app]['apparmor-profile']
204 self.security_profiles[rel_fn] = \
205 self._extract_security_profile(app)
206 self.security_apps_profiles.append(app)
164207
165 def _override_framework_policies(self, overrides):208 def _override_framework_policies(self, overrides):
166 # override major framework policies209 # override major framework policies
@@ -222,21 +265,32 @@
222265
223 def _get_security_manifest(self, app):266 def _get_security_manifest(self, app):
224 '''Get the security manifest for app'''267 '''Get the security manifest for app'''
225 if app not in self.manifest['hooks']:268 if self._pkgfmt_type() == "click" or self._pkgfmt_version() == "15.04":
226 error("Could not find '%s' in click manifest" % app)269 if app not in self.manifest['hooks']:
227 elif 'apparmor' not in self.manifest['hooks'][app]:270 error("Could not find '%s' in click manifest" % app)
228 error("Could not find apparmor hook for '%s' in click manifest" %271 elif 'apparmor' not in self.manifest['hooks'][app]:
229 app)272 error("Could not find apparmor hook for '%s' in click manifest" %
230 f = self.manifest['hooks'][app]['apparmor']273 app)
231 m = self.security_manifests[f]274 f = self.manifest['hooks'][app]['apparmor']
275 m = self.security_manifests[f]
276 else:
277 f = app
278 m = self.security_manifests[app]
279
232 return (f, m)280 return (f, m)
233281
234 def _extract_security_profile(self, app):282 def _extract_security_profile(self, app):
235 '''Extract security profile'''283 '''Extract security profile'''
236 d = self.manifest['hooks'][app]['apparmor-profile']284 if self._pkgfmt_type() == "click" or self._pkgfmt_version() == "15.04":
237 fn = os.path.join(self.unpack_dir, d)285 rel_fn = self.manifest['hooks'][app]['apparmor-profile']
238 rel_fn = self.manifest['hooks'][app]['apparmor-profile']286 else:
287 exe_t, name = app.split('/')
288 for item in self.pkg_yaml[exe_t]:
289 if 'name' in item and item['name'] == name:
290 rel_fn = item['security-policy']['apparmor']
291 break
239292
293 fn = os.path.join(self.unpack_dir, rel_fn)
240 if not os.path.exists(fn):294 if not os.path.exists(fn):
241 error("Could not find '%s'" % rel_fn)295 error("Could not find '%s'" % rel_fn)
242296
@@ -254,12 +308,20 @@
254308
255 def _get_security_profile(self, app):309 def _get_security_profile(self, app):
256 '''Get the security profile for app'''310 '''Get the security profile for app'''
257 if app not in self.manifest['hooks']:311 if self._pkgfmt_type() == "click" or self._pkgfmt_version() == "15.04":
258 error("Could not find '%s' in click manifest" % app)312 if app not in self.manifest['hooks']:
259 elif 'apparmor-profile' not in self.manifest['hooks'][app]:313 error("Could not find '%s' in click manifest" % app)
260 error("Could not find apparmor-profile hook for '%s' in click "314 elif 'apparmor-profile' not in self.manifest['hooks'][app]:
261 "manifest" % app)315 error("Could not find apparmor-profile hook for '%s' in click "
262 f = self.manifest['hooks'][app]['apparmor-profile']316 "manifest" % app)
317 f = self.manifest['hooks'][app]['apparmor-profile']
318 else:
319 exe_t, name = app.split('/')
320 for item in self.pkg_yaml[exe_t]:
321 if 'name' in item and item['name'] == name:
322 f = item['security-policy']['apparmor']
323 break
324
263 p = self.security_profiles[f]325 p = self.security_profiles[f]
264 return (f, p)326 return (f, p)
265327
@@ -343,6 +405,10 @@
343 s = "policy_vendor '%s' not found" % m['policy_vendor']405 s = "policy_vendor '%s' not found" % m['policy_vendor']
344 self._add_result(t, n, s)406 self._add_result(t, n, s)
345407
408 if self._pkgfmt_type() == "snap" and \
409 float(self._pkgfmt_version()) >= 16.04:
410 continue
411
346 t = 'info'412 t = 'info'
347 n = self._get_check_name('policy_vendor_matches_framework', extra=f)413 n = self._get_check_name('policy_vendor_matches_framework', extra=f)
348 s = "OK"414 s = "OK"
@@ -408,6 +474,10 @@
408 s = '%s != %s' % (str(m['policy_version']), str(highest))474 s = '%s != %s' % (str(m['policy_version']), str(highest))
409 self._add_result(t, n, s, l)475 self._add_result(t, n, s, l)
410476
477 if self._pkgfmt_type() == "snap" and \
478 float(self._pkgfmt_version()) >= 16.04:
479 continue
480
411 t = 'info'481 t = 'info'
412 n = self._get_check_name('policy_version_matches_framework', extra=f)482 n = self._get_check_name('policy_version_matches_framework', extra=f)
413 s = "OK"483 s = "OK"
@@ -545,29 +615,17 @@
545615
546 self._add_result(t, n, s)616 self._add_result(t, n, s)
547617
548 def check_template_push_helpers(self):
549 '''Check template for push-helpers'''
550 for app in sorted(self.security_apps):
551 (f, m) = self._get_security_manifest(app)
552 t = 'info'
553 n = self._get_check_name('template_push_helper', extra=f)
554 s = "OK"
555 if 'push-helper' not in self.manifest['hooks'][app]:
556 continue
557 if 'template' not in m or m['template'] != "ubuntu-push-helper":
558 t = 'error'
559 s = "template is not 'ubuntu-push-helper'"
560 self._add_result(t, n, s)
561
562 def check_policy_groups_push_helpers(self):618 def check_policy_groups_push_helpers(self):
563 '''Check policy_groups for push-helpers'''619 '''Check policy groups for push-helpers'''
564 for app in sorted(self.security_apps):620 for app in sorted(self.security_apps):
565 (f, m) = self._get_security_manifest(app)621 (f, m) = self._get_security_manifest(app)
566 t = 'info'622 t = 'info'
567 n = self._get_check_name('policy_groups_push_helper', extra=f)623 n = self._get_check_name('policy_groups_push_helper', extra=f)
568 s = "OK"624 s = "OK"
569 if 'push-helper' not in self.manifest['hooks'][app]:625
626 if 'template' not in m or m['template'] != 'ubuntu-push-helper':
570 continue627 continue
628
571 if 'policy_groups' not in m or \629 if 'policy_groups' not in m or \
572 'push-notification-client' not in m['policy_groups']:630 'push-notification-client' not in m['policy_groups']:
573 self._add_result('error', n,631 self._add_result('error', n,
@@ -578,7 +636,7 @@
578 for p in m['policy_groups']:636 for p in m['policy_groups']:
579 if p not in self.allowed_push_helper_policy_groups:637 if p not in self.allowed_push_helper_policy_groups:
580 bad.append(p)638 bad.append(p)
581 elif p == "networking":639 elif p == "networking" or p == "network-client":
582 # The above covers this, but let's be very explicit and640 # The above covers this, but let's be very explicit and
583 # never allow networking with push-helpers641 # never allow networking with push-helpers
584 bad.append(p)642 bad.append(p)
@@ -624,7 +682,8 @@
624 '''Check policy_groups for ubuntu-account-plugin template'''682 '''Check policy_groups for ubuntu-account-plugin template'''
625 for app in sorted(self.security_apps):683 for app in sorted(self.security_apps):
626 (f, m) = self._get_security_manifest(app)684 (f, m) = self._get_security_manifest(app)
627 if 'account-qml-plugin' not in self.manifest['hooks'][app]:685
686 if 'template' not in m or m['template'] != 'ubuntu-account-plugin':
628 continue687 continue
629688
630 t = 'info'689 t = 'info'
@@ -843,12 +902,17 @@
843 for app in sorted(self.security_apps_profiles):902 for app in sorted(self.security_apps_profiles):
844 (f, p) = self._get_security_profile(app)903 (f, p) = self._get_security_profile(app)
845904
846 for v in ['###VAR###',905 searches = ['###VAR###',
847 '###PROFILEATTACH###',906 '###PROFILEATTACH###',
848 '@{CLICK_DIR}',907 '@{CLICK_DIR}',
849 '@{APP_PKGNAME}',908 '@{APP_PKGNAME}',
850 '@{APP_VERSION}',909 '@{APP_VERSION}',
851 ]:910 ]
911 if self._pkgfmt_type() == 'snap' and \
912 float(self._pkgfmt_version()) > 15.04:
913 searches.append("@{INSTALL_DIR}")
914
915 for v in searches:
852 t = 'info'916 t = 'info'
853 n = self._get_check_name(917 n = self._get_check_name(
854 'apparmor_profile', extra='%s (%s)' % (v, f))918 'apparmor_profile', extra='%s (%s)' % (v, f))
@@ -1081,7 +1145,9 @@
1081 '''Verify click and security yaml are in sync (not including1145 '''Verify click and security yaml are in sync (not including
1082 override)1146 override)
1083 '''1147 '''
1084 if not self.is_snap or self.pkg_yaml['type'] in self.sec_skipped_types:1148 if not self.is_snap or \
1149 self.pkg_yaml['type'] in self.sec_skipped_types or \
1150 float(self._pkgfmt_version()) > 15.04:
1085 return1151 return
10861152
1087 # setup a small dict that is a subset of self.pkg_yaml1153 # setup a small dict that is a subset of self.pkg_yaml
@@ -1121,7 +1187,9 @@
11211187
1122 def check_security_yaml_override_and_click(self):1188 def check_security_yaml_override_and_click(self):
1123 '''Verify click and security yaml override are in sync'''1189 '''Verify click and security yaml override are in sync'''
1124 if not self.is_snap or self.pkg_yaml['type'] in self.sec_skipped_types:1190 if not self.is_snap or \
1191 self.pkg_yaml['type'] in self.sec_skipped_types or \
1192 float(self._pkgfmt_version()) > 15.04:
1125 return1193 return
11261194
1127 for exe_t in ['services', 'binaries']:1195 for exe_t in ['services', 'binaries']:
@@ -1180,16 +1248,44 @@
1180 s = "OK"1248 s = "OK"
1181 if 'security-override' not in item:1249 if 'security-override' not in item:
1182 s = "OK (skipping unspecified override)"1250 s = "OK (skipping unspecified override)"
1183 elif 'apparmor' not in item['security-override']:1251 elif float(self._pkgfmt_version()) < 16.04:
1184 t = 'error'1252 if 'apparmor' not in item['security-override']:
1185 s = "'apparmor' not specified in 'security-override' " + \1253 t = 'error'
1186 "for '%s'" % app1254 s = "'apparmor' not specified in 'security-override' " + \
1187 elif 'seccomp' not in item['security-override']:1255 "for '%s'" % app
1188 t = 'error'1256 elif 'seccomp' not in item['security-override']:
1189 s = "'seccomp' not specified in 'security-override' " + \1257 t = 'error'
1190 "for '%s'" % app1258 s = "'seccomp' not specified in 'security-override' " + \
1259 "for '%s'" % app
1260 else:
1261 allowed_fields = ['read-paths',
1262 'write-paths',
1263 'abstractions',
1264 'syscalls']
1265 if len(item['security-override'].keys()) == 0:
1266 t = 'error'
1267 s = "nothing specified in 'security-override' " + \
1268 "for '%s'" % app
1269 else:
1270 for f in item['security-override'].keys():
1271 if f not in allowed_fields:
1272 t = 'error'
1273 s = "unknown field '%s' in " % f + \
1274 "'security-override' for '%s'" % app
1275
1191 self._add_result(t, n, s)1276 self._add_result(t, n, s)
11921277
1278 # security-override on 16.04 gives direct access to syscalls,
1279 # read-paths, etc so it always needs a manual override
1280 if 'security-override' in item and \
1281 float(self._pkgfmt_version()) > 15.04:
1282 t = 'error'
1283 n = self._get_check_name('yaml_override_present')
1284 s = "(MANUAL REVIEW) 'security-override' not allowed"
1285 l = 'https://developer.ubuntu.com/en/snappy/guides/security-policy/'
1286 m = True
1287 self._add_result(t, n, s, link=l, manual_review=m)
1288
1193 def check_security_yaml_policy(self):1289 def check_security_yaml_policy(self):
1194 '''Verify security yaml policy'''1290 '''Verify security yaml policy'''
1195 if not self.is_snap:1291 if not self.is_snap:
@@ -1305,20 +1401,21 @@
1305 continue1401 continue
1306 self._add_result(t, n, s)1402 self._add_result(t, n, s)
13071403
1308 t = 'info'1404 if self._pkgfmt_version() == "15.04":
1309 n = self._get_check_name('yaml_security-template_in_manifest', app=app)1405 t = 'info'
1310 s = "OK"1406 n = self._get_check_name('yaml_security-template_in_manifest', app=app)
1311 if app not in self.manifest['hooks']:1407 s = "OK"
1312 t = 'error'1408 if app not in self.manifest['hooks']:
1313 s = "'%s' not found in click manifest" % app1409 t = 'error'
1314 self._add_result(t, n, s)1410 s = "'%s' not found in click manifest" % app
1315 continue1411 self._add_result(t, n, s)
1316 elif 'apparmor' not in self.manifest['hooks'][app] and \1412 continue
1317 'apparmor-profile' not in self.manifest['hooks'][app]:1413 elif 'apparmor' not in self.manifest['hooks'][app] and \
1318 t = 'error'1414 'apparmor-profile' not in self.manifest['hooks'][app]:
1319 s = "'apparmor' not found in click manifest for '%s'" % app1415 t = 'error'
1320 self._add_result(t, n, s)1416 s = "'apparmor' not found in click manifest for '%s'" % app
1321 continue1417 self._add_result(t, n, s)
1418 continue
13221419
1323 # TODO: error if not 'common' or is 'unconfined'1420 # TODO: error if not 'common' or is 'unconfined'
13241421
@@ -1358,25 +1455,30 @@
1358 continue1455 continue
1359 self._add_result(t, n, s)1456 self._add_result(t, n, s)
13601457
1361 t = 'info'1458 if self._pkgfmt_version() == "15.04":
1362 n = self._get_check_name('yaml_caps_in_manifest', app=app)1459 t = 'info'
1363 s = "OK"1460 n = self._get_check_name('yaml_caps_in_manifest', app=app)
1364 if app not in self.manifest['hooks']:1461 s = "OK"
1365 t = 'error'1462 if app not in self.manifest['hooks']:
1366 s = "'%s' not found in click manifest" % app1463 t = 'error'
1367 self._add_result(t, n, s)1464 s = "'%s' not found in click manifest" % app
1368 continue1465 self._add_result(t, n, s)
1369 elif 'apparmor' not in self.manifest['hooks'][app] and \1466 continue
1370 'apparmor-profile' not in self.manifest['hooks'][app]:1467 elif 'apparmor' not in self.manifest['hooks'][app] and \
1371 t = 'error'1468 'apparmor-profile' not in self.manifest['hooks'][app]:
1372 s = "'apparmor' not found in click manifest for '%s'" % app1469 t = 'error'
1373 self._add_result(t, n, s)1470 s = "'apparmor' not found in click manifest for '%s'" % app
1374 continue1471 self._add_result(t, n, s)
1472 continue
13751473
1376 # TODO: error if not 'common'1474 # TODO: error if not 'common'
13771475
1378 def check_template_online_accounts_provider(self):1476 def check_template_online_accounts_provider(self):
1379 '''Check template for online accounts account-provider'''1477 '''Check template for online accounts account-provider'''
1478 if self._pkgfmt_type() == "snap" and \
1479 float(self._pkgfmt_version()) > 15.04:
1480 return
1481
1380 for app in sorted(self.security_apps):1482 for app in sorted(self.security_apps):
1381 (f, m) = self._get_security_manifest(app)1483 (f, m) = self._get_security_manifest(app)
1382 t = 'info'1484 t = 'info'
@@ -1391,6 +1493,10 @@
13911493
1392 def check_template_online_accounts_qml_plugin(self):1494 def check_template_online_accounts_qml_plugin(self):
1393 '''Check template for online accounts account-qml-plugin'''1495 '''Check template for online accounts account-qml-plugin'''
1496 if self._pkgfmt_type() == "snap" and \
1497 float(self._pkgfmt_version()) > 15.04:
1498 return
1499
1394 for app in sorted(self.security_apps):1500 for app in sorted(self.security_apps):
1395 (f, m) = self._get_security_manifest(app)1501 (f, m) = self._get_security_manifest(app)
1396 t = 'info'1502 t = 'info'
13971503
=== modified file 'clickreviews/cr_tests.py'
--- clickreviews/cr_tests.py 2015-11-12 13:37:12 +0000
+++ clickreviews/cr_tests.py 2015-12-01 15:03:49 +0000
@@ -50,6 +50,8 @@
50TEST_FRAMEWORK = dict()50TEST_FRAMEWORK = dict()
51TEST_FRAMEWORK_POLICY = dict()51TEST_FRAMEWORK_POLICY = dict()
52TEST_FRAMEWORK_POLICY_UNKNOWN = []52TEST_FRAMEWORK_POLICY_UNKNOWN = []
53TEST_PKGFMT_TYPE = "click"
54TEST_PKGFMT_VERSION = "0.4"
5355
5456
55#57#
@@ -139,6 +141,9 @@
139141
140def _get_security_manifest(self, app):142def _get_security_manifest(self, app):
141 '''Pretend we read the security manifest file'''143 '''Pretend we read the security manifest file'''
144 if TEST_PKGFMT_VERSION == "16.04":
145 return (app, json.loads(TEST_SECURITY[app]))
146
142 return ("%s.apparmor" % app, json.loads(TEST_SECURITY[app]))147 return ("%s.apparmor" % app, json.loads(TEST_SECURITY[app]))
143148
144149
@@ -244,6 +249,21 @@
244 return True249 return True
245250
246251
252def _pkgfmt_type(self):
253 '''Pretend we found the pkgfmt type'''
254 return TEST_PKGFMT_TYPE
255
256
257def _pkgfmt_version(self):
258 '''Pretend we found the pkgfmt version'''
259 return TEST_PKGFMT_VERSION
260
261
262def _is_squashfs(self):
263 '''Pretend we discovered if it is a squashfs or not'''
264 return (TEST_PKGFMT_TYPE == "snap" and float(TEST_PKGFMT_VERSION) > 15.04)
265
266
247def create_patches():267def create_patches():
248 # http://docs.python.org/3.4/library/unittest.mock-examples.html268 # http://docs.python.org/3.4/library/unittest.mock-examples.html
249 # Mock patching. Don't use decorators but instead patch in setUp() of the269 # Mock patching. Don't use decorators but instead patch in setUp() of the
@@ -367,7 +387,14 @@
367 patches.append(patch(387 patches.append(patch(
368 'clickreviews.cr_framework.ClickReviewFramework._has_framework_in_metadir',388 'clickreviews.cr_framework.ClickReviewFramework._has_framework_in_metadir',
369 _has_framework_in_metadir))389 _has_framework_in_metadir))
370 patches.append(patch("clickreviews.cr_lint.is_squashfs", lambda x: False))390
391 # pkgfmt
392 patches.append(patch("clickreviews.cr_common.ClickReview._pkgfmt_type",
393 _pkgfmt_type))
394 patches.append(patch("clickreviews.cr_common.ClickReview._pkgfmt_version",
395 _pkgfmt_version))
396 patches.append(patch("clickreviews.cr_common.is_squashfs", _is_squashfs))
397 patches.append(patch("clickreviews.cr_lint.is_squashfs", _is_squashfs))
371398
372 return patches399 return patches
373400
@@ -427,6 +454,8 @@
427 self.test_readme_md = self.test_control['Description']454 self.test_readme_md = self.test_control['Description']
428 self._update_test_readme_md()455 self._update_test_readme_md()
429456
457 self.set_test_pkgfmt("click", "0.4")
458
430 # hooks459 # hooks
431 self.test_security_manifests = dict()460 self.test_security_manifests = dict()
432 self.test_security_profiles = dict()461 self.test_security_profiles = dict()
@@ -444,6 +473,7 @@
444 self.test_framework = dict()473 self.test_framework = dict()
445 self.test_framework_policy = dict()474 self.test_framework_policy = dict()
446 self.test_framework_policy_unknown = []475 self.test_framework_policy_unknown = []
476
447 for app in self.test_manifest["hooks"].keys():477 for app in self.test_manifest["hooks"].keys():
448 # setup security manifest for each app478 # setup security manifest for each app
449 self.set_test_security_manifest(app, 'policy_groups',479 self.set_test_security_manifest(app, 'policy_groups',
@@ -846,6 +876,12 @@
846 self.test_security_profiles[app] = policy876 self.test_security_profiles[app] = policy
847 self._update_test_security_profiles()877 self._update_test_security_profiles()
848878
879 def set_test_pkgfmt(self, t, v):
880 global TEST_PKGFMT_TYPE
881 global TEST_PKGFMT_VERSION
882 TEST_PKGFMT_TYPE = t
883 TEST_PKGFMT_VERSION = v
884
849 def set_test_desktop(self, app, key, value, no_update=False):885 def set_test_desktop(self, app, key, value, no_update=False):
850 '''Set key in desktop file to value. If value is None, remove key'''886 '''Set key in desktop file to value. If value is None, remove key'''
851 if app not in self.test_desktop_files:887 if app not in self.test_desktop_files:
@@ -1137,6 +1173,10 @@
1137 TEST_FRAMEWORK_POLICY = dict()1173 TEST_FRAMEWORK_POLICY = dict()
1138 global TEST_FRAMEWORK_POLICY_UNKNOWN1174 global TEST_FRAMEWORK_POLICY_UNKNOWN
1139 TEST_FRAMEWORK_POLICY_UNKNOWN = []1175 TEST_FRAMEWORK_POLICY_UNKNOWN = []
1176 global TEST_PKGFMT_TYPE
1177 TEST_PKGFMT_TYPE = "click"
1178 global TEST_PKGFMT_VERSION
1179 TEST_PKGFMT_VERSION = "0.4"
11401180
1141 self._reset_test_data()1181 self._reset_test_data()
1142 cr_common.recursive_rm(self.desktop_tmpdir)1182 cr_common.recursive_rm(self.desktop_tmpdir)
11431183
=== modified file 'clickreviews/cr_url_dispatcher.py'
--- clickreviews/cr_url_dispatcher.py 2015-08-13 21:07:13 +0000
+++ clickreviews/cr_url_dispatcher.py 2015-12-01 15:03:49 +0000
@@ -40,6 +40,10 @@
4040
41 self.url_dispatcher_files = dict() # click-show-files and tests41 self.url_dispatcher_files = dict() # click-show-files and tests
42 self.url_dispatcher = dict()42 self.url_dispatcher = dict()
43
44 if self.manifest is None:
45 return
46
43 for app in self.manifest['hooks']:47 for app in self.manifest['hooks']:
44 if 'urls' not in self.manifest['hooks'][app]:48 if 'urls' not in self.manifest['hooks'][app]:
45 # msg("Skipped missing urls hook for '%s'" % app)49 # msg("Skipped missing urls hook for '%s'" % app)
4650
=== modified file 'clickreviews/tests/test_cr_content_hub.py'
--- clickreviews/tests/test_cr_content_hub.py 2015-10-16 02:54:07 +0000
+++ clickreviews/tests/test_cr_content_hub.py 2015-12-01 15:03:49 +0000
@@ -155,3 +155,28 @@
155 r = c.click_report155 r = c.click_report
156 expected_counts = {'info': None, 'warn': 0, 'error': 1}156 expected_counts = {'info': None, 'warn': 0, 'error': 1}
157 self.check_results(r, expected_counts)157 self.check_results(r, expected_counts)
158
159 def test_check_valid_snappy_1504(self):
160 '''Test check_valid() - snappy 15.04'''
161 self.set_test_pkgfmt("snap", "15.04")
162 self.set_test_content_hub(self.default_appname, "destination", "pictures")
163 self.set_test_content_hub(self.default_appname, "share", "pictures")
164 self.set_test_content_hub(self.default_appname, "source", "pictures")
165 c = ClickReviewContentHub(self.test_name)
166 c.check_valid()
167 r = c.click_report
168 expected_counts = {'info': 6, 'warn': 0, 'error': 0}
169 self.check_results(r, expected_counts)
170
171 def test_check_valid_snappy_1604(self):
172 '''Test check_valid() - snappy 16.04'''
173 self.set_test_pkgfmt("snap", "16.04")
174 self.set_test_content_hub(self.default_appname, "destination", "pictures")
175 self.set_test_content_hub(self.default_appname, "share", "pictures")
176 self.set_test_content_hub(self.default_appname, "source", "pictures")
177 c = ClickReviewContentHub(self.test_name)
178 c.check_valid()
179 r = c.click_report
180 # should be empty with this pkgfmt
181 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
182 self.check_results(r, expected_counts)
158183
=== modified file 'clickreviews/tests/test_cr_desktop.py'
--- clickreviews/tests/test_cr_desktop.py 2015-10-16 02:54:07 +0000
+++ clickreviews/tests/test_cr_desktop.py 2015-12-01 15:03:49 +0000
@@ -896,3 +896,31 @@
896 r = c.click_report896 r = c.click_report
897 expected_counts = {'info': None, 'warn': 0, 'error': 1}897 expected_counts = {'info': None, 'warn': 0, 'error': 1}
898 self.check_results(r, expected_counts)898 self.check_results(r, expected_counts)
899
900 def test_check_desktop_file_snappy_1504(self):
901 '''Test check_desktop_file() - snappy 15.04'''
902 self.set_test_pkgfmt("snap", "15.04")
903 c = ClickReviewDesktop(self.test_name)
904 c.check_desktop_file()
905 r = c.click_report
906 expected = dict()
907 expected['info'] = dict()
908 expected['warn'] = dict()
909 expected['error'] = dict()
910 name = c._get_check_name('files_usable')
911 expected['info'][name] = {"text": "OK"}
912 self.check_results(r, expected=expected)
913
914 def test_check_desktop_file_snappy_1604(self):
915 '''Test check_desktop_file() - snappy 16.04'''
916 self.set_test_pkgfmt("snap", "16.04")
917 c = ClickReviewDesktop(self.test_name)
918 c.check_desktop_file()
919 r = c.click_report
920 expected = dict()
921 expected['info'] = dict()
922 expected['warn'] = dict()
923 expected['error'] = dict()
924 name = c._get_check_name('files_usable')
925 expected['info'][name] = {"text": "Skipped: could not find any desktop files"}
926 self.check_results(r, expected=expected)
899927
=== modified file 'clickreviews/tests/test_cr_lint.py'
--- clickreviews/tests/test_cr_lint.py 2015-11-12 14:27:00 +0000
+++ clickreviews/tests/test_cr_lint.py 2015-12-01 15:03:49 +0000
@@ -143,7 +143,9 @@
143 def test_check_architecture_nonexistent(self):143 def test_check_architecture_nonexistent(self):
144 '''Test check_architecture() - nonexistent'''144 '''Test check_architecture() - nonexistent'''
145 self.set_test_control("Architecture", "nonexistent")145 self.set_test_control("Architecture", "nonexistent")
146 self.set_test_pkgfmt("click", "0.4")
146 c = ClickReviewLint(self.test_name)147 c = ClickReviewLint(self.test_name)
148 c.pkg_arch = ["nonexistent"]
147 c.check_architecture()149 c.check_architecture()
148 r = c.click_report150 r = c.click_report
149 expected_counts = {'info': 0, 'warn': 0, 'error': 1}151 expected_counts = {'info': 0, 'warn': 0, 'error': 1}
@@ -157,6 +159,25 @@
157 expected_counts = {'info': None, 'warn': 0, 'error': 0}159 expected_counts = {'info': None, 'warn': 0, 'error': 0}
158 self.check_results(r, expected_counts)160 self.check_results(r, expected_counts)
159161
162 def test_check_control_architecture_snappy_1504(self):
163 '''Test check_control() (architecture) - snappy 15.04'''
164 self.set_test_pkgfmt("snap", "15.04")
165 c = ClickReviewLint(self.test_name)
166 c.check_control()
167 r = c.click_report
168 expected_counts = {'info': 15, 'warn': 0, 'error': 0}
169 self.check_results(r, expected_counts)
170
171 def test_check_control_architecture_snappy_1604(self):
172 '''Test check_control() (architecture) - snappy 16.04'''
173 self.set_test_pkgfmt("snap", "16.04")
174 c = ClickReviewLint(self.test_name)
175 c.check_control()
176 r = c.click_report
177 # should be empty with this pkgfmt
178 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
179 self.check_results(r, expected_counts)
180
160 def test_check_control_architecture_missing(self):181 def test_check_control_architecture_missing(self):
161 '''Test check_control() (architecture missing)'''182 '''Test check_control() (architecture missing)'''
162 self.set_test_control("Architecture", None)183 self.set_test_control("Architecture", None)
@@ -220,6 +241,7 @@
220 self.set_test_control("Architecture", "armhf")241 self.set_test_control("Architecture", "armhf")
221 self.set_test_manifest("architecture", "armhf")242 self.set_test_manifest("architecture", "armhf")
222 c = ClickReviewLint(self.test_name)243 c = ClickReviewLint(self.test_name)
244 c.pkg_arch = ['armhf']
223 c.pkg_bin_files = []245 c.pkg_bin_files = []
224 c.check_architecture_specified_needed()246 c.check_architecture_specified_needed()
225 r = c.click_report247 r = c.click_report
@@ -237,90 +259,6 @@
237 expected_counts = {'info': None, 'warn': 0, 'error': 0}259 expected_counts = {'info': None, 'warn': 0, 'error': 0}
238 self.check_results(r, expected_counts)260 self.check_results(r, expected_counts)
239261
240 def test_check_package_filename(self):
241 '''Test check_package_filename()'''
242 c = ClickReviewLint(self.test_name)
243 c.check_package_filename()
244 r = c.click_report
245 expected_counts = {'info': None, 'warn': 0, 'error': 0}
246 self.check_results(r, expected_counts)
247
248 def test_check_package_filename_missing_version(self):
249 '''Test check_package_filename() - missing version'''
250 test_name = "%s_%s.click" % (self.test_control['Package'],
251 self.test_control['Architecture'])
252 c = ClickReviewLint(test_name)
253 c.check_package_filename()
254 r = c.click_report
255 expected_counts = {'info': None, 'warn': 3, 'error': 1}
256 self.check_results(r, expected_counts)
257
258 def test_check_package_filename_missing_arch(self):
259 '''Test check_package_filename() - missing arch'''
260 test_name = "%s_%s.click" % (self.test_control['Package'],
261 self.test_control['Version'])
262 c = ClickReviewLint(test_name)
263 c.check_package_filename()
264 r = c.click_report
265 expected_counts = {'info': None, 'warn': 3, 'error': 0}
266 self.check_results(r, expected_counts)
267
268 def test_check_package_filename_missing_package(self):
269 '''Test check_package_filename() - missing package'''
270 test_name = "%s_%s.click" % (self.test_control['Version'],
271 self.test_control['Architecture'])
272 c = ClickReviewLint(test_name)
273 c.check_package_filename()
274 r = c.click_report
275 expected_counts = {'info': None, 'warn': 3, 'error': 1}
276 self.check_results(r, expected_counts)
277
278 def test_check_package_filename_extra_underscore(self):
279 '''Test check_package_filename() - extra underscore'''
280 test_name = "_%s_%s_%s.click" % (self.test_control['Package'],
281 self.test_control['Version'],
282 self.test_control['Architecture'])
283 c = ClickReviewLint(test_name)
284 c.check_package_filename()
285 r = c.click_report
286 expected_counts = {'info': None, 'warn': 2, 'error': 2}
287 self.check_results(r, expected_counts)
288
289 def test_check_package_filename_version_mismatches(self):
290 '''Test check_package_filename() (version mismatches filename)'''
291 self.set_test_control("Version", "100.1.1")
292 c = ClickReviewLint(self.test_name)
293 c.check_package_filename()
294 r = c.click_report
295 expected_counts = {'info': None, 'warn': 0, 'error': 1}
296 self.check_results(r, expected_counts)
297
298 def test_check_package_filename_valid_arch(self):
299 '''Test check_package_filename() (valid arch)'''
300 arch = "armhf"
301 self.set_test_control("Architecture", arch)
302 test_name = "%s_%s_%s.click" % (self.test_control['Package'],
303 self.test_control['Version'],
304 self.test_control['Architecture'])
305 c = ClickReviewLint(test_name)
306 c.check_package_filename()
307 r = c.click_report
308 expected_counts = {'info': None, 'warn': 0, 'error': 0}
309 self.check_results(r, expected_counts)
310
311 def test_check_package_filename_valid_arch_multi(self):
312 '''Test check_package_filename() (valid multi arch)'''
313 arch = "multi"
314 self.set_test_control("Architecture", arch)
315 test_name = "%s_%s_%s.click" % (self.test_control['Package'],
316 self.test_control['Version'],
317 arch)
318 c = ClickReviewLint(test_name)
319 c.check_package_filename()
320 r = c.click_report
321 expected_counts = {'info': None, 'warn': 0, 'error': 0}
322 self.check_results(r, expected_counts)
323
324 def test_check_manifest_missing_arch(self):262 def test_check_manifest_missing_arch(self):
325 '''Test check_manifest_architecture() (missing)'''263 '''Test check_manifest_architecture() (missing)'''
326 self.set_test_manifest("architecture", None)264 self.set_test_manifest("architecture", None)
@@ -330,6 +268,26 @@
330 expected_counts = {'info': 1, 'warn': 0, 'error': 0}268 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
331 self.check_results(r, expected_counts)269 self.check_results(r, expected_counts)
332270
271 def test_check_manifest_missing_arch_snappy_1504(self):
272 '''Test check_manifest_architecture() - snappy 15.04'''
273 self.set_test_pkgfmt("snap", "15.04")
274 self.set_test_manifest("architecture", None)
275 c = ClickReviewLint(self.test_name)
276 c.check_manifest_architecture()
277 r = c.click_report
278 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
279 self.check_results(r, expected_counts)
280
281 def test_check_manifest_missing_arch_snappy_1604(self):
282 '''Test check_manifest_architecture() - snappy 16.04'''
283 self.set_test_pkgfmt("snap", "16.04")
284 self.set_test_manifest("architecture", None)
285 c = ClickReviewLint(self.test_name)
286 c.check_manifest_architecture()
287 r = c.click_report
288 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
289 self.check_results(r, expected_counts)
290
333 def test_check_manifest_arch_all(self):291 def test_check_manifest_arch_all(self):
334 '''Test check_manifest_architecture() (all)'''292 '''Test check_manifest_architecture() (all)'''
335 self.set_test_manifest("architecture", "all")293 self.set_test_manifest("architecture", "all")
@@ -455,27 +413,6 @@
455 expected_counts = {'info': 0, 'warn': 0, 'error': 1}413 expected_counts = {'info': 0, 'warn': 0, 'error': 1}
456 self.check_results(r, expected_counts)414 self.check_results(r, expected_counts)
457415
458 def test_check_package_filename_mismatch_arch(self):
459 '''Test check_package_filename() (control mismatches arch)'''
460 arch = "armhf"
461 self.set_test_control("Architecture", "all")
462 test_name = "%s_%s_%s.click" % (self.test_control['Package'],
463 self.test_control['Version'],
464 arch)
465 c = ClickReviewLint(test_name)
466 c.check_package_filename()
467 r = c.click_report
468 expected_counts = {'info': None, 'warn': 0, 'error': 1}
469 self.check_results(r, expected_counts)
470
471 def test_check_package_filename_with_extra_click(self):
472 """Test namespaces with the word "click" in them."""
473 c = ClickReviewLint(self.test_name)
474 c.check_package_filename()
475 r = c.click_report
476 expected_counts = {'info': None, 'warn': 0, 'error': 0}
477 self.check_results(r, expected_counts)
478
479 def test_check_control(self):416 def test_check_control(self):
480 """A very basic test to make sure check_control can be tested."""417 """A very basic test to make sure check_control can be tested."""
481 c = ClickReviewLint(self.test_name)418 c = ClickReviewLint(self.test_name)
@@ -638,6 +575,26 @@
638 expected_counts = {'info': None, 'warn': 0, 'error': 0}575 expected_counts = {'info': None, 'warn': 0, 'error': 0}
639 self.check_results(r, expected_counts)576 self.check_results(r, expected_counts)
640577
578 def test_check_icon_snappy_1504(self):
579 '''Test check_icon() - snappy 15.04'''
580 self.set_test_pkgfmt("snap", "15.04")
581 self.set_test_manifest("icon", "someicon")
582 c = ClickReviewLint(self.test_name)
583 c.check_icon()
584 r = c.click_report
585 expected_counts = {'info': 3, 'warn': 0, 'error': 0}
586 self.check_results(r, expected_counts)
587
588 def test_check_icon_snappy_1604(self):
589 '''Test check_icon() - snappy 16.04'''
590 self.set_test_pkgfmt("snap", "16.04")
591 self.set_test_manifest("icon", "someicon")
592 c = ClickReviewLint(self.test_name)
593 c.check_icon()
594 r = c.click_report
595 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
596 self.check_results(r, expected_counts)
597
641 def test_check_icon_unspecified(self):598 def test_check_icon_unspecified(self):
642 '''Test check_icon()'''599 '''Test check_icon()'''
643 self.set_test_manifest("icon", None)600 self.set_test_manifest("icon", None)
@@ -714,6 +671,34 @@
714 expected_counts = {'info': 1, 'warn': 0, 'error': 0}671 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
715 self.check_results(r, expected_counts)672 self.check_results(r, expected_counts)
716673
674 def test_check_click_local_extensions_snappy_1504(self):
675 '''Testeck_click_local_extensions() - snappy 15.04'''
676 self.set_test_pkgfmt("snap", "15.04")
677 for k in self.test_manifest.keys():
678 if k.startswith("x-"):
679 self.set_test_manifest(k, None)
680 self.set_test_manifest("x-source", {"vcs-bzr": "lp:notes-app",
681 "vcs-bzr-revno": "209"})
682 c = ClickReviewLint(self.test_name)
683 c.check_click_local_extensions()
684 r = c.click_report
685 expected_counts = {'info': 0, 'warn': 1, 'error': 0}
686 self.check_results(r, expected_counts)
687
688 def test_check_click_local_extensions_snappy_1604(self):
689 '''Testeck_click_local_extensions() - snappy 16.04'''
690 self.set_test_pkgfmt("snap", "16.04")
691 for k in self.test_manifest.keys():
692 if k.startswith("x-"):
693 self.set_test_manifest(k, None)
694 self.set_test_manifest("x-source", {"vcs-bzr": "lp:notes-app",
695 "vcs-bzr-revno": "209"})
696 c = ClickReviewLint(self.test_name)
697 c.check_click_local_extensions()
698 r = c.click_report
699 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
700 self.check_results(r, expected_counts)
701
717 def test_check_framework(self):702 def test_check_framework(self):
718 '''Test check_framework()'''703 '''Test check_framework()'''
719 self.patch_frameworks()704 self.patch_frameworks()
@@ -748,6 +733,19 @@
748 expected_counts = {'info': 1, 'warn': 0, 'error': 0}733 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
749 self.check_results(r, expected_counts)734 self.check_results(r, expected_counts)
750735
736 def test_check_framework_multiple_snappy_1604(self):
737 '''Test check_framework() - snappy 16.04'''
738 self.patch_frameworks()
739 self.set_test_pkgfmt("snap", "16.04")
740 self.set_test_manifest("framework",
741 "ubuntu-sdk-14.10-qml-dev2,ubuntu-core-15.04")
742 c = ClickReviewLint(self.test_name)
743 c.is_snap = True
744 c.check_framework()
745 r = c.click_report
746 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
747 self.check_results(r, expected_counts)
748
751 @patch('clickreviews.remote.read_cr_file')749 @patch('clickreviews.remote.read_cr_file')
752 def test_check_framework_fetches_remote_data(self, mock_read_cr_file):750 def test_check_framework_fetches_remote_data(self, mock_read_cr_file):
753 '''Test check_framework()'''751 '''Test check_framework()'''
@@ -831,6 +829,27 @@
831 expected_counts = {'info': None, 'warn': 0, 'error': 0}829 expected_counts = {'info': None, 'warn': 0, 'error': 0}
832 self.check_results(r, expected_counts)830 self.check_results(r, expected_counts)
833831
832 def test_check_hooks_snappy_1504(self):
833 '''Test check_hooks() - snappy 15.04'''
834 self.set_test_pkgfmt("snap", "15.04")
835 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
836 c = ClickReviewLint(self.test_name)
837 c.check_hooks()
838 r = c.click_report
839 expected_counts = {'info': 5, 'warn': 0, 'error': 0}
840 self.check_results(r, expected_counts)
841
842 def test_check_hooks_snappy_1604(self):
843 '''Test check_hooks() - snappy 16.04'''
844 self.set_test_pkgfmt("snap", "16.04")
845 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
846 c = ClickReviewLint(self.test_name)
847 c.check_hooks()
848 r = c.click_report
849 # this should be 0 with this pkgfmt
850 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
851 self.check_results(r, expected_counts)
852
834 def test_check_hooks_multiple_desktop_apps(self):853 def test_check_hooks_multiple_desktop_apps(self):
835 '''Test check_hooks() - multiple desktop apps'''854 '''Test check_hooks() - multiple desktop apps'''
836 self.set_test_manifest("framework", "ubuntu-sdk-13.10")855 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
@@ -950,6 +969,26 @@
950 expected_counts = {'info': None, 'warn': 1, 'error': 0}969 expected_counts = {'info': None, 'warn': 1, 'error': 0}
951 self.check_results(r, expected_counts)970 self.check_results(r, expected_counts)
952971
972 def test_check_hooks_unknown_nonexistent_snappy_1504(self):
973 '''Test check_hooks_unknown() - nonexistent - snappy 15.04'''
974 self.set_test_pkgfmt("snap", "15.04")
975 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
976 c = ClickReviewLint(self.test_name)
977 c.check_hooks_unknown()
978 r = c.click_report
979 expected_counts = {'info': 3, 'warn': 0, 'error': 0}
980 self.check_results(r, expected_counts)
981
982 def test_check_hooks_unknown_nonexistent_snappy_1604(self):
983 '''Test check_hooks_unknown() - nonexistent - snappy 16.04'''
984 self.set_test_pkgfmt("snap", "16.04")
985 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
986 c = ClickReviewLint(self.test_name)
987 c.check_hooks_unknown()
988 r = c.click_report
989 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
990 self.check_results(r, expected_counts)
991
953 def test_check_hooks_unknown_good(self):992 def test_check_hooks_unknown_good(self):
954 '''Test check_hooks_unknown()'''993 '''Test check_hooks_unknown()'''
955 self.set_test_manifest("framework", "ubuntu-sdk-13.10")994 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
@@ -982,6 +1021,26 @@
982 name = c._get_check_name('hooks_redflag', app='test-app')1021 name = c._get_check_name('hooks_redflag', app='test-app')
983 self.check_manual_review(r, name)1022 self.check_manual_review(r, name)
9841023
1024 def test_check_hooks_redflagged_payui_snappy_1504(self):
1025 '''Test check_hooks_redflagged() - pay-ui - snappy 15.04'''
1026 self.set_test_pkgfmt("snap", "15.04")
1027 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
1028 c = ClickReviewLint(self.test_name)
1029 c.check_hooks_redflagged()
1030 r = c.click_report
1031 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1032 self.check_results(r, expected_counts)
1033
1034 def test_check_hooks_redflagged_payui_snappy_1604(self):
1035 '''Test check_hooks_redflagged() - pay-ui - snappy 16.04'''
1036 self.set_test_pkgfmt("snap", "16.04")
1037 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
1038 c = ClickReviewLint(self.test_name)
1039 c.check_hooks_redflagged()
1040 r = c.click_report
1041 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
1042 self.check_results(r, expected_counts)
1043
985 def test_check_hooks_redflagged_apparmor_profile(self):1044 def test_check_hooks_redflagged_apparmor_profile(self):
986 '''Test check_hooks_redflagged() - apparmor-profile'''1045 '''Test check_hooks_redflagged() - apparmor-profile'''
987 self.set_test_manifest("framework", "ubuntu-sdk-13.10")1046 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
@@ -1036,6 +1095,28 @@
1036 expected_counts = {'info': 1, 'warn': 0, 'error': 0}1095 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1037 self.check_results(r, expected_counts)1096 self.check_results(r, expected_counts)
10381097
1098 def test_snappy_name_toplevel_1504(self):
1099 '''Test check_snappy_name - toplevel - 15.04'''
1100 self.set_test_pkgfmt("snap", "15.04")
1101 self.set_test_pkg_yaml("name", "foo")
1102 c = ClickReviewLint(self.test_name)
1103 c.is_snap = True
1104 c.check_snappy_name()
1105 r = c.click_report
1106 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1107 self.check_results(r, expected_counts)
1108
1109 def test_snappy_name_toplevel_1604(self):
1110 '''Test check_snappy_name - toplevel - 16.04'''
1111 self.set_test_pkgfmt("snap", "16.04")
1112 self.set_test_pkg_yaml("name", "foo")
1113 c = ClickReviewLint(self.test_name)
1114 c.is_snap = True
1115 c.check_snappy_name()
1116 r = c.click_report
1117 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1118 self.check_results(r, expected_counts)
1119
1039 def test_snappy_name_flat(self):1120 def test_snappy_name_flat(self):
1040 '''Test check_snappy_name - obsoleted flat'''1121 '''Test check_snappy_name - obsoleted flat'''
1041 self.set_test_pkg_yaml("name", "foo.bar")1122 self.set_test_pkg_yaml("name", "foo.bar")
@@ -1092,6 +1173,26 @@
1092 expected_counts = {'info': None, 'warn': 0, 'error': 1}1173 expected_counts = {'info': None, 'warn': 0, 'error': 1}
1093 self.check_results(r, expected_counts)1174 self.check_results(r, expected_counts)
10941175
1176 def test_snappy_version_1504(self):
1177 '''Test check_snappy_version - 15.04'''
1178 self.set_test_pkgfmt("snap", "15.04")
1179 self.set_test_pkg_yaml("version", 1)
1180 c = ClickReviewLint(self.test_name)
1181 c.check_snappy_version()
1182 r = c.click_report
1183 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1184 self.check_results(r, expected_counts)
1185
1186 def test_snappy_version_1604(self):
1187 '''Test check_snappy_version - 16.04'''
1188 self.set_test_pkgfmt("snap", "16.04")
1189 self.set_test_pkg_yaml("version", 1)
1190 c = ClickReviewLint(self.test_name)
1191 c.check_snappy_version()
1192 r = c.click_report
1193 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1194 self.check_results(r, expected_counts)
1195
1095 def test_snappy_version1(self):1196 def test_snappy_version1(self):
1096 '''Test check_snappy_version - integer'''1197 '''Test check_snappy_version - integer'''
1097 self.set_test_pkg_yaml("version", 1)1198 self.set_test_pkg_yaml("version", 1)
@@ -1191,6 +1292,26 @@
1191 expected_counts = {'info': 1, 'warn': 0, 'error': 0}1292 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1192 self.check_results(r, expected_counts)1293 self.check_results(r, expected_counts)
11931294
1295 def test_snappy_type_app_1504(self):
1296 '''Test check_snappy_type - app - 15.04'''
1297 self.set_test_pkgfmt("snap", "15.04")
1298 self.set_test_pkg_yaml("type", "app")
1299 c = ClickReviewLint(self.test_name)
1300 c.check_snappy_type()
1301 r = c.click_report
1302 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1303 self.check_results(r, expected_counts)
1304
1305 def test_snappy_type_app_1604(self):
1306 '''Test check_snappy_type - app - 16.04'''
1307 self.set_test_pkgfmt("snap", "16.04")
1308 self.set_test_pkg_yaml("type", "app")
1309 c = ClickReviewLint(self.test_name)
1310 c.check_snappy_type()
1311 r = c.click_report
1312 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1313 self.check_results(r, expected_counts)
1314
1194 def test_snappy_type_framework(self):1315 def test_snappy_type_framework(self):
1195 '''Test check_snappy_type - framework'''1316 '''Test check_snappy_type - framework'''
1196 self.set_test_pkg_yaml("type", "framework")1317 self.set_test_pkg_yaml("type", "framework")
@@ -1209,6 +1330,24 @@
1209 expected_counts = {'info': 1, 'warn': 0, 'error': 0}1330 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1210 self.check_results(r, expected_counts)1331 self.check_results(r, expected_counts)
12111332
1333 def test_snappy_type_os(self):
1334 '''Test check_snappy_type - os'''
1335 self.set_test_pkg_yaml("type", "os")
1336 c = ClickReviewLint(self.test_name)
1337 c.check_snappy_type()
1338 r = c.click_report
1339 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1340 self.check_results(r, expected_counts)
1341
1342 def test_snappy_type_kernel(self):
1343 '''Test check_snappy_type - kernel'''
1344 self.set_test_pkg_yaml("type", "kernel")
1345 c = ClickReviewLint(self.test_name)
1346 c.check_snappy_type()
1347 r = c.click_report
1348 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1349 self.check_results(r, expected_counts)
1350
1212 def test_snappy_type_redflagged(self):1351 def test_snappy_type_redflagged(self):
1213 '''Test check_snappy_type_redflagged - unspecified'''1352 '''Test check_snappy_type_redflagged - unspecified'''
1214 self.set_test_pkg_yaml("type", None)1353 self.set_test_pkg_yaml("type", None)
@@ -1218,6 +1357,26 @@
1218 expected_counts = {'info': 1, 'warn': 0, 'error': 0}1357 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1219 self.check_results(r, expected_counts)1358 self.check_results(r, expected_counts)
12201359
1360 def test_snappy_type_redflagged_1504(self):
1361 '''Test check_snappy_type_redflagged - unspecified - 15.04'''
1362 self.set_test_pkgfmt("snap", "15.04")
1363 self.set_test_pkg_yaml("type", None)
1364 c = ClickReviewLint(self.test_name)
1365 c.check_snappy_type_redflagged()
1366 r = c.click_report
1367 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1368 self.check_results(r, expected_counts)
1369
1370 def test_snappy_type_redflagged_1604(self):
1371 '''Test check_snappy_type_redflagged - unspecified - 16.04'''
1372 self.set_test_pkgfmt("snap", "16.04")
1373 self.set_test_pkg_yaml("type", None)
1374 c = ClickReviewLint(self.test_name)
1375 c.check_snappy_type_redflagged()
1376 r = c.click_report
1377 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1378 self.check_results(r, expected_counts)
1379
1221 def test_snappy_type_redflagged_app(self):1380 def test_snappy_type_redflagged_app(self):
1222 '''Test check_snappy_type_redflagged - app'''1381 '''Test check_snappy_type_redflagged - app'''
1223 self.set_test_pkg_yaml("type", "app")1382 self.set_test_pkg_yaml("type", "app")
@@ -1236,6 +1395,33 @@
1236 expected_counts = {'info': None, 'warn': 0, 'error': 1}1395 expected_counts = {'info': None, 'warn': 0, 'error': 1}
1237 self.check_results(r, expected_counts)1396 self.check_results(r, expected_counts)
12381397
1398 def test_snappy_type_redflagged_oem(self):
1399 '''Test check_snappy_type_redflagged - oem'''
1400 self.set_test_pkg_yaml("type", "oem")
1401 c = ClickReviewLint(self.test_name)
1402 c.check_snappy_type_redflagged()
1403 r = c.click_report
1404 expected_counts = {'info': None, 'warn': 0, 'error': 1}
1405 self.check_results(r, expected_counts)
1406
1407 def test_snappy_type_redflagged_os(self):
1408 '''Test check_snappy_type_redflagged - os'''
1409 self.set_test_pkg_yaml("type", "os")
1410 c = ClickReviewLint(self.test_name)
1411 c.check_snappy_type_redflagged()
1412 r = c.click_report
1413 expected_counts = {'info': None, 'warn': 0, 'error': 1}
1414 self.check_results(r, expected_counts)
1415
1416 def test_snappy_type_redflagged_kernel(self):
1417 '''Test check_snappy_type_redflagged - kernel'''
1418 self.set_test_pkg_yaml("type", "kernel")
1419 c = ClickReviewLint(self.test_name)
1420 c.check_snappy_type_redflagged()
1421 r = c.click_report
1422 expected_counts = {'info': None, 'warn': 0, 'error': 1}
1423 self.check_results(r, expected_counts)
1424
1239 def test_check_snappy_icon(self):1425 def test_check_snappy_icon(self):
1240 '''Test check_snappy_icon()'''1426 '''Test check_snappy_icon()'''
1241 self.set_test_pkg_yaml("icon", "someicon")1427 self.set_test_pkg_yaml("icon", "someicon")
@@ -1245,6 +1431,26 @@
1245 expected_counts = {'info': 3, 'warn': 0, 'error': 0}1431 expected_counts = {'info': 3, 'warn': 0, 'error': 0}
1246 self.check_results(r, expected_counts)1432 self.check_results(r, expected_counts)
12471433
1434 def test_check_snappy_icon_1504(self):
1435 '''Test check_snappy_icon() - 15.04'''
1436 self.set_test_pkgfmt("snap", "15.04")
1437 self.set_test_pkg_yaml("icon", "someicon")
1438 c = ClickReviewLint(self.test_name)
1439 c.check_snappy_icon()
1440 r = c.click_report
1441 expected_counts = {'info': 3, 'warn': 0, 'error': 0}
1442 self.check_results(r, expected_counts)
1443
1444 def test_check_snappy_icon_1604(self):
1445 '''Test check_snappy_icon() - 16.04'''
1446 self.set_test_pkgfmt("snap", "16.04")
1447 self.set_test_pkg_yaml("icon", "someicon")
1448 c = ClickReviewLint(self.test_name)
1449 c.check_snappy_icon()
1450 r = c.click_report
1451 expected_counts = {'info': 3, 'warn': 0, 'error': 0}
1452 self.check_results(r, expected_counts)
1453
1248 def test_check_snappy_icon_unspecified(self):1454 def test_check_snappy_icon_unspecified(self):
1249 '''Test check_snappy_icon() - unspecified'''1455 '''Test check_snappy_icon() - unspecified'''
1250 self.set_test_pkg_yaml("icon", None)1456 self.set_test_pkg_yaml("icon", None)
@@ -1274,6 +1480,18 @@
12741480
1275 def test_check_snappy_missing_arch(self):1481 def test_check_snappy_missing_arch(self):
1276 '''Test check_snappy_architecture() (missing)'''1482 '''Test check_snappy_architecture() (missing)'''
1483 self.set_test_pkgfmt("snap", "15.04")
1484 self.set_test_pkg_yaml("architectures", None)
1485 c = ClickReviewLint(self.test_name)
1486 c.is_snap = True
1487 c.check_snappy_architecture()
1488 r = c.click_report
1489 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
1490 self.check_results(r, expected_counts)
1491
1492 def test_check_snappy_missing_arch_1604(self):
1493 '''Test check_snappy_architecture() (missing)'''
1494 self.set_test_pkgfmt("snap", "16.04")
1277 self.set_test_pkg_yaml("architectures", None)1495 self.set_test_pkg_yaml("architectures", None)
1278 c = ClickReviewLint(self.test_name)1496 c = ClickReviewLint(self.test_name)
1279 c.is_snap = True1497 c.is_snap = True
@@ -1284,6 +1502,7 @@
12841502
1285 def test_check_snappy_arch_all_deprecated(self):1503 def test_check_snappy_arch_all_deprecated(self):
1286 '''Test check_snappy_architecture() (deprecated, all)'''1504 '''Test check_snappy_architecture() (deprecated, all)'''
1505 self.set_test_pkgfmt("snap", "15.04")
1287 self.set_test_pkg_yaml("architecture", "all")1506 self.set_test_pkg_yaml("architecture", "all")
1288 c = ClickReviewLint(self.test_name)1507 c = ClickReviewLint(self.test_name)
1289 c.is_snap = True1508 c.is_snap = True
@@ -1294,6 +1513,7 @@
12941513
1295 def test_check_snappy_arch_amd64_deprecated(self):1514 def test_check_snappy_arch_amd64_deprecated(self):
1296 '''Test check_snappy_architecture() (deprecated, all)'''1515 '''Test check_snappy_architecture() (deprecated, all)'''
1516 self.set_test_pkgfmt("snap", "15.04")
1297 self.set_test_pkg_yaml("architecture", "amd64")1517 self.set_test_pkg_yaml("architecture", "amd64")
1298 c = ClickReviewLint(self.test_name)1518 c = ClickReviewLint(self.test_name)
1299 c.is_snap = True1519 c.is_snap = True
@@ -1304,6 +1524,7 @@
13041524
1305 def test_check_snappy_arch_all(self):1525 def test_check_snappy_arch_all(self):
1306 '''Test check_snappy_architecture() (all)'''1526 '''Test check_snappy_architecture() (all)'''
1527 self.set_test_pkgfmt("snap", "15.04")
1307 self.set_test_pkg_yaml("architectures", ["all"])1528 self.set_test_pkg_yaml("architectures", ["all"])
1308 c = ClickReviewLint(self.test_name)1529 c = ClickReviewLint(self.test_name)
1309 c.is_snap = True1530 c.is_snap = True
@@ -1314,6 +1535,7 @@
13141535
1315 def test_check_snappy_arch_single_armhf(self):1536 def test_check_snappy_arch_single_armhf(self):
1316 '''Test check_snappy_architecture() (single arch, armhf)'''1537 '''Test check_snappy_architecture() (single arch, armhf)'''
1538 self.set_test_pkgfmt("snap", "15.04")
1317 self.set_test_pkg_yaml("architectures", ["armhf"])1539 self.set_test_pkg_yaml("architectures", ["armhf"])
1318 c = ClickReviewLint(self.test_name)1540 c = ClickReviewLint(self.test_name)
1319 c.is_snap = True1541 c.is_snap = True
@@ -1324,6 +1546,7 @@
13241546
1325 def test_check_snappy_arch_single_arm64(self):1547 def test_check_snappy_arch_single_arm64(self):
1326 '''Test check_snappy_architecture() (single arch, arm64)'''1548 '''Test check_snappy_architecture() (single arch, arm64)'''
1549 self.set_test_pkgfmt("snap", "15.04")
1327 self.set_test_pkg_yaml("architectures", ["arm64"])1550 self.set_test_pkg_yaml("architectures", ["arm64"])
1328 c = ClickReviewLint(self.test_name)1551 c = ClickReviewLint(self.test_name)
1329 c.is_snap = True1552 c.is_snap = True
@@ -1334,6 +1557,7 @@
13341557
1335 def test_check_snappy_arch_single_i386(self):1558 def test_check_snappy_arch_single_i386(self):
1336 '''Test check_snappy_architecture() (single arch, i386)'''1559 '''Test check_snappy_architecture() (single arch, i386)'''
1560 self.set_test_pkgfmt("snap", "15.04")
1337 self.set_test_pkg_yaml("architectures", ["i386"])1561 self.set_test_pkg_yaml("architectures", ["i386"])
1338 c = ClickReviewLint(self.test_name)1562 c = ClickReviewLint(self.test_name)
1339 c.is_snap = True1563 c.is_snap = True
@@ -1344,6 +1568,7 @@
13441568
1345 def test_check_snappy_arch_single_amd64(self):1569 def test_check_snappy_arch_single_amd64(self):
1346 '''Test check_snappy_architecture() (single arch, amd64)'''1570 '''Test check_snappy_architecture() (single arch, amd64)'''
1571 self.set_test_pkgfmt("snap", "15.04")
1347 self.set_test_pkg_yaml("architectures", ["amd64"])1572 self.set_test_pkg_yaml("architectures", ["amd64"])
1348 c = ClickReviewLint(self.test_name)1573 c = ClickReviewLint(self.test_name)
1349 c.is_snap = True1574 c.is_snap = True
@@ -1354,6 +1579,7 @@
13541579
1355 def test_check_snappy_arch_single_nonexistent(self):1580 def test_check_snappy_arch_single_nonexistent(self):
1356 '''Test check_snappy_architecture() (single nonexistent arch)'''1581 '''Test check_snappy_architecture() (single nonexistent arch)'''
1582 self.set_test_pkgfmt("snap", "15.04")
1357 self.set_test_pkg_yaml("architectures", ["nonexistent"])1583 self.set_test_pkg_yaml("architectures", ["nonexistent"])
1358 c = ClickReviewLint(self.test_name)1584 c = ClickReviewLint(self.test_name)
1359 c.is_snap = True1585 c.is_snap = True
@@ -1364,6 +1590,7 @@
13641590
1365 def test_check_snappy_arch_single_multi(self):1591 def test_check_snappy_arch_single_multi(self):
1366 '''Test check_snappy_architecture() (single arch: invalid multi)'''1592 '''Test check_snappy_architecture() (single arch: invalid multi)'''
1593 self.set_test_pkgfmt("snap", "15.04")
1367 self.set_test_pkg_yaml("architectures", "multi")1594 self.set_test_pkg_yaml("architectures", "multi")
1368 c = ClickReviewLint(self.test_name)1595 c = ClickReviewLint(self.test_name)
1369 c.is_snap = True1596 c.is_snap = True
@@ -1374,12 +1601,11 @@
13741601
1375 def test_check_snappy_valid_arch_multi(self):1602 def test_check_snappy_valid_arch_multi(self):
1376 '''Test check_snappy_architecture() (valid multi)'''1603 '''Test check_snappy_architecture() (valid multi)'''
1377 arch = "multi"1604 self.set_test_pkgfmt("snap", "15.04")
1378 self.set_test_pkg_yaml("architectures", ["armhf"])1605 self.set_test_pkg_yaml("architectures", ["armhf"])
1379 self.set_test_control("Architecture", arch)
1380 test_name = "%s_%s_%s.snap" % (self.test_control['Package'],1606 test_name = "%s_%s_%s.snap" % (self.test_control['Package'],
1381 self.test_control['Version'],1607 self.test_control['Version'],
1382 arch)1608 "armhf")
1383 c = ClickReviewLint(test_name)1609 c = ClickReviewLint(test_name)
1384 c.is_snap = True1610 c.is_snap = True
1385 c.check_snappy_architecture()1611 c.check_snappy_architecture()
@@ -1389,9 +1615,9 @@
13891615
1390 def test_check_snappy_valid_arch_multi2(self):1616 def test_check_snappy_valid_arch_multi2(self):
1391 '''Test check_snappy_architecture() (valid multi2)'''1617 '''Test check_snappy_architecture() (valid multi2)'''
1618 self.set_test_pkgfmt("snap", "15.04")
1392 arch = "multi"1619 arch = "multi"
1393 self.set_test_pkg_yaml("architectures", ["armhf", "i386"])1620 self.set_test_pkg_yaml("architectures", ["armhf", "i386"])
1394 self.set_test_control("Architecture", arch)
1395 test_name = "%s_%s_%s.snap" % (self.test_control['Package'],1621 test_name = "%s_%s_%s.snap" % (self.test_control['Package'],
1396 self.test_control['Version'],1622 self.test_control['Version'],
1397 arch)1623 arch)
@@ -1404,9 +1630,9 @@
14041630
1405 def test_check_snappy_invalid_arch_multi_nonexistent(self):1631 def test_check_snappy_invalid_arch_multi_nonexistent(self):
1406 '''Test check_snappy_architecture() (invalid multi)'''1632 '''Test check_snappy_architecture() (invalid multi)'''
1633 self.set_test_pkgfmt("snap", "15.04")
1407 arch = "multi"1634 arch = "multi"
1408 self.set_test_pkg_yaml("architectures", ["armhf", "nonexistent"])1635 self.set_test_pkg_yaml("architectures", ["armhf", "nonexistent"])
1409 self.set_test_control("Architecture", arch)
1410 test_name = "%s_%s_%s.snap" % (self.test_control['Package'],1636 test_name = "%s_%s_%s.snap" % (self.test_control['Package'],
1411 self.test_control['Version'],1637 self.test_control['Version'],
1412 arch)1638 arch)
@@ -1419,9 +1645,9 @@
14191645
1420 def test_check_snappy_invalid_arch_multi_all(self):1646 def test_check_snappy_invalid_arch_multi_all(self):
1421 '''Test check_snappy_architecture() (invalid all)'''1647 '''Test check_snappy_architecture() (invalid all)'''
1648 self.set_test_pkgfmt("snap", "15.04")
1422 arch = "multi"1649 arch = "multi"
1423 self.set_test_pkg_yaml("architectures", ["armhf", "all"])1650 self.set_test_pkg_yaml("architectures", ["armhf", "all"])
1424 self.set_test_control("Architecture", arch)
1425 test_name = "%s_%s_%s.snap" % (self.test_control['Package'],1651 test_name = "%s_%s_%s.snap" % (self.test_control['Package'],
1426 self.test_control['Version'],1652 self.test_control['Version'],
1427 arch)1653 arch)
@@ -1434,13 +1660,14 @@
14341660
1435 def test_check_snappy_invalid_arch_multi_multi(self):1661 def test_check_snappy_invalid_arch_multi_multi(self):
1436 '''Test check_snappy_architecture() (invalid multi)'''1662 '''Test check_snappy_architecture() (invalid multi)'''
1663 self.set_test_pkgfmt("snap", "15.04")
1437 arch = "multi"1664 arch = "multi"
1438 self.set_test_pkg_yaml("architectures", ["multi", "armhf"])1665 self.set_test_pkg_yaml("architectures", ["multi", "armhf"])
1439 self.set_test_control("Architecture", arch)
1440 test_name = "%s_%s_%s.snap" % (self.test_control['Package'],1666 test_name = "%s_%s_%s.snap" % (self.test_control['Package'],
1441 self.test_control['Version'],1667 self.test_control['Version'],
1442 arch)1668 arch)
1443 c = ClickReviewLint(test_name)1669 c = ClickReviewLint(test_name)
1670 c.is_snap = True
1444 c.check_snappy_architecture()1671 c.check_snappy_architecture()
1445 r = c.click_report1672 r = c.click_report
1446 expected_counts = {'info': None, 'warn': 0, 'error': 1}1673 expected_counts = {'info': None, 'warn': 0, 'error': 1}
@@ -1455,6 +1682,26 @@
1455 expected_counts = {'info': 1, 'warn': 0, 'error': 0}1682 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1456 self.check_results(r, expected_counts)1683 self.check_results(r, expected_counts)
14571684
1685 def test_check_snappy_unknown_entries_1504(self):
1686 '''Test check_snappy_unknown_entries - none - 15.04'''
1687 self.set_test_pkgfmt("snap", "15.04")
1688 self.set_test_pkg_yaml("name", "foo")
1689 c = ClickReviewLint(self.test_name)
1690 c.check_snappy_unknown_entries()
1691 r = c.click_report
1692 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1693 self.check_results(r, expected_counts)
1694
1695 def test_check_snappy_unknown_entries_1604(self):
1696 '''Test check_snappy_unknown_entries - none - 16.04'''
1697 self.set_test_pkgfmt("snap", "16.04")
1698 self.set_test_pkg_yaml("name", "foo")
1699 c = ClickReviewLint(self.test_name)
1700 c.check_snappy_unknown_entries()
1701 r = c.click_report
1702 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1703 self.check_results(r, expected_counts)
1704
1458 def test_check_snappy_unknown_entries2(self):1705 def test_check_snappy_unknown_entries2(self):
1459 '''Test check_snappy_unknown_entries - one'''1706 '''Test check_snappy_unknown_entries - one'''
1460 self.set_test_pkg_yaml("nonexistent", "bar")1707 self.set_test_pkg_yaml("nonexistent", "bar")
@@ -1653,6 +1900,33 @@
1653 expected_counts = {'info': 4, 'warn': 0, 'error': 0}1900 expected_counts = {'info': 4, 'warn': 0, 'error': 0}
1654 self.check_results(r, expected_counts)1901 self.check_results(r, expected_counts)
16551902
1903 def test_check_snappy_hashes_1504(self):
1904 '''Test check_snappy_hashes() - 15.04'''
1905 self.set_test_pkgfmt("snap", "15.04")
1906 c = ClickReviewLint(self.test_name)
1907 c.is_snap = True
1908 yaml = self._create_hashes_yaml()
1909 c.pkg_files = self._test_pkg_files
1910 self.set_test_hashes_yaml(yaml)
1911 c.check_snappy_hashes()
1912 r = c.click_report
1913 expected_counts = {'info': 4, 'warn': 0, 'error': 0}
1914 self.check_results(r, expected_counts)
1915
1916 def test_check_snappy_hashes_1604(self):
1917 '''Test check_snappy_hashes() - 16.04'''
1918 self.set_test_pkgfmt("snap", "16.04")
1919 c = ClickReviewLint(self.test_name)
1920 c.is_snap = True
1921 yaml = self._create_hashes_yaml()
1922 c.pkg_files = self._test_pkg_files
1923 self.set_test_hashes_yaml(yaml)
1924 c.check_snappy_hashes()
1925 r = c.click_report
1926 # this should be empty with this package format
1927 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
1928 self.check_results(r, expected_counts)
1929
1656 def test_check_snappy_hashes_archive_files_missing_name(self):1930 def test_check_snappy_hashes_archive_files_missing_name(self):
1657 '''Test check_snappy_hashes() - missing name'''1931 '''Test check_snappy_hashes() - missing name'''
1658 c = ClickReviewLint(self.test_name)1932 c = ClickReviewLint(self.test_name)
16591933
=== modified file 'clickreviews/tests/test_cr_online_accounts.py'
--- clickreviews/tests/test_cr_online_accounts.py 2015-11-27 09:04:43 +0000
+++ clickreviews/tests/test_cr_online_accounts.py 2015-12-01 15:03:49 +0000
@@ -270,6 +270,30 @@
270 expected_counts = {'info': 4, 'warn': 0, 'error': 0}270 expected_counts = {'info': 4, 'warn': 0, 'error': 0}
271 self.check_results(r, expected_counts)271 self.check_results(r, expected_counts)
272272
273 def test_check_application_snappy_1504(self):
274 '''Test check_application() - snappy 15.04'''
275 self.set_test_pkgfmt("snap", "15.04")
276 xml = self._stub_application()
277 # print(etree.tostring(xml))
278 self.set_test_account(self.default_appname, "account-application", xml)
279 c = ClickReviewAccounts(self.test_name)
280 c.check_application()
281 r = c.click_report
282 expected_counts = {'info': 4, 'warn': 0, 'error': 0}
283 self.check_results(r, expected_counts)
284
285 def test_check_application_snappy_1604(self):
286 '''Test check_application() - snappy 16.04'''
287 self.set_test_pkgfmt("snap", "16.04")
288 xml = self._stub_application()
289 # print(etree.tostring(xml))
290 self.set_test_account(self.default_appname, "account-application", xml)
291 c = ClickReviewAccounts(self.test_name)
292 c.check_application()
293 r = c.click_report
294 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
295 self.check_results(r, expected_counts)
296
273 def test_check_application_not_specified(self):297 def test_check_application_not_specified(self):
274 '''Test check_application() - not specified'''298 '''Test check_application() - not specified'''
275 c = ClickReviewAccounts(self.test_name)299 c = ClickReviewAccounts(self.test_name)
276300
=== modified file 'clickreviews/tests/test_cr_push_helper.py'
--- clickreviews/tests/test_cr_push_helper.py 2015-10-16 02:54:07 +0000
+++ clickreviews/tests/test_cr_push_helper.py 2015-12-01 15:03:49 +0000
@@ -201,3 +201,23 @@
201 r = c.click_report201 r = c.click_report
202 expected_counts = {'info': None, 'warn': 0, 'error': 1}202 expected_counts = {'info': None, 'warn': 0, 'error': 1}
203 self.check_results(r, expected_counts)203 self.check_results(r, expected_counts)
204
205 def test_check_valid_exec_snappy_1504(self):
206 '''Test check_valid() - exec - snappy 15.04'''
207 self.set_test_pkgfmt("snap", "15.04")
208 self.set_test_push_helper(self.default_appname, "exec", "foo")
209 c = ClickReviewPushHelper(self.test_name)
210 c.check_valid()
211 r = c.click_report
212 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
213 self.check_results(r, expected_counts)
214
215 def test_check_valid_exec_snappy_1604(self):
216 '''Test check_valid() - exec - snappy 16.04'''
217 self.set_test_pkgfmt("snap", "16.04")
218 self.set_test_push_helper(self.default_appname, "exec", "foo")
219 c = ClickReviewPushHelper(self.test_name)
220 c.check_valid()
221 r = c.click_report
222 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
223 self.check_results(r, expected_counts)
204224
=== modified file 'clickreviews/tests/test_cr_scope.py'
--- clickreviews/tests/test_cr_scope.py 2015-12-01 07:45:05 +0000
+++ clickreviews/tests/test_cr_scope.py 2015-12-01 15:03:49 +0000
@@ -281,3 +281,27 @@
281 r = c.click_report281 r = c.click_report
282 expected_counts = {'info': None, 'warn': 0, 'error': 1}282 expected_counts = {'info': None, 'warn': 0, 'error': 1}
283 self.check_results(r, expected_counts)283 self.check_results(r, expected_counts)
284
285 def test_check_scope_ini_snappy_1504(self):
286 '''Test check_scope_ini() - snappy 15.04'''
287 self.set_test_pkgfmt("snap", "15.04")
288 scope = self._create_scope(self._stub_config())
289
290 self.set_test_scope(self.default_appname, scope)
291 c = ClickReviewScope(self.test_name)
292 c.check_scope_ini()
293 r = c.click_report
294 expected_counts = {'info': 4, 'warn': 0, 'error': 0}
295 self.check_results(r, expected_counts)
296
297 def test_check_scope_ini_snappy_1604(self):
298 '''Test check_scope_ini() - snappy 16.04'''
299 self.set_test_pkgfmt("snap", "16.04")
300 scope = self._create_scope(self._stub_config())
301
302 self.set_test_scope(self.default_appname, scope)
303 c = ClickReviewScope(self.test_name)
304 c.check_scope_ini()
305 r = c.click_report
306 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
307 self.check_results(r, expected_counts)
284308
=== modified file 'clickreviews/tests/test_cr_security.py'
--- clickreviews/tests/test_cr_security.py 2015-11-11 15:40:49 +0000
+++ clickreviews/tests/test_cr_security.py 2015-12-01 15:03:49 +0000
@@ -41,14 +41,41 @@
4141
42 def test_check_policy_version_vendor(self):42 def test_check_policy_version_vendor(self):
43 '''Test check_policy_version() - valid'''43 '''Test check_policy_version() - valid'''
44 for v in [1.0]: # update when have more vendor policy44 c = ClickReviewSecurity(self.test_name)
45 c = ClickReviewSecurity(self.test_name)45 self.set_test_security_manifest(self.default_appname,
46 self.set_test_security_manifest(self.default_appname,46 "policy_version", 1.0)
47 "policy_version", v)47 c.check_policy_version()
48 c.check_policy_version()48 report = c.click_report
49 report = c.click_report49 expected_counts = {'info': 3, 'warn': 0, 'error': 0}
50 expected_counts = {'info': 3, 'warn': 0, 'error': 0}50 self.check_results(report, expected_counts)
51 self.check_results(report, expected_counts)51
52 def test_check_policy_version_vendor_snappy_1504(self):
53 '''Test check_policy_version() - valid - snappy 15.04'''
54 self.set_test_pkgfmt("snap", "15.04")
55 n = "bin/%s" % self.default_appname
56 self._set_yaml_binary([('caps', ['network-client'])], name=n)
57 c = ClickReviewSecurity(self.test_name)
58 self.set_test_security_manifest("binaries/%s" % n,
59 "policy_version", 1.0)
60 c.check_policy_version()
61 report = c.click_report
62 expected_counts = {'info': 3, 'warn': 0, 'error': 0}
63 self.check_results(report, expected_counts)
64
65 def test_check_policy_version_vendor_snappy_1604(self):
66 '''Test check_policy_version() - valid - snappy 16.04'''
67 self.set_test_pkgfmt("snap", "16.04")
68 n = "bin/%s" % self.default_appname
69 self._set_yaml_binary([('caps', ['network-client'])], name=n)
70 c = ClickReviewSecurity(self.test_name)
71 self.set_test_security_manifest("binaries/%s" % n,
72 "policy_vendor", "ubuntu-core")
73 self.set_test_security_manifest("binaries/%s" % n,
74 "policy_version", 15.04)
75 c.check_policy_version()
76 report = c.click_report
77 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
78 self.check_results(report, expected_counts)
5279
53 def test_check_policy_version_highest(self):80 def test_check_policy_version_highest(self):
54 '''Test check_policy_version() - highest'''81 '''Test check_policy_version() - highest'''
@@ -273,6 +300,32 @@
273 expected_counts = {'info': 2, 'warn': 0, 'error': 0}300 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
274 self.check_results(report, expected_counts)301 self.check_results(report, expected_counts)
275302
303 def test_check_policy_vendor_ubuntu_1504(self):
304 '''Test check_policy_vendor() - ubuntu - 15.04'''
305 self.set_test_pkgfmt("snap", "15.04")
306 n = "bin/%s" % self.default_appname
307 self._set_yaml_binary([('caps', ['network-client'])], name=n)
308 c = ClickReviewSecurity(self.test_name)
309 self.set_test_security_manifest("binaries/%s" % n,
310 "policy_vendor", "ubuntu")
311 c.check_policy_vendor()
312 report = c.click_report
313 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
314 self.check_results(report, expected_counts)
315
316 def test_check_policy_vendor_ubuntu_1604(self):
317 '''Test check_policy_vendor() - ubuntu - 16.04'''
318 self.set_test_pkgfmt("snap", "16.04")
319 n = "bin/%s" % self.default_appname
320 self._set_yaml_binary([('caps', ['network-client'])], name=n)
321 c = ClickReviewSecurity(self.test_name)
322 self.set_test_security_manifest("binaries/%s" % n,
323 "policy_vendor", "ubuntu")
324 c.check_policy_vendor()
325 report = c.click_report
326 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
327 self.check_results(report, expected_counts)
328
276 def test_check_policy_vendor_ubuntu(self):329 def test_check_policy_vendor_ubuntu(self):
277 '''Test check_policy_vendor() - ubuntu'''330 '''Test check_policy_vendor() - ubuntu'''
278 c = ClickReviewSecurity(self.test_name)331 c = ClickReviewSecurity(self.test_name)
@@ -975,18 +1028,36 @@
975 self.set_test_security_manifest(self.default_appname,1028 self.set_test_security_manifest(self.default_appname,
976 "policy_groups",1029 "policy_groups",
977 ["push-notification-client"])1030 ["push-notification-client"])
1031 self.set_test_security_manifest(self.default_appname,
1032 "template", "ubuntu-push-helper")
978 c = ClickReviewSecurity(self.test_name)1033 c = ClickReviewSecurity(self.test_name)
979 c.check_policy_groups_push_helpers()1034 c.check_policy_groups_push_helpers()
980 report = c.click_report1035 report = c.click_report
981 expected_counts = {'info': 1, 'warn': 0, 'error': 0}1036 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
982 self.check_results(report, expected_counts)1037 self.check_results(report, expected_counts)
9831038
1039 def test_check_policy_groups_pushhelper_wrong_template(self):
1040 '''Test check_policy_groups_pushhelper()'''
1041 self.set_test_push_helper(self.default_appname, "exec", "foo")
1042 self.set_test_security_manifest(self.default_appname,
1043 "policy_groups",
1044 ["push-notification-client"])
1045 self.set_test_security_manifest(self.default_appname,
1046 "template", "ubuntu-sdk")
1047 c = ClickReviewSecurity(self.test_name)
1048 c.check_policy_groups_push_helpers()
1049 report = c.click_report
1050 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
1051 self.check_results(report, expected_counts)
1052
984 def test_check_policy_groups_pushhelper_missing(self):1053 def test_check_policy_groups_pushhelper_missing(self):
985 '''Test check_policy_groups_pushhelper - missing'''1054 '''Test check_policy_groups_pushhelper - missing'''
986 self.set_test_push_helper(self.default_appname, "exec", "foo")1055 self.set_test_push_helper(self.default_appname, "exec", "foo")
987 self.set_test_security_manifest(self.default_appname,1056 self.set_test_security_manifest(self.default_appname,
988 "policy_groups",1057 "policy_groups",
989 None)1058 None)
1059 self.set_test_security_manifest(self.default_appname,
1060 "template", "ubuntu-push-helper")
990 c = ClickReviewSecurity(self.test_name)1061 c = ClickReviewSecurity(self.test_name)
991 c.check_policy_groups_push_helpers()1062 c.check_policy_groups_push_helpers()
992 report = c.click_report1063 report = c.click_report
@@ -1001,6 +1072,8 @@
1001 ["video_files",1072 ["video_files",
1002 "networking",1073 "networking",
1003 "push-notification-client"])1074 "push-notification-client"])
1075 self.set_test_security_manifest(self.default_appname,
1076 "template", "ubuntu-push-helper")
1004 c = ClickReviewSecurity(self.test_name)1077 c = ClickReviewSecurity(self.test_name)
1005 c.check_policy_groups_push_helpers()1078 c.check_policy_groups_push_helpers()
1006 report = c.click_report1079 report = c.click_report
@@ -1014,64 +1087,14 @@
1014 "policy_groups",1087 "policy_groups",
1015 ["networking",1088 ["networking",
1016 "push-notification-client"])1089 "push-notification-client"])
1090 self.set_test_security_manifest(self.default_appname,
1091 "template", "ubuntu-push-helper")
1017 c = ClickReviewSecurity(self.test_name)1092 c = ClickReviewSecurity(self.test_name)
1018 c.check_policy_groups_push_helpers()1093 c.check_policy_groups_push_helpers()
1019 report = c.click_report1094 report = c.click_report
1020 expected_counts = {'info': None, 'warn': 0, 'error': 1}1095 expected_counts = {'info': None, 'warn': 0, 'error': 1}
1021 self.check_results(report, expected_counts)1096 self.check_results(report, expected_counts)
10221097
1023 def test_check_template_pushhelper(self):
1024 '''Test check_template_pushhelper'''
1025 self.set_test_push_helper(self.default_appname, "exec", "foo")
1026 self.set_test_security_manifest(self.default_appname,
1027 "template", "ubuntu-push-helper")
1028 self.set_test_security_manifest(self.default_appname,
1029 "policy_groups",
1030 ["push-notification-client"])
1031 c = ClickReviewSecurity(self.test_name)
1032 c.check_template_push_helpers()
1033 report = c.click_report
1034 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1035 self.check_results(report, expected_counts)
1036
1037 def test_check_template_pushhelper_no_hook(self):
1038 '''Test check_template_pushhelper'''
1039 self.set_test_security_manifest(self.default_appname,
1040 "template", "ubuntu-sdk")
1041 c = ClickReviewSecurity(self.test_name)
1042 c.check_template_push_helpers()
1043 report = c.click_report
1044 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
1045 self.check_results(report, expected_counts)
1046
1047 def test_check_template_pushhelper_wrong_template(self):
1048 '''Test check_template_pushhelper - wrong template'''
1049 self.set_test_push_helper(self.default_appname, "exec", "foo")
1050 self.set_test_security_manifest(self.default_appname,
1051 "template", "ubuntu-webapp")
1052 self.set_test_security_manifest(self.default_appname,
1053 "policy_groups",
1054 ["push-notification-client"])
1055 c = ClickReviewSecurity(self.test_name)
1056 c.check_template_push_helpers()
1057 report = c.click_report
1058 expected_counts = {'info': None, 'warn': 0, 'error': 1}
1059 self.check_results(report, expected_counts)
1060
1061 def test_check_template_pushhelper_wrong_template2(self):
1062 '''Test check_template_pushhelper - default template'''
1063 self.set_test_push_helper(self.default_appname, "exec", "foo")
1064 self.set_test_security_manifest(self.default_appname,
1065 "template", None)
1066 self.set_test_security_manifest(self.default_appname,
1067 "policy_groups",
1068 ["push-notification-client"])
1069 c = ClickReviewSecurity(self.test_name)
1070 c.check_template_push_helpers()
1071 report = c.click_report
1072 expected_counts = {'info': None, 'warn': 0, 'error': 1}
1073 self.check_results(report, expected_counts)
1074
1075 def test_check_peer_hooks(self):1098 def test_check_peer_hooks(self):
1076 '''Test check_peer_hooks()'''1099 '''Test check_peer_hooks()'''
1077 c = ClickReviewSecurity(self.test_name)1100 c = ClickReviewSecurity(self.test_name)
@@ -1267,6 +1290,25 @@
1267 expected_counts = {'info': 5, 'warn': 0, 'error': 0}1290 expected_counts = {'info': 5, 'warn': 0, 'error': 0}
1268 self.check_results(report, expected_counts)1291 self.check_results(report, expected_counts)
12691292
1293 def test_check_apparmor_profile_1604(self):
1294 '''Test check_apparmor_profile() - snappy 16.04'''
1295 policy = '''
1296###VAR###
1297###PROFILEATTACH### {
1298 #include <abstractions/base>
1299 # Read-only for the install directory
1300 @{CLICK_DIR}/@{APP_PKGNAME}/@{APP_VERSION}/** mrklix,
1301 @{INSTALL_DIR}/@{APP_PKGNAME}/@{APP_VERSION}/** mrklix,
1302}
1303'''
1304 self.set_test_security_profile(self.default_appname, policy)
1305 c = ClickReviewSecurity(self.test_name)
1306 self.set_test_pkgfmt("snap", "16.04")
1307 c.check_apparmor_profile()
1308 report = c.click_report
1309 expected_counts = {'info': 6, 'warn': 0, 'error': 0}
1310 self.check_results(report, expected_counts)
1311
1270 def test_check_apparmor_profile_missing_var(self):1312 def test_check_apparmor_profile_missing_var(self):
1271 '''Test check_apparmor_profile() - missing ###VAR###'''1313 '''Test check_apparmor_profile() - missing ###VAR###'''
1272 policy = '''1314 policy = '''
@@ -1366,6 +1408,30 @@
1366 expected_counts = {'info': 1, 'warn': 0, 'error': 0}1408 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1367 self.check_results(report, expected_counts)1409 self.check_results(report, expected_counts)
13681410
1411 def test_check_security_template_nondefault_1504(self):
1412 '''Test check_security_template() - nondefault - 15.04'''
1413 self.set_test_pkgfmt("snap", "15.04")
1414 self.set_test_security_manifest(self.default_appname,
1415 "template", "nondefault")
1416 self._set_yaml_binary([('security-template', 'nondefault')])
1417 c = ClickReviewSecurity(self.test_name)
1418 c.check_security_template()
1419 report = c.click_report
1420 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1421 self.check_results(report, expected_counts)
1422
1423 def test_check_security_template_nondefault_1604(self):
1424 '''Test check_security_template() - nondefault - 16.04'''
1425 self.set_test_pkgfmt("snap", "16.04")
1426 self.set_test_security_manifest(self.default_appname,
1427 "template", "nondefault")
1428 self._set_yaml_binary([('security-template', 'nondefault')])
1429 c = ClickReviewSecurity(self.test_name)
1430 c.check_security_template()
1431 report = c.click_report
1432 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1433 self.check_results(report, expected_counts)
1434
1369 def test_check_security_template_bad(self):1435 def test_check_security_template_bad(self):
1370 '''Test check_security_template() - {}'''1436 '''Test check_security_template() - {}'''
1371 self._set_yaml_binary([('security-template', {})])1437 self._set_yaml_binary([('security-template', {})])
@@ -1455,6 +1521,33 @@
1455 expected_counts = {'info': 5, 'warn': 0, 'error': 0}1521 expected_counts = {'info': 5, 'warn': 0, 'error': 0}
1456 self.check_results(report, expected_counts)1522 self.check_results(report, expected_counts)
14571523
1524 def test_check_security_yaml_and_click_snappy_1504(self):
1525 '''Test check_security_yaml_and_click() - snappy 15.04'''
1526 self.set_test_pkgfmt("snap", "15.04")
1527 self._set_yaml_binary([('caps', ['networking'])],
1528 name="bin/%s" % self.default_appname)
1529 c = ClickReviewSecurity(self.test_name)
1530
1531 # update the manifest and test_manifest
1532 c.manifest["hooks"][self.default_appname]['bin-path'] = "bin/path"
1533
1534 c.check_security_yaml_and_click()
1535 report = c.click_report
1536 expected_counts = {'info': 5, 'warn': 0, 'error': 0}
1537 self.check_results(report, expected_counts)
1538
1539 def test_check_security_yaml_and_click_snappy_1604(self):
1540 '''Test check_security_yaml_and_click() - snappy 16.04'''
1541 self.set_test_pkgfmt("snap", "16.04")
1542 self._set_yaml_binary([('caps', ['networking'])],
1543 name="bin/%s" % self.default_appname)
1544 c = ClickReviewSecurity(self.test_name)
1545
1546 c.check_security_yaml_and_click()
1547 report = c.click_report
1548 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
1549 self.check_results(report, expected_counts)
1550
1458 def test_check_security_yaml_and_click_name_exec(self):1551 def test_check_security_yaml_and_click_name_exec(self):
1459 '''Test check_security_yaml_and_click() - uses exec'''1552 '''Test check_security_yaml_and_click() - uses exec'''
1460 self._set_yaml_binary([('caps', ['networking']),1553 self._set_yaml_binary([('caps', ['networking']),
@@ -1923,6 +2016,28 @@
1923 expected_counts = {'info': 1, 'warn': 0, 'error': 0}2016 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1924 self.check_results(report, expected_counts)2017 self.check_results(report, expected_counts)
19252018
2019 def test_check_security_yaml_override_and_click_1504(self):
2020 '''Test check_security_yaml_override_and_click() - 15.04'''
2021 self.set_test_pkgfmt("snap", "15.04")
2022 self.set_test_security_manifest(self.default_appname, "template", None)
2023 self._set_yaml_binary([])
2024 c = ClickReviewSecurity(self.test_name)
2025 c.check_security_yaml_override_and_click()
2026 report = c.click_report
2027 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
2028 self.check_results(report, expected_counts)
2029
2030 def test_check_security_yaml_override_and_click_1604(self):
2031 '''Test check_security_yaml_override_and_click() - 16.04'''
2032 self.set_test_pkgfmt("snap", "16.04")
2033 self.set_test_security_manifest(self.default_appname, "template", None)
2034 self._set_yaml_binary([])
2035 c = ClickReviewSecurity(self.test_name)
2036 c.check_security_yaml_override_and_click()
2037 report = c.click_report
2038 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
2039 self.check_results(report, expected_counts)
2040
1926 def test_check_security_yaml_override_and_click_bad(self):2041 def test_check_security_yaml_override_and_click_bad(self):
1927 '''Test check_security_yaml_override_and_click() - bad'''2042 '''Test check_security_yaml_override_and_click() - bad'''
1928 self.set_test_security_manifest(self.default_appname, "template", None)2043 self.set_test_security_manifest(self.default_appname, "template", None)
@@ -1945,8 +2060,31 @@
1945 expected_counts = {'info': 1, 'warn': 0, 'error': 0}2060 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1946 self.check_results(report, expected_counts)2061 self.check_results(report, expected_counts)
19472062
2063 def test_check_security_yaml_override_1504(self):
2064 '''Test check_security_yaml_override() - 15.04'''
2065 self.set_test_pkgfmt("snap", "15.04")
2066 self.set_test_security_manifest(self.default_appname, "template", None)
2067 self._set_yaml_binary([])
2068 c = ClickReviewSecurity(self.test_name)
2069 c.check_security_yaml_override()
2070 report = c.click_report
2071 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
2072 self.check_results(report, expected_counts)
2073
2074 def test_check_security_yaml_override_1604(self):
2075 '''Test check_security_yaml_override() - 16.04'''
2076 self.set_test_pkgfmt("snap", "16.04")
2077 self.set_test_security_manifest(self.default_appname, "template", None)
2078 self._set_yaml_binary([])
2079 c = ClickReviewSecurity(self.test_name)
2080 c.check_security_yaml_override()
2081 report = c.click_report
2082 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
2083 self.check_results(report, expected_counts)
2084
1948 def test_check_security_yaml_override2(self):2085 def test_check_security_yaml_override2(self):
1949 '''Test check_security_yaml_override() - seccomp/apparmor specified'''2086 '''Test check_security_yaml_override() - seccomp/apparmor specified'''
2087 self.set_test_pkgfmt("snap", "15.04")
1950 self._set_yaml_binary([('security-override', {'apparmor': 'aa',2088 self._set_yaml_binary([('security-override', {'apparmor': 'aa',
1951 'seccomp': 'sc'})],2089 'seccomp': 'sc'})],
1952 name=self.default_appname)2090 name=self.default_appname)
@@ -1956,6 +2094,84 @@
1956 expected_counts = {'info': 1, 'warn': 0, 'error': 0}2094 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
1957 self.check_results(report, expected_counts)2095 self.check_results(report, expected_counts)
19582096
2097 def test_check_security_yaml_override3(self):
2098 '''Test check_security_yaml_override() - seccomp/apparmor specified
2099 with 16.04
2100 '''
2101 self.set_test_pkgfmt("snap", "16.04")
2102 self._set_yaml_binary([('security-override', {'apparmor': 'aa',
2103 'seccomp': 'sc'})],
2104 name=self.default_appname)
2105 c = ClickReviewSecurity(self.test_name)
2106 c.check_security_yaml_override()
2107 report = c.click_report
2108 expected_counts = {'info': None, 'warn': 0, 'error': 2}
2109 self.check_results(report, expected_counts)
2110
2111 def test_check_security_yaml_override4(self):
2112 '''Test check_security_yaml_override() - syscalls specified with
2113 15.04
2114 '''
2115 self.set_test_pkgfmt("snap", "15.04")
2116 self._set_yaml_binary([('security-override', {'syscalls': 'foo'})],
2117 name=self.default_appname)
2118 c = ClickReviewSecurity(self.test_name)
2119 c.check_security_yaml_override()
2120 report = c.click_report
2121 expected_counts = {'info': None, 'warn': 0, 'error': 1}
2122 self.check_results(report, expected_counts)
2123
2124 def test_check_security_yaml_override5(self):
2125 '''Test check_security_yaml_override() - syscalls specified with
2126 16.04
2127 '''
2128 self.set_test_pkgfmt("snap", "16.04")
2129 self._set_yaml_binary([('security-override', {'syscalls': 'foo'})],
2130 name=self.default_appname)
2131 c = ClickReviewSecurity(self.test_name)
2132 c.check_security_yaml_override()
2133 report = c.click_report
2134 # the error is security-override not allowed
2135 expected_counts = {'info': 1, 'warn': 0, 'error': 1}
2136 self.check_results(report, expected_counts)
2137
2138 def test_check_security_yaml_override6(self):
2139 '''Test check_security_yaml_override() - read-paths'''
2140 self.set_test_pkgfmt("snap", "16.04")
2141 self._set_yaml_binary([('security-override', {'read-paths': '/foo'})],
2142 name=self.default_appname)
2143 c = ClickReviewSecurity(self.test_name)
2144 c.check_security_yaml_override()
2145 report = c.click_report
2146 # the error is security-override not allowed
2147 expected_counts = {'info': 1, 'warn': 0, 'error': 1}
2148 self.check_results(report, expected_counts)
2149
2150 def test_check_security_yaml_override7(self):
2151 '''Test check_security_yaml_override() - write-paths'''
2152 self.set_test_pkgfmt("snap", "16.04")
2153 self._set_yaml_binary([('security-override', {'write-paths': '/foo'})],
2154 name=self.default_appname)
2155 c = ClickReviewSecurity(self.test_name)
2156 c.check_security_yaml_override()
2157 report = c.click_report
2158 # the error is security-override not allowed
2159 expected_counts = {'info': 1, 'warn': 0, 'error': 1}
2160 self.check_results(report, expected_counts)
2161
2162 def test_check_security_yaml_override8(self):
2163 '''Test check_security_yaml_override() - abstractions'''
2164 self.set_test_pkgfmt("snap", "16.04")
2165 self._set_yaml_binary([('security-override',
2166 {'abstractions': '/foo'})],
2167 name=self.default_appname)
2168 c = ClickReviewSecurity(self.test_name)
2169 c.check_security_yaml_override()
2170 report = c.click_report
2171 # the error is security-override not allowed
2172 expected_counts = {'info': 1, 'warn': 0, 'error': 1}
2173 self.check_results(report, expected_counts)
2174
1959 def test_check_security_yaml_override_missing1(self):2175 def test_check_security_yaml_override_missing1(self):
1960 '''Test check_security_yaml_override() - missing apparmor'''2176 '''Test check_security_yaml_override() - missing apparmor'''
1961 self._set_yaml_binary([('security-override', {'seccomp': 'sc'})],2177 self._set_yaml_binary([('security-override', {'seccomp': 'sc'})],
@@ -2049,6 +2265,34 @@
2049 expected_counts = {'info': 1, 'warn': 0, 'error': 0}2265 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
2050 self.check_results(report, expected_counts)2266 self.check_results(report, expected_counts)
20512267
2268 def test_check_template_online_account_provider_1504(self):
2269 '''Test check_template_online_account_provider - 15.04'''
2270 self.set_test_pkgfmt("snap", "15.04")
2271 self.set_test_account(self.default_appname, "account-provider", "foo")
2272 self.set_test_security_manifest(self.default_appname,
2273 "template", "ubuntu-account-plugin")
2274 self.set_test_security_manifest(self.default_appname,
2275 "policy_groups", ["accounts"])
2276 c = ClickReviewSecurity(self.test_name)
2277 c.check_template_online_accounts_provider()
2278 report = c.click_report
2279 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
2280 self.check_results(report, expected_counts)
2281
2282 def test_check_template_online_account_provider_1604(self):
2283 '''Test check_template_online_account_provider - 16.04'''
2284 self.set_test_pkgfmt("snap", "16.04")
2285 self.set_test_account(self.default_appname, "account-provider", "foo")
2286 self.set_test_security_manifest(self.default_appname,
2287 "template", "ubuntu-account-plugin")
2288 self.set_test_security_manifest(self.default_appname,
2289 "policy_groups", ["accounts"])
2290 c = ClickReviewSecurity(self.test_name)
2291 c.check_template_online_accounts_provider()
2292 report = c.click_report
2293 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
2294 self.check_results(report, expected_counts)
2295
2052 def test_check_template_online_account_provider_no_hook(self):2296 def test_check_template_online_account_provider_no_hook(self):
2053 '''Test check_template_online_account_provider'''2297 '''Test check_template_online_account_provider'''
2054 self.set_test_security_manifest(self.default_appname,2298 self.set_test_security_manifest(self.default_appname,
@@ -2099,6 +2343,36 @@
2099 expected_counts = {'info': 1, 'warn': 0, 'error': 0}2343 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
2100 self.check_results(report, expected_counts)2344 self.check_results(report, expected_counts)
21012345
2346 def test_check_template_online_account_qml_plugin_1504(self):
2347 '''Test check_template_online_account_qml_plugin - 15.04'''
2348 self.set_test_pkgfmt("snap", "15.04")
2349 self.set_test_account(self.default_appname,
2350 "account-qml-plugin", "foo")
2351 self.set_test_security_manifest(self.default_appname,
2352 "template", "ubuntu-account-plugin")
2353 self.set_test_security_manifest(self.default_appname,
2354 "policy_groups", ["accounts"])
2355 c = ClickReviewSecurity(self.test_name)
2356 c.check_template_online_accounts_qml_plugin()
2357 report = c.click_report
2358 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
2359 self.check_results(report, expected_counts)
2360
2361 def test_check_template_online_account_qml_plugin_1604(self):
2362 '''Test check_template_online_account_qml_plugin - 16.04'''
2363 self.set_test_pkgfmt("snap", "16.04")
2364 self.set_test_account(self.default_appname,
2365 "account-qml-plugin", "foo")
2366 self.set_test_security_manifest(self.default_appname,
2367 "template", "ubuntu-account-plugin")
2368 self.set_test_security_manifest(self.default_appname,
2369 "policy_groups", ["accounts"])
2370 c = ClickReviewSecurity(self.test_name)
2371 c.check_template_online_accounts_qml_plugin()
2372 report = c.click_report
2373 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
2374 self.check_results(report, expected_counts)
2375
2102 def test_check_template_online_account_qml_plugin_no_hook(self):2376 def test_check_template_online_account_qml_plugin_no_hook(self):
2103 '''Test check_template_online_account_qml_plugin'''2377 '''Test check_template_online_account_qml_plugin'''
2104 self.set_test_security_manifest(self.default_appname,2378 self.set_test_security_manifest(self.default_appname,
@@ -2139,8 +2413,6 @@
21392413
2140 def test_check_policy_groups_ubuntu_account_plugin_no_hook(self):2414 def test_check_policy_groups_ubuntu_account_plugin_no_hook(self):
2141 '''Test check_policy_groups_ubuntu_account_plugin() - no hook'''2415 '''Test check_policy_groups_ubuntu_account_plugin() - no hook'''
2142 self.set_test_security_manifest(self.default_appname,
2143 "template", "ubuntu-account-plugin")
2144 c = ClickReviewSecurity(self.test_name)2416 c = ClickReviewSecurity(self.test_name)
2145 c.check_policy_groups_ubuntu_account_plugin()2417 c.check_policy_groups_ubuntu_account_plugin()
2146 report = c.click_report2418 report = c.click_report
21472419
=== modified file 'clickreviews/tests/test_cr_url_dispatcher.py'
--- clickreviews/tests/test_cr_url_dispatcher.py 2015-10-16 02:54:07 +0000
+++ clickreviews/tests/test_cr_url_dispatcher.py 2015-12-01 15:03:49 +0000
@@ -255,3 +255,27 @@
255 r = c.click_report255 r = c.click_report
256 expected_counts = {'info': None, 'warn': 0, 'error': 1}256 expected_counts = {'info': None, 'warn': 0, 'error': 1}
257 self.check_results(r, expected_counts)257 self.check_results(r, expected_counts)
258
259 def test_check_required_snappy_1504(self):
260 '''Test check_required() - has protocol - snappy 15.04'''
261 self.set_test_pkgfmt("snap", "15.04")
262 self.set_test_url_dispatcher(self.default_appname,
263 key="protocol",
264 value="some-protocol")
265 c = ClickReviewUrlDispatcher(self.test_name)
266 c.check_required()
267 r = c.click_report
268 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
269 self.check_results(r, expected_counts)
270
271 def test_check_required_snappy_1604(self):
272 '''Test check_required() - has protocol - snappy 16.04'''
273 self.set_test_pkgfmt("snap", "16.04")
274 self.set_test_url_dispatcher(self.default_appname,
275 key="protocol",
276 value="some-protocol")
277 c = ClickReviewUrlDispatcher(self.test_name)
278 c.check_required()
279 r = c.click_report
280 expected_counts = {'info': 0, 'warn': 0, 'error': 0}
281 self.check_results(r, expected_counts)
258282
=== modified file 'clickreviews/tests/utils.py'
--- clickreviews/tests/utils.py 2015-10-21 22:12:25 +0000
+++ clickreviews/tests/utils.py 2015-12-01 15:03:49 +0000
@@ -22,31 +22,36 @@
22import tempfile22import tempfile
2323
2424
25def make_package(name='test', package_format='click', package_types=None,25def make_package(name='test', pkgfmt_type='click', pkgfmt_version='0.4',
26 version='1.0', title="An application",26 package_types=None, version='1.0', title="An application",
27 framework='ubuntu-sdk-15.04', extra_files=None, output_dir=None):27 framework='ubuntu-sdk-15.04', extra_files=None,
28 output_dir=None):
28 """Return the path to a click/snap package with the given data.29 """Return the path to a click/snap package with the given data.
2930
30 Caller is responsible for deleting the output_dir afterwards.31 Caller is responsible for deleting the output_dir afterwards.
31 """32 """
32 is_snap = (package_format == "snap")33 is_snap = (pkgfmt_type == "snap")
33 build_dir = tempfile.mkdtemp()34 build_dir = tempfile.mkdtemp()
34 package_types = package_types or []35 package_types = package_types or []
3536
36 try:37 try:
37 make_dir_structure(build_dir, extra_files=extra_files)38 make_dir_structure(build_dir, pkgfmt_type=pkgfmt_type,
39 pkgfmt_version=pkgfmt_version,
40 extra_files=extra_files)
38 write_icon(build_dir)41 write_icon(build_dir)
39 write_manifest(build_dir, name, version,42
40 title, framework, package_types,43 if pkgfmt_type == 'click' or pkgfmt_version == 15.04:
41 is_snap)44 write_manifest(build_dir, name, version,
42 if is_snap:45 title, framework, package_types,
43 write_meta_data(build_dir, name, version,46 is_snap)
44 title, framework)47 write_control(build_dir, name, version, title, pkgfmt_version)
45 write_control(build_dir, name, version, title)48 write_preinst(build_dir)
46 write_preinst(build_dir)49 write_apparmor_profile(build_dir, name)
47 write_apparmor_profile(build_dir, name)50 write_other_files(build_dir)
48 write_other_files(build_dir)51 else:
49 pkg_path = build_package(build_dir, name, version, package_format,52 write_meta_data(build_dir, name, version, title, framework)
53
54 pkg_path = build_package(build_dir, name, version, pkgfmt_type,
50 output_dir=output_dir)55 output_dir=output_dir)
51 finally:56 finally:
52 shutil.rmtree(build_dir)57 shutil.rmtree(build_dir)
@@ -54,9 +59,12 @@
54 return pkg_path59 return pkg_path
5560
5661
57def make_dir_structure(path, extra_files=None):62def make_dir_structure(path, pkgfmt_type, pkgfmt_version, extra_files=None):
58 extra_files = extra_files or []63 extra_files = extra_files or []
59 directories = ['DEBIAN', 'meta']64 directories = ['meta']
65 if pkgfmt_type == 'click' or pkgfmt_version == 15.04:
66 directories.append('DEBIAN')
67
60 directories.extend(68 directories.extend(
61 [os.path.dirname(extra_file) for extra_file in extra_files])69 [os.path.dirname(extra_file) for extra_file in extra_files])
6270
@@ -128,11 +136,11 @@
128 f.write(title)136 f.write(title)
129137
130138
131def write_control(path, name, version, title):139def write_control(path, name, version, title, pkgfmt_version):
132 control_path = os.path.join(path, 'DEBIAN', 'control')140 control_path = os.path.join(path, 'DEBIAN', 'control')
133 control_content = {'Package': name,141 control_content = {'Package': name,
134 'Version': version,142 'Version': version,
135 'Click-Version': '0.4',143 'Click-Version': pkgfmt_version,
136 'Architecture': 'all',144 'Architecture': 'all',
137 'Maintainer': 'Someone <someone@example.com>',145 'Maintainer': 'Someone <someone@example.com>',
138 'Installed-Size': '123',146 'Installed-Size': '123',
139147
=== modified file 'debian/changelog'
--- debian/changelog 2015-12-01 14:44:03 +0000
+++ debian/changelog 2015-12-01 15:03:49 +0000
@@ -19,8 +19,37 @@
19 - 'Maintainer' checks in the click manifest should only be done with click19 - 'Maintainer' checks in the click manifest should only be done with click
20 packages (LP: #1510522)20 packages (LP: #1510522)
21 - don't prompt manual review when find .excludes file21 - don't prompt manual review when find .excludes file
22 - add kernel and os as valid snap types
23 - remove package filename checks. They were meaningless and hard to
24 maintain
25 - sort unknown snappy yaml keys
26 * clickreviews/cr_common.py:
27 - add valid yaml keys for kernel snaps
22 * update data/apparmor-easyprof-ubuntu.json for 16.04 policy28 * update data/apparmor-easyprof-ubuntu.json for 16.04 policy
23 * Makefile: add json syntax check29 * Makefile: add json syntax check
30 * several changes for squashfs snaps that won't have a click manifest, etc.
31 Importantly, this means that only package.yaml is looked at and a lot of
32 click specific tests can be skipped
33 - cr_common.py:
34 + rename a few variable to not be click specific
35 + add self.pkgfmt
36 + adjust __init__() to conditionally use package.yaml on squashfs,
37 otherwise click manifest
38 + make click data structure initialization conditional on if click
39 or not (eg, don't run hooks code on squashfs images)
40 - adjust clickreviews/cr_* to conditionally run certain click-only tests
41 on click packages
42 - adjust architecture checks to use self.pkg_arch and rename
43 control_architecture_specified_needed as architecture_specified_needed
44 - cr_security.py:
45 + revamp to use package.yaml on non-click instead of now nonexistent
46 security manifest
47 + update push-helper template test to not make hooks specific
48 + network-client should not be allowed with push helpers either
49 + conditionally look for INSTALL_DIR on 16.04 systems in security-policy
50 + adjust security-override checks on 16.04 to follow 16.04 yaml
51 + make click manifest checks conditional on if click
52 - cr_tests.py: mock _pkgfmt_type(), _pkgfmt_version() and _is_squashfs()
2453
25 [ Michael Nelson ]54 [ Michael Nelson ]
26 * add support for non-mocked tests55 * add support for non-mocked tests

Subscribers

People subscribed via source and target branches