132 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
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
Zeyad Yasser
54c6a1d8c3 refactor: replace IsNotFound usages for errors.Is(err, &NotFoundError{}) 2023-02-09 16:02:40 +00:00
Miguel Pires
4c6fdc2164 many: add tests for error Is()
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-10-03 10:22:01 +01:00
Samuele Pedroni
920389ac46 asserts,cmd/snap-repair: drop not pursued AuthorityDelegation/signatory-id code
in the end we went for a control assertion (snap-declaration) specific
delegation approach, instead of the generic one
2022-08-24 14:04:35 +02:00
Michael Vogt
0510676887 asserts: add some missing c.Check() in the asserts test
The staticcheck.io complained that in some places in the
assert tests values are assigned but not used. This commit
fixes this by checking the values. Alternatives we could
of course just use `_, err := ...` instead of `a, err := ...`
but checking seems slightly more sensible to me.
2022-08-16 20:56:01 +02: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
Miguel Pires
24c876c8ce asserts: add more context to key expiry error
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-07-06 15:13:49 +01:00
Paweł Stołowski
5245cd1ba8 Fix ineffectual assignment in the test. 2022-04-15 17:18:11 +02:00
Samuele Pedroni
491ff56795 asserts: export MockOptionalPrimaryKey for usage in other packages 2022-04-06 14:17:12 +02:00
Samuele Pedroni
98de63ac23 asserts: support optional primary keys in Find family
change PrimaryKeyFromHeaders to allow for omitted optional primary
keys
2022-04-06 14:17:12 +02:00
Samuele Pedroni
331724d76d asserts: minimal changes to disable authority-delegation before full revert
authority-delegation might have been premature, disable until we might
decide for a full revert
2022-03-14 18:47:04 +01:00
Samuele Pedroni
d5c752b103 asserts: drop wrong and unnecessary type in fixture headers 2022-02-14 15:20:10 +01:00
Samuele Pedroni
078cb5f74c asserts: first-class support for formatting/encoding signatory-id
together with checks for it
2022-02-11 15:24:41 +01:00
Samuele Pedroni
d59e2e8f47 asserts: fix error message and test
thanks @MiguelPires and @stolowski
2022-02-04 17:22:50 +01:00
Samuele Pedroni
e3b23eef45 asserts: implementent Check*Delegation*
these implement the logic to validate delegation
if needed
2022-02-04 17:22:50 +01:00
Samuele Pedroni
130242ee7e asserts: start supporting delegation when validating signatures
* start of basic test (failing here)
* start of signatory-id support
2022-02-03 11:22:12 +01:00
Michael Vogt
856cd41c7f asserts: rename "white box" to "clear box" (woke checker)
First PR to fix an error from the "woke" checker [1].

[1] https://github.com/get-woke/woke
2021-11-22 10:08:19 +01:00
Alberto Mardegan
37e83765f3 asserts: fix errors reported by linter
Besides some trivial fixes, this also adds the (previously unused) class
`isUnacceptedUpdateSuite` to the tests suite.
2021-05-05 10:16:20 +03: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
Samuele Pedroni
8eff2997ae asserts: repeat the authority cross-check in CheckSignature as well
findAccountKey was alread checking this but
this is an additional defense and makes CheckSignature a more
robust standalone helper if used that way
2021-02-12 18:29:30 +01:00
Samuele Pedroni
237c0103ac asserts: implement Database.FindSequence
FindSequence finds a sequence-forming assertion based the given
headers. Provided headers must contain a prefix of the primary key
for the assertion type except for the sequence header.
Th assertion is the first in the sequence under the prefix with
sequential number > after.
If after is -1 it returns instead the assertion with the largest
sequential number.
2020-06-29 14:14:28 +02:00
Samuele Pedroni
d1e2afcbb1 introduce asserts.Database.WithStackedBackstore 2019-07-19 09:37:15 +02:00
Samuele Pedroni
3c5f9613b6 many: switch to account validation: unproven|verified (#5419) 2018-06-28 08:56:48 +02:00
Samuele Pedroni
97e3ef21a3 many: introduce asserts.NotFoundError replacing both ErrNotFound and store.AssertionNotFoundError (#3893)
This converts the singleton asserts.ErrNotFound to a richer asserts.NotFoundError struct carrying Type and optionally PrimaryKey, similar to store.AssertionNotFoundError which then gets folded with this.

This means code doesn't have to worry anymore which is which or to convert between the two. And when possible there is more information around. Though Backstores can continue to return minimal information (Type but not Headers in the new error).

A helper asserts.IsNotFound is also added to cover the simple old ==/!= asserts.ErrNotFound needs.

This also fixes/adjust some error handling to usually not repeat the richer information twice.
2017-09-12 16:34:53 +02:00