-
Notifications
You must be signed in to change notification settings - Fork 601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
seed: ReadSystemEssentialAndBetterEarliestTime #10005
seed: ReadSystemEssentialAndBetterEarliestTime #10005
Conversation
based on #10004 |
8f889ad
to
e12e040
Compare
have a variant of CommitTo that supports a callback to consider each assertion immediately after it has been added to the database, at which point it also verified
ReadSystemEssentialAndBetterEarliestTime retrieves in one go information about the model and essential snaps of the given types for the Core 20 recovery system seed specified by seedDir and label (which cannot be empty). It can operate even if current system time is unreliable by taking a earliestTime lower bound for current time. It returns as well an improved lower bound by considering appropriate assertions in the seed.
e12e040
to
6dc91da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also do this for snap-declarations too, but other than that looks great to me (minus some nitpicky wording things in the doc-comments)
seed/seed.go
Outdated
// and more recent than snap-declarations anyway, | ||
// other assertions are ignored as they might be added | ||
// with unreliable times | ||
if a.Type() == asserts.SnapRevisionType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as mentioned on IRC, we could also use the snap-declaration timestamp here, since the checkConsistency method also verified that the snap-declarations are store-signed too, the case is unlikely where the snap-declaration is newer than the snap-revision, but it could happen and I think it's okay to be slightly more accepting of assertion types here
seed/seed.go
Outdated
// we consider only snap-revisions as they are stored-signed | ||
// and more recent than snap-declarations anyway, | ||
// other assertions are ignored as they might be added | ||
// with unreliable times |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// we consider only snap-revisions as they are stored-signed | |
// and more recent than snap-declarations anyway, | |
// other assertions are ignored as they might be added | |
// with unreliable times | |
// we consider only snap-revision and snap-declaration | |
// assertions here as they must be store-signed, see | |
// checkConsistency for each type | |
// other assertions are ignored as they might have a root | |
// of trust that does not include the brand key that signed | |
// the model assertion; thereby allowing an attacker with an | |
// account-key that was signed by canonical to inject new | |
// assertions that are not rooted in trust with the store directly | |
// or with the brand key directly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used a slightly different explanation in the end
seed/seed.go
Outdated
return nil, nil, time.Time{}, err | ||
} | ||
|
||
// consider model own timestamp as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// consider model own timestamp as well | |
// consider the model's timestamp as well - it must be signed | |
// by the brand so is safe from the attack detailed above |
asserts/batch_test.go
Outdated
|
||
// this is the order they needed to be added | ||
c.Check(seen, DeepEquals, []*asserts.Ref{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seed/seed20_test.go
Outdated
c.Check(essSnaps, DeepEquals, t.expected) | ||
c.Check(betterTime.Equal(improvedTime), Equals, true, Commentf("%v expected: %v", betterTime, improvedTime)) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @anonymouse64 also remove some spurious blank lines here and in asserts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this
} | ||
|
||
improve := func(a asserts.Assertion) { | ||
// we consider only snap-revision and snap-declaration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this comment
// containing unreliable time | ||
var tstamp time.Time | ||
switch a.Type() { | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nitpick^99) most of the switch/case I have seen has the default as the last entry but that is really probably my most nitpicky comment yet.
ReadSystemEssentialAndBetterEarliestTime retrieves in one go information about the model and essential snaps of the given types for the Core 20 recovery system seed specified by seedDir and label (which cannot be empty). It can operate even if current system time is unreliable by taking a earliestTime lower bound for current time. It returns as well an improved lower bound by considering appropriate assertions in the seed. * asserts: Batch.CommitToAndObserve have a variant of CommitTo that supports a callback to consider each assertion immediately after it has been added to the database, at which point it also verified
ReadSystemEssentialAndBetterEarliestTime retrieves in one go
information about the model and essential snaps of the given types
for the Core 20 recovery system seed specified by seedDir and label
(which cannot be empty).
It can operate even if current system time is unreliable by taking
a earliestTime lower bound for current time.
It returns as well an improved lower bound by considering appropriate
assertions in the seed.