114 Commits

Author SHA1 Message Date
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
Samuele Pedroni
392fbba353 improve errors 2017-08-10 16:02:25 +02:00
Samuele Pedroni
103f98f17e support predefined assertions that don't establish foundational trust 2017-08-09 12:55:23 +02:00
Samuele Pedroni
4a0547ee90 add some tests that as per design we don't accept chains of assertions founded on a self-signed key coming externally 2017-07-04 11:10:09 +02:00
Samuele Pedroni
ad12f1c854 asserts: implement FindManyTrusted as well (#3516) 2017-06-23 11:16:55 +02:00
Samuele Pedroni
01ed3c86c1 implement a SuggestedFormat helper to help avoid specifying the wrong format iteration for an assertion 2017-01-20 16:55:42 +01:00
Zygmunt Krynicki
ed6ef8c710 asserts: fix ineffectual assignment to headers
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2016-11-22 15:48:48 +01:00
Zygmunt Krynicki
d6df05b0ca many: fix ineffectal assignments of err
This patch corrects a number of issues that have the form of:

    err := ...
    c.Check(err, IsNil)
    ...
    err = ...
    // err is not used again

That is, the last assignment of err is never used again and in practice
the error is not checked.

Thanks to https://github.com/gordonklaus/ineffassign

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2016-11-22 15:48:48 +01:00
Samuele Pedroni
4c9a64cf73 review feedback 2016-10-18 12:01:29 +02:00
Samuele Pedroni
b43c9ad27f go fmt 2016-10-17 21:27:02 +02:00
Samuele Pedroni
881219252e add FindSupported(.,.,maxFormat) to the Datbase 2016-10-17 21:11:38 +02:00
Samuele Pedroni
613d492324 review feedback 2016-10-17 19:57:08 +02:00
Samuele Pedroni
7ee295d416 refuse to sign things with declared unsupported formats, we likely cannot verify them properly while assembling them 2016-10-14 21:44:41 +02:00
Samuele Pedroni
425abc340f refuse to add an assertion with a not yet supported format iteration, ignore this kind of issue selectively 2016-10-14 21:25:53 +02:00
Samuele Pedroni
fe4495fe7f support a concept of assertion format iteration on all assertions, default is 0 2016-10-14 20:39:35 +02:00
Samuele Pedroni
4a509e7846 support for maps in assertion, tidier regexp for validating header names and now map keys 2016-09-21 20:10:12 +02:00
Matt Goodall
4ebf03bdb0 Give custom test account-key a name. 2016-09-07 13:33:39 +01:00
Samuele Pedroni
7da9e71978 don't have Add/Check panic in the face of unsupported no-authority assertion types, we don't control what is fed to snap ack, and we don't want to make this other layers problem 2016-09-03 13:34:32 +02:00
Samuele Pedroni
07aba0129f simplify the Database.ImportyKey/PublicKey interface now that key id are really assumed to be globally unique 2016-08-21 19:57:10 +02:00