89 Commits

Author SHA1 Message Date
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
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
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
Miguel Pires
438424b702 asserts: improve time range formatting
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-07-08 10:56:01 +01:00
Paweł Stołowski
81f307bd61 Merge branch 'master' into asserts-opt-primary-keys 2022-04-15 17:18:57 +02:00
Paweł Stołowski
1f6f1ee740 Fixes related to inclusive language. 2022-04-14 12:51:08 +02:00
Samuele Pedroni
491ff56795 asserts: export MockOptionalPrimaryKey for usage in other packages 2022-04-06 14:17:12 +02:00
Samuele Pedroni
4308154ed2 asserts: start supporting optional primary keys, fs backstore Put/Get 2022-02-28 11:13:26 +01:00
Samuele Pedroni
52de97d821 asserts: move DeviceScopeConstraint to constraint.go
cleanup some things
have dedicated tests
2022-02-14 15:21:55 +01:00
Samuele Pedroni
8f6bbee4a2 asserts: extract since-until support to a dedicated struct 2022-02-03 11:22:12 +01:00
Samuele Pedroni
e1a856242e asserts: finish the scaffold of authority-delegation
main missing things since/until support and device scope constraint
support
2022-01-28 13:11:53 +01:00
Samuele Pedroni
50f8cfaf0f asserts: let use a contextual word for "attribute" in attrMatcher
this is for errors
2022-01-27 11:49:59 +01:00
Samuele Pedroni
a4f82f5b3f asserts: start generalizing attrMatcher $OP() support 2022-01-27 11:49:59 +01:00
Samuele Pedroni
39413a7407 asserts: start splitting out attrMatcher for reuse to constraint.go 2022-01-26 17:04:15 +01:00
Samuele Pedroni
4a8ecace54 devicestate: Unregister deletes the device key pair as well
* daemon,tests: support forgetting device serial via API

this is done by posting {"action":"forget"} to /v2/model/serial

a flag no-registration-until-reboot is also supported

* many: more consistent naming Delete => DeleteByName on keypair mgrs

we actually want to introduce a Delete by key id on some of them now

* asserts: implement KeypairManager.Delete

* devicestate: Unregister deletes the device key pair as well

* tests: test device key deletion in generic-unregister

* asserts: avoid skipping the GPGKeypairManager.Delete test

pair --yes to --batch in the test
2021-12-02 18:04:53 +01:00
Samuele Pedroni
f3d9f94d54 asserts: clarify/simplify AccountKey.isValidAssumingCurTimeWithin
simplify the code a bit, try to improve the name/comments

thanks @mvo and @stolowski
2021-03-10 14:14:54 +01:00
Samuele Pedroni
0409b0d0e9 asserts: mode where Database only assumes cur time >= earliest time
if current system time is unreliable have a mode where Database checks
for key expiry just based on assuming that current time is >= known
earliest time

this is set up via Database.SetEarliestTime

internally a new predicate AccountKey.isKeyValidAbout(earliest,
latest) is used to support this
2021-03-05 09:27:12 +01:00
Pawel Stolowski
07b6ed2059 asserts: pool changes for validation-sets (#9930)
Support for sequence-forming assertions in pool.
2021-03-02 12:09:21 +01:00
Samuele Pedroni
4422c93e87 asserts: introduce Backstore.SequenceMemberAfter
implement it first for the memoryBackstore

there's also an always failing impementation for filesystemBackstore
for now
2020-06-29 13:52:36 +02:00
Samuele Pedroni
89291d8457 asserts: make clearer that with label we mean a serialized label 2020-05-12 20:48:17 +02:00
Samuele Pedroni
20c4aec9c0 asserts: introduce Pool
Motivation

With the new assertion bulk refresh API we can fetch or update
many assertions together, either assertions related/dependent or
unrelated/independent of each other.

To help driving and managing that this introduces asserts.Pool:

* a Pool can track unresolved assertions to be fetched
* or assertions to be updated
* it can record resolved assertions as fetched from the store and
  implicitly turn unresolved prerequisites into assertions to
  resolve

* assertions can be organized in groups, as the doc comment explains:
    Failure can be tracked isolated to groups, conversely any
    error related to a single group alone will stop any work to
    resolve it.  Independent assertions should not be grouped.

* assertions that are part of or are required by more than one
  group are tracked only once, for example store account-keys or
  developer account assertions for developers of many snaps on
  the system.

The latter is achieved by labeling each assertion with a Grouping
which represents all the groups it belongs to, at the low-level
this uses internal.Groupings/Grouping.

This organization into groupings matches well with the capabilities
of the API and means assertions will be typically requested only
once and grouped in ways that should be cache friendly.
2020-04-27 10:46:55 +02:00
Samuele Pedroni
c20c2c1f3e asserts: parse plug-names/slot-names constraints
these introduce format 4 for snap-declaration
2020-01-31 11:55:37 +01:00
Samuele Pedroni
f9f19ec9d2 make Precheck an option to CommitTo instead of a separate method
as discussed/suggested

clarify docs
2019-08-23 09:25:58 +02:00
Samuele Pedroni
3c5f9613b6 many: switch to account validation: unproven|verified (#5419) 2018-06-28 08:56:48 +02:00
John Lenton
7b162185ab Merge pull request #3506 from pedronis/asserts-type-max-body-size
asserts: introduce NewDecoderWithTypeMaxBodySize

NewDecoderWithTypeMaxBodySize allow to create an assertion stream Decoder that is configured with optional per-type max body sizes.

This will allow snap-repair to control what size of repair scripts/bodies is happy to accept.
2017-06-28 11:18:56 +01:00