71 Commits

Author SHA1 Message Date
Zeyad Yasser
54c6a1d8c3 refactor: replace IsNotFound usages for errors.Is(err, &NotFoundError{}) 2023-02-09 16:02:40 +00:00
Miguel Pires
1bc20a8391 daemon: change summary message + minor changes
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-28 10:28:31 +01:00
Miguel Pires
af2750d0a4 o/assertstate: add all used sets to ValidationSetsValidationError
Include all validation sets used to check in the validation error
instead of wrapping error with additional information.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-27 17:10:18 +01:00
Miguel Pires
73484a1523 asserts: wrap validation error with new sets data
Wrap the error returned by CheckInstalledSnaps with the new sets
that are not currently tracked. The previous approach required
marking those sets as "extra" in the validation set but was out
of place since this is only required for callers of "TryEnforce" to
resolve constraints that led to the validation error

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-26 17:17:46 +01:00
Miguel Pires
65e5c0271b asserts: add unit test for SetExtraSets method
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-26 14:46:23 +01:00
Miguel Pires
3cf8a0828b asserts: rename SexExtra method
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-26 14:46:09 +01:00
Miguel Pires
5c42708c8c daemon: support validation set refresh+enforce in API
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-23 15:43:31 +01:00
Miguel Pires
de9e6b210a asserts: pass assertion by ref instead of value
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-15 10:59:05 +01:00
Miguel Pires
7cb5386ebb store: use typed valset key in store action
Take a typed ValidationSetKey in the store package instead of a
[][]string, to help prevent wrong keys from being passed. To the same
end, also renames the field from ValidationSet to ValidationSetKey.
Also adds a Components() helper to split the key into its primary key
components.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-13 10:57:43 +01:00
Miguel Pires
5bcc0a98be asserts/snapasserts: use typed valset key in CheckPresenceInvalid
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-12 10:50:48 +01:00
Miguel Pires
621ff727c1 asserts/snapasserts: move and test ValidationSetKey helpers
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-12 10:50:48 +01:00
Miguel Pires
1bd6e476ce asserts/snapasserts: add ValidationSetKey type for RevisionOptions
Add ValidationSetKey type to prevent incorrect keys from being used.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-08 18:30:51 +01:00
Michael Vogt
e53a826e18 Merge pull request #11911 from stolowski/validation-sets/try-enforce-validation-sets
o/assertstate, snapasserts: implementation of assertstate.TryEnforceValidationSets function
2022-08-16 18:30:58 +02:00
Michael Vogt
42dc5efb05 Merge remote-tracking branch 'upstream/master' into validation-sets/try-enforce-validation-sets 2022-08-16 12:59:08 +02:00
Michael Vogt
9512a42ae5 Merge pull request #11988 from pedronis/crisper-check-provenance-api
many: change name and input of CheckProvenance to clarify usage
2022-08-16 12:51:04 +02:00
Samuele Pedroni
cbddde69ff a/snapasserts: add a test about DeriveSideInfo* ambiguity limitations 2022-07-22 18:25:10 +02:00
Samuele Pedroni
14a5f258e1 many: change name and input of CheckProvenance to clarify usage 2022-07-22 13:20:16 +02:00
Samuele Pedroni
21e2207e9e many: support non-default provenance snap-revisions in DeriveSideInfo*
snapsserts.DeriveSideInfo* cannot deal with snap-revisions with the
same hash but different provenance in the local system assertion
database, this should be an acceptable limitation for a while

the seedwriter code now assumes that the input can be trusted, this is
reasonable

systems.go uses already installed snaps, so it's fine but probably
would still be good to address the TODO in it for efficiency/clarity
as the code in seedwriter DeriveSideInfo is even more clunky now for
this use case, we should be able to find an applicable snap-revision
by other means
2022-07-22 11:30:28 +02:00
Samuele Pedroni
1ca77ad4e2 image,a/snapasserts: doc comment improvements/formatting
from comments on the previous PR and this, thanks @mardy, @MiguelPires
2022-07-21 09:17:14 +02:00
Samuele Pedroni
a58b5b6640 many: snap revision fetching and cross-checking for delegation
snap revision fetching and cross-checking should take provenance into
account and also verify device scope constraints for revision
authority delegation

provenance is taken as a hint from the store, but then matching
assertions must be found and then provenance is double checked

a failure of the latter check is likely a sign of a bug or
error as an attacker that can submit or forge/sign a blob could
as well do one with the expected provenance

provenance goals are tracing and avoiding the risk of polluting
the snap-revision namespace

this leaves alone the DeriveSideInfo* functions mainly used for
asserted local installs, this means they might fail to find a
snap-revision sometimes, they will be updated in a different branch.
2022-07-20 11:03:20 +02:00
Samuele Pedroni
b670e9a185 many: snapasserts.DeriveSideInfo* take a model assertion
this will be used to perform the device specific part of full cross
checks for delegated authority snap-revisions
2022-07-18 20:36:18 +02:00
Samuele Pedroni
bac14a21a4 many: snapasserts.CrossChecks takes a model assertion optionally
this will be used to perform the device specific part of full cross
checks for delegated authority snap-revisions
2022-07-18 14:28:46 +02:00
Paweł Stołowski
a52d709634 Tweak error messages coming from ParseValidationSet helper. 2022-06-23 15:55:32 +02:00
Paweł Stołowski
9199c3ae0f Cover all error cases from ParseValidationSet. 2022-06-23 14:49:12 +02:00
Paweł Stołowski
599a3584b8 Implementation of assertstate.TryEnforceValidationSets function. The
function tries to enforce extra validation sets passed to it (and
updates v-s tracking state) or returns an error.
ValidationSetsValidationError can be used by the caller to resolve
validation issues and retry.
2022-06-23 14:20:20 +02:00