1236 Commits

Author SHA1 Message Date
Robert Ancell
fc53358689 interfaces/builtin/home: autoconnect home on core desktop (#14106)
* asserts,i/policy: add on-core-desktop constraint

This is required for interface behaviours that are different on Core Desktop.

* interfaces/builtin/home: autoconnect home on core desktop

Core desktop is much like a classic system in that the user would reasonably
expect to be able to access this home directory.
2024-07-12 09:19:12 +02:00
Miguel Pires
283f8abb6b i/builtin: add registry interface (#14113)
* i/builtin: add registry interface

Add a registry interface that snaps can use to access a particular
registry view.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* registry: constrain registry name

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

---------

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-06-27 11:15:13 +02:00
Miguel Pires
cfcc50a1cf asserts: allow $PLUG_PUBLISHER_ID in plug attribute constraints
Allow plugs to specify the $PLUG_PUBLISHER_ID in attribute constraints
such that interfaces can restrict auto-connection to when certain
attributes match their publisher IDs.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-06-21 15:49:09 +02:00
Miguel Pires
8128ed20bb many: rename aspect/bundle to view/registry
This changes the naming of the aspects feature to be "registry" instead
of bundle (i.e., a configuration space backed with its own storage) and
"view" instead of aspect. Once this lands, anyone that has this enabled
needs to unset the experimental flag and rename the state entry before
refreshing snapd and then re-enable.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-06-17 17:16:57 +02:00
Andrew Phelps
6abc1a3e6a a/snapasserts, o/assertstate: implement validate-component task handler (#13964)
* a/snapasserts: add helpers for checking validity of component against assertions

* a/snapasserts, o/assertstate: implement validate-component task handler

* o/assertstate: test validate-component handler with provenance
2024-06-03 17:29:13 +02:00
Miguel Pires
79c5ac14b2 many: remove usages of deprecated io/ioutil package (#13768)
* many: remove usages of deprecated io/ioutil package

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* .golangci.yml: remove errcheck ignore rule for io/ioutil

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* run-checks: prevent new usages of io/ioutil

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

---------

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-04-03 23:23:24 +02:00
Alfonso Sánchez-Beato
b1f86bedfd asserts: add support for components in model assertion 2024-03-22 19:06:32 +00:00
Alfonso Sánchez-Beato
c32f6b7d90 asserts: refactor so checkModelSnap fills all ModelSnap fields
instead doing it only partially and filling part of them in other
method that should not have a saying on this.
2024-03-22 19:06:32 +00:00
Miguel Pires
562fe027c8 asserts: move aspect schema to assertion body (#13666)
* asserts: move aspect schema to assertion body

Move the aspect schema from a "storage" stanza to the assertion body.
Also format parse and re-encode the JSON with two spaces for indentation
and map ordered map keys. This should make the schema uniform and easy
to read while still using a format that can be emulated by other tools.

* many: nest schema in storage stanza

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* asserts: support checking JSON body format

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* asserts: improve err messages; move check

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

---------

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-03-13 17:22:05 +02:00
Miguel Pires
6a7ecfe597 aspects: validate summary descriptions (#13609)
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-02-21 15:38:08 +02:00
Philip Meulengracht
4f18d968a9 asserts: update username regex allowed by system-user assertion (#13590)
* asserts: update username regex allowed by system-user assertion

* asserts: drop the second '-' from the regex
2024-02-16 12:24:21 +01:00
Miguel Pires
f5f241c30f aspects: make access pattern/rule usage consistent
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-02-09 15:21:23 +01:00
Miguel Pires
33ef8e9bf7 aspects: put access rules under map in assertion
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-02-09 15:21:23 +01:00
Samuele Pedroni
3c93806071 asserts: define new aspect-bundle assertion (#13545)
this holds configuration aspects' defintions

* asserts: some doc comment fixes and tweaks

thanks @MiguelPires
2024-02-07 10:16:09 +01:00
Andrew Phelps
0238dca2a7 asserts: add Model.AllSnaps method (#13456)
* asserts: add Model.AllSnaps method

* o/devicestate: use model.AllSnaps rather than concatenating essential and non-essential snaps

* asserts: update Model.AllSnaps doc comment to be more clear

* asserts: update Model.AllSnaps test to assert that test is actually useful
2024-01-11 13:03:02 +02:00
Andrew Phelps
3a7d30b271 a/snapasserts: add ValidationSets.SnapConstrained method (#13457) 2024-01-09 22:49:18 -05:00
Samuele Pedroni
57cb2b15ef asserts: validate resource-name in snap-resource-* assertions 2024-01-02 16:35:08 +01:00
Samuele Pedroni
8203f7111d asserts: implement snap-resource-pair 2024-01-02 16:35:08 +01:00
Samuele Pedroni
3ce86db9ee asserts: implement snap-resource-revision
including delegation support parallel to snap-revision similar support
2023-12-13 22:10:24 +01:00
Andrew Phelps
154d46b46c many: take into account validation sets during remodel (#13243)
This PR makes remodels take into account revision constraints from validation sets on the new model. Additionally, snaps that are marked as invalid in validation sets are checked for in the model.

* a/snapasserts: add methods for extracting more information out of ValidationSets type

* o/assertstate: add ValidationSetsFromModel function for extracting a snapasserts.ValidationSets from an asserts.Model

* o/snapstate: prevent installing/updating a snap from a local file that does not match requested revision

* o/devicestate: consider validation sets during remodeling

* tests/nested/manual: add remodel test that downgrades a snap because of a validation set

* tests/nested/manual: add remodel test that fails to remodel because of an invalid snap in a validation set

* tests/nested/manual: extend offline remodel test to also include a validation set

* tests/lib/assertions: fix timestamps on assertions

* asserts: add Key method to ValidationSet and ModelValidationSet

* o/devicestate: use new Key methods

* o/devicestate: maybe enforce validation sets during doSetModel

* o/devicestate: add test for enforcing validation sets in doSetModel

* a/snapasserts: simplify TestCanBePresent with loop

* tests/lib/assertions: add bluez snap to offline remodel test

* o/devicestate: remove done TODO

* o/snapstate: if remodeling, do not install prereq if link-snap task is present

* tests/nested/manual/remodel-offline: extend test to verify that validation sets are accounted for

* Revert "o/snapstate: if remodeling, do not install prereq if link-snap task is present"

This reverts commit 57c7725a2513df51be7ac1c06c492aaed07a6e3b.

This change is independent and will be included in another PR.

* a/snapasserts: add methods for extracting more information out of ValidationSets type

* o/assertstate: add ValidationSetsFromModel function for extracting a snapasserts.ValidationSets from an asserts.Model

* o/devicestate: add test for ValidationSetsConflictError.Is

* a/snapasserts: move methods after New function

* a/snapasserts: add test for ValidationSets.Revisions to verify ValidationSetsConflictError is returned

* o/assertstate: change ValidationSetsFromModel to take in a DeviceContext, rather than a StoreService

* o/assertstate: rename ValidationSetsModelFlags to ValidationSetsModelOptions

* o/devicestate: add type to export_test to make testing simpler

* tests: add details to new spread tests

* asserts: rename ModelValidationSet.Key and ValidationSet.Key to .SequenceName and add unit tests for them

* o/snapstate: update snap revision mismatch error message to be more clear

* o/devicestate: introduce helper for setting ValidationSets on snapstate.RevisionOptions if Revision is set

* o/devicestate: verify the parameters that fakeSequenceStore receives

* o/devicestate: fix revisions not being respected for essential snaps (and add a test for it)

* o/devicestate: extend TestRemodelUC20EssentialSnapsAlreadyInstalledAndLocal to also exercise case where a validation set requires a revision but the currently installed version is unasserted

* s/seedtest: update retrieveSeq to handle unconstrained sequence forming assertions

* a/snapasserts: add ValidationSets.Sets method

* o/assertstate: add deviceContext to ForgetValidationSet function so that change can happen during remodel

* o/devicestate: attempt to handle rollback of validation sets during failed remodel

* overlord: test for replacing conflicting validation sets during remodel

* o/assertstate: update ForgetValidationSet to take in a DeviceContext and to allow for forcing removal even if the validation set is in use by the model

* o/devicestate: roll back validation set changes on remodel failure

* o/devicestate: make sure that validation sets unrelated to the model survive a remodel

* o/devicestate: rename param in installedSnapRevisionChanged

* o/devicestate: rename field newSnapRevision to newRequiredRevision in modelSnapsForRemodel

* o/devicestate: simplify loops in checkForInvalidSnapsInModel

* o/devicestate: compare validation sets using SequenceName methods

* o/devicestate: fail remodel if we attempt to use an unasserted snap as a specific revision

* tests/nested/manual/remodel-offline: fix test to actually use validation set

* o/devicestate: create helper for creating snapstate.RevisionOptions during remodel

* o/devicestate: name param literals for clarity

* o/devicestate: invert logic to eliminate double negative

* o/devicestate: fix missed inversion of logic

* o/assertstate: update comment on ForgetValidationSetOpts.ForceForget

* overlord, o/devicestate: update remodel test to change models that contain the same validation set

* o/assertstate: test ForceForget functionality in ForgetValidationSet

* o/devicestate: rename function newRevisionOptionsForRemodel to revisionOptionsForRemodel

* o/assertstate, o/devicestate, daemon: remove unneeded DeviceContext param from ForgetValidationSet

* o/devicestate: remove println

* o/devicestate: clarify comment in rollback of adding validation sets

* o/devicestate: rename variable in enforceValidationSetsForRemodel

* o/snapstate: clarify error when attempting to install/refresh local snap with different revision than requested

* o/devicestate: naming consistency

* o/devicestate: simplify error when model is missing snap that is required in validation set

* asserts, overlord, o/devicestate: rename SequenceName to SequenceKey and prefix the series to the string that is returned
2023-12-12 10:00:48 +01:00
Andrew Phelps
38a74ecb3f a/snapasserts, o/assertstate: add functions to help during remodel (#13345) 2023-11-28 15:54:39 -05:00
Samuele Pedroni
c6365a4b8e asserts,i/policy: slot-side slot-snap-type connection constraints
these can be useful in the base-declaration in situations where
a slot can be app-provided or implicit both on classic and core

now we have at least one use case like this for upower-observe

as core/system snaps so far provide only slots there is no use
case for adding plug-side plug-snap-type connection constraints
2023-09-27 14:58:56 +02:00
Miguel Pires
29c9752d66 many: s/ioutil.WriteFile/os.WriteFile (#13217)
Replace ioutil.WriteFile with os.WriteFile since the former has been
deprecated since go1.16 and simply calls the latter.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-09-26 11:38:46 +01:00
Dimitri John Ledkov
d55f3123d4 go: go fix with 1.18
Apply `go fix ./...` to the whole code base using go-1.18 to remove
old build tags.
2023-09-25 13:22:14 +02:00
Joseph Brock
f91aeea090 asserts/model: test serial-authority field with wildcard
Signed-off-by: Joseph Brock <joseph.brock@canonical.com>
2023-09-11 15:50:54 +01:00