Commit Graph

1231 Commits

Author SHA1 Message Date
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
J. Brock
7c17cf2669 asserts,seed: preseed authority delegation (#13034)
* asserts/model: add preseedAuthority field to Model

* seed20: allow authority-id to differ from the brand-id

* fixup! asserts/model: add preseedAuthority field to Model

fix comment wording to PreseedAuthority

* fixup! seed20: allow authority-id to differ from the brand-id

clarify error message as "preseed authority-id"

* fixup! asserts/model: add preseedAuthority field to Model

standardize checkOptionalAuthority() signature and make acceptsAny bool explicit when invoking it

* fixup! seed20: allow authority-id to differ from the brand-id

fix ineffectual assignment to preseedAs2

* fixup! asserts/model: add preseedAuthority field to Model

bump copyright years for files touched by 5593e76312

* fixup! seed20: allow authority-id to differ from the brand-id

bump copyright years for files touched by ce7ba34e0f

* fixup! asserts/model: add preseedAuthority field to Model

asserts/model.go: rename "acceptsAny" to "acceptsWildcard"
2023-09-04 10:22:43 +02:00
Samuele Pedroni
c21d4b4b72 asserts,a/signtool: support for cross-checking against constraints when signing 2023-08-31 13:06:49 +02:00
Samuele Pedroni
6cc7429752 asserts: add support for account-key constraints (#12988)
and take them into account when verifying assertion signatures
2023-08-08 15:43:19 +02:00
Spyros Seimenis
fa9cf5aada asserts: add support for integrity stanza in snap revision assertions
Address comments:

- Rename Integrity to SnapIntegrity
- Export SHA3_384 and Size field of SnapIntegrity
- Add What variants for checkDigest and checkUint helpers
2023-05-09 09:59:56 +02:00
Philip Meulengracht
c715c2fd85 asserts,seed/seedwriter: support for validation sets in seedwriter (#12571)
* asserts,seed/seedwriter: support for validation sets when writing the image seed.

* seed/seedwriter: simplify writer code

* seed/seedwriter: updatethe docs for Start

* asserts,seed/seedwriter: review feedback

Add unit tests for AtSequence, ensure CheckValidationSets cannot be called unless download step has completed

* seed/seedwriter: review feedback

add unit test for CheckValidationSets to early call, reuse checkStepCompleted in checkSnapsAccessor
2023-04-04 09:55:44 +02:00