1215 Commits

Author SHA1 Message Date
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
Philip Meulengracht
c5bc938f80 image,seed: refactor RefAssertsFetcher (#12667)
* asserts,seed/seedwriter: refactor RefAssertsFetcher into a SeedAssertionFetcher with support for FetchSequence, and its own set of unit tests.

* seed/seedwriter: review feedback

Removed the TODO and updated docs for Writer.Start

* seed/seedwriter: review feedback

remove a line of the docs for SeedAssertionFetcher

* seed/seedwriter: review feedback

add additional case for calling FetchSequence with the default fetcher
2023-03-29 07:48:31 +02:00
Philip Meulengracht
7ec1160e91 asserts: add code for Fetcher to support the fetching of sequence-forming assertions (#12654)
* multiple: add code for Fetcher to support the fetching of sequence-forming assertions
* asserts: obviously not a typo as I read it
* asserts: add new SeqFetcher interface
* asserts: add docs to NewSeqFetcher
* asserts: remove ResolveLatest and open another PR
* asserts: cleanup some doc comments, make sure they fit their use-cases. Include Fetcher interface in SequenceFormingFetcher. Rename SeqFetcher to SequenceFormingFetcher and the new function. Do some additional renaming. Reuse some code between FetchSequence and Fetch.
* asserts: add an additional unit test to document current behavior of multiple sequences of same assertion.
* asserts: update docs for NewSequenceFormingFetcher, readd a line I had removed accidently, the sequence number must be set back to 2 after testing with sequence 4
* asserts: add docs for the multiple-sequence behavior, add missing doc line for SequenceFormingFetcher.
* asserts: add unit tests for detecting circular references, clarify some of the terminology around sequences

---------

Co-authored-by: Michael Vogt <mvo@ubuntu.com>
2023-03-22 11:28:25 +01:00
Philip Meulengracht
d1f1074adf asserts: review feedback
add Optional to the sequence check, change error for wrongly formatted validation-set entry
2023-03-10 07:22:44 +01:00
Philip Meulengracht
6c167b9ab6 asserts: review feedback
clarify error description if specifying an invalid sequence
2023-03-10 07:22:44 +01:00
Philip Meulengracht
9a006ce79d asserts: review feedback
dont allow 0 in sequence, remove checkDefaultIntWhat as its not needed anymore, add unit test for the 0 case
2023-03-10 07:22:44 +01:00
Philip Meulengracht
77c9bfb609 asserts: review feedback
improve error messages, add missing unit test cases for these errors
2023-03-10 07:22:43 +01:00
Philip Meulengracht
080f154631 asserts: review feedback
use 'what' methods instead to provide error context when data members are invalid, change certain error messages to align with the rest, and introduce a What variant of checkIntWithDefault
2023-03-10 07:22:43 +01:00
Philip Meulengracht
b3f15803d1 asserts: remove monitor as a mode 2023-03-10 07:22:43 +01:00
Philip Meulengracht
1f903f7524 asserts: default to brand ID when account ID is not set 2023-03-10 07:22:42 +01:00
Philip Meulengracht
b18a7aab80 asserts: support validation-sets in model assertion 2023-03-10 07:22:42 +01:00
Philip Meulengracht
ae6489f798 golang: remove deadcode linter 2023-03-09 14:43:47 +01:00
Zeyad Yasser
12ad23f53a fix infinite recursion in errors.Is(err, &NotFoundError{}) 2023-02-09 16:02:40 +00:00
Zeyad Yasser
54c6a1d8c3 refactor: replace IsNotFound usages for errors.Is(err, &NotFoundError{}) 2023-02-09 16:02:40 +00:00
Miguel Pires
d097436c1c many: fix formatting w/ gofmt 1.19
Go 1.19 includes some changes to gofmt which intend to make lists and
heading clearer when rendered (https://go.dev/doc/go1.19). This commit
is the result of running the new gofmt and manually fixing some of it.
This was necessary because the new gofmt assumed lines beginning w/ tabs
to start lists or examples. While this is often true in our codebase,
we occasionally also use tabs to indent the lines after a TODO or FIXME
prefix or in yaml (e.g., excerpts of a snap.yaml). This meant that a lot of the
reformatted comments were broken and had to be fixed manually.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-16 14:23:11 +01:00
Philip Meulengracht
99302b1ad3 asserts: review feedback
update maxSupportedFormat to 2, update test, add check that UserExpiration is empty by default
2022-10-19 10:38:34 +02:00
Philip Meulengracht
2afc347391 asserts: reverse logic check 2022-10-19 09:26:01 +02:00