interfaces: put base policy fragments inside each interface #3464

Merged
merged 92 commits into from Jun 29, 2017

Conversation

Projects
None yet
5 participants
Contributor

zyga commented Jun 9, 2017

This change completes the work towards making interface modules self-contained. Now each interface
can define a fragment of the base policy that applies to its plugs and slots.

Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com

codecov-io commented Jun 9, 2017

Codecov Report

Merging #3464 into master will decrease coverage by 0.09%.
The diff coverage is 32.04%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #3464     +/-   ##
=========================================
- Coverage   76.93%   76.84%   -0.1%     
=========================================
  Files         378      378             
  Lines       26116    26217    +101     
=========================================
+ Hits        20093    20147     +54     
- Misses       4243     4290     +47     
  Partials     1780     1780
Impacted Files Coverage Δ
interfaces/policy/basedeclaration.go 40.74% <ø> (ø) ⬆️
interfaces/builtin/storage_framework_service.go 78.94% <0%> (-2.14%) ⬇️
interfaces/builtin/io_ports_control.go 77.77% <0%> (-2.23%) ⬇️
interfaces/builtin/modem_manager.go 53.48% <0%> (-1.28%) ⬇️
interfaces/builtin/ubuntu_download_manager.go 52.63% <0%> (-1.43%) ⬇️
interfaces/builtin/udisks2.go 80.48% <0%> (-2.02%) ⬇️
interfaces/builtin/time_control.go 75.75% <0%> (-2.37%) ⬇️
interfaces/builtin/ppp.go 42.85% <0%> (-2.15%) ⬇️
interfaces/builtin/pulseaudio.go 48.27% <0%> (-1.73%) ⬇️
interfaces/builtin/hardware_random_observe.go 74.19% <0%> (-2.48%) ⬇️
... and 85 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84227d0...d3f3c2c. Read the comment docs.

zyga added some commits Jun 6, 2017

interfaces: move base decl for account-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for greengrass-support to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for alsa to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for autopilot-introspection to interface i…
…tself

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for avahi-observe to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for bluetooth-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for bluez to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for bool-file to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for browser-support to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for camera to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for classic-support to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for content to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for core-support to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for cups-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for dbus to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for dcdbas-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for docker to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for docker-support to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for firewall-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for framebuffer to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for fuse-support to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for fwupd to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for gpio to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for hardware-observe to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for hardware-random-control to interface i…
…tself

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for hardware-random-observe to interface i…
…tself

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for hidraw to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for home to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for i2c to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for iio to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for io-ports-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for joystick to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for kernel-module-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for kubernetes-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for libvirt to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for locale-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for location-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for location-observe to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for log-observe to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for lxd to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for lxd-support to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for maliit to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for media-hub to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for mir to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for modem-manager to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for mount-observe to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for mpris to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for netlink-audit to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for netlink-connector to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for network to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for network-bind to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for network-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for network-manager to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for network-observe to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for network-setup-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for network-setup-observe to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for network-status to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for ofono to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for online-accounts-service to interface i…
…tself

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for opengl to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for openvswitch to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for openvswitch-support to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for optical-drive to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for physical-memory-control to interface i…
…tself

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for physical-memory-observe to interface i…
…tself

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for ppp to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for process-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for pulseaudio to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for raw-usb to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for removable-media to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for screen-inhibit-control to interface it…
…self

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for serial-port to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for shutdown to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for snapd-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for storage-framework-service to interface…
… itself

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for system-observe to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for system-trace to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for thumbnailer-service to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for time-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for timeserver-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for timezone-control to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for tpm to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for ubuntu-download-manager to interface i…
…tself

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for udisks2 to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for uhid to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for unity7 to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for unity8 to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for unity8-calendar to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for unity8-contacts to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for upower-observe to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: move base decl for x11 to interface itself
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

Looks good. In addition to the review I compared the output with 'snap debug get-base-declaration' and it all looks fine.

As an aside, I was surprised that I needed 'sudo' when using 'snap debug get-base-declaration'-- there is nothing privileged there, the info is static and public.

Looks good, thanks for these changes! Just one question about a regex, see below.

+ - app
+ deny-connection:
+ slot-attributes:
+ name: .+
@stolowski

stolowski Jun 21, 2017

Contributor

Shouldn't this regex be more strict?

@jdstrand

jdstrand Jun 21, 2017

Contributor

It could be, but all it is really saying is that 'name' must be present. The interface slot code verifies this for us.

- x11:
- allow-installation:
- slot-snap-type:
- - core
@stolowski

stolowski Jun 21, 2017

Contributor

I wasn't sure what is the real purpose of all these changes until I reached this... Very nice, it's great we get rid of this big blob :)

@zyga

zyga Jun 23, 2017

Contributor

:-)

Contributor

zyga commented Jun 23, 2017

@jdstrand thank you for commenting, I think you are right but perhaps the nature of the debug endpoint is special enough to warrant this. All the debug interactions are done through one API endpoint. We could explore how to make specific actions require authentication but for now that is all-or-nothing for the debug endpoint.

@mvo5 mvo5 merged commit 2c7f904 into snapcore:master Jun 29, 2017

7 checks passed

artful-amd64 autopkgtest finished (success)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
xenial-i386 autopkgtest finished (success)
Details
xenial-ppc64el autopkgtest finished (success)
Details
yakkety-amd64 autopkgtest finished (success)
Details
zesty-amd64 autopkgtest finished (success)
Details

@zyga zyga deleted the zyga:feature/metadata-defines-base-policy branch Jun 29, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment