Skip to content
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

Implement auditor-server protocol #182

Merged
merged 7 commits into from
Sep 21, 2017
Merged

Implement auditor-server protocol #182

merged 7 commits into from
Sep 21, 2017

Conversation

masomel
Copy link
Member

@masomel masomel commented Aug 18, 2017

Part of #151

TODO:

  • auditor-server request message
  • implement Audit() and change auditlog initialization
  • auditor-server tests
  • add auditor request handling in directory

@masomel masomel added this to In Progress in Auditing Aug 18, 2017
@masomel masomel added this to In Progress in Sprint: Nov 24 - Dec 7 Aug 19, 2017
@masomel masomel requested a review from vqhuy August 21, 2017 01:17
@masomel masomel self-assigned this Aug 21, 2017
@masomel masomel changed the title [WIP] Implement auditor-server protocol Implement auditor-server protocol Aug 21, 2017
@masomel masomel moved this from In Progress to In Review in Sprint: Nov 24 - Dec 7 Aug 21, 2017
@vqhuy vqhuy changed the base branch from master to generic-auditor August 21, 2017 13:56

// Since the str[0] is pinned in the audit log
// expect that STR[0].Epoch is at least 1
if strs.STR[0].Epoch < 1 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be covered in AuditDirectory()? And I suppose an auditor should be able to request an STR range starting from epoch 0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this case is covered in the str.Epoch == verifiedSTR.Epoch case in AuditDirectory(). What I wanted to avoid is re-inserting str[0], but if the checks pass, it wouldn't matter anyway.

@@ -105,7 +106,7 @@ func (a *AudState) checkSTRAgainstVerified(str *DirSTR) error {
return CheckBadSTR
}

return nil
Copy link
Member

@vqhuy vqhuy Aug 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer returning nil here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean only for this function because it's only a helper function, or in all the cases in which I replaced nil with CheckPassed? I feel like it would definitely make sense to return CheckPassed from AuditDirectory() at least.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean only for this function ;)

@masomel masomel changed the base branch from generic-auditor to master September 1, 2017 14:20
@masomel masomel moved this from In Progress to In Review in Auditing Sep 1, 2017
// Audit checks that a directory's STR history
// is linear and updates the auditor's state
// is linear and updates the audtor's state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

// TODO: Implement as part of the auditor-server protocol
return CheckPassed
if err := msg.validate(); err != nil {
return err.(ErrorCode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be just return err.

func (l ConiksAuditLog) Insert(addr string, signKey sign.PublicKey,
// InitHistory() is called by an auditor when it initializes its state
// from disk (either first-time startup, or after reboot).
func (l ConiksAuditLog) InitHistory(addr string, signKey sign.PublicKey,
snaps []*DirSTR) error {
// make sure we're getting an initial STR at the very least
if len(snaps) < 1 || snaps[0].Epoch != 0 {
Copy link
Member

@vqhuy vqhuy Sep 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should compare snaps[0] with the pinned STR, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snaps[0] is the pinned STR. As the documentation describes, this function is called when the auditor first starts up, so the very first time that auditor is launched, it will read the pinned STR from disk and pass it into InitHistory through the snaps parameter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh sorry, I missed that part. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem! I can make this clearer in the documentation.

@@ -133,7 +133,7 @@ func (cc *ConsistencyChecks) updateSTR(requestType int, msg *Response) error {
// The initial STR is pinned in the client
// so cc.verifiedSTR should never be nil
// FIXME: use STR slice from Response msg
if err := cc.AuditDirectory([]*DirSTR{str}); err != nil {
if err := cc.AuditDirectory([]*DirSTR{str}); err != CheckPassed {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove this CheckPassed later (nil is more idiomatic Go), so I think we can leave it as it was.

Copy link
Member Author

@masomel masomel Sep 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for CONIKS, though, CheckPassed is a clearer return value for the AuditDirectory check than nil.

It seems I misunderstood. If you're removing CheckPassed altogether, that seems fine to me.

// the epoch range [startEpoch, endEpoch], where startEpoch
// and endEpoch are the epoch range endpoints indicated in the client's
// request. If req.endEpoch is greater than d.LatestSTR().Epoch or
// omitted in req, the end of the range will be set to d.LatestSTR().Epoch.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't checked if req.endEpoch is omitted in "MonitoringRequest", so should we change the range request to something like [Epoch, Range] where Epoch is StartEpoch and Range is the maximum number of epochs to return?

@@ -135,7 +149,8 @@ type DirectoryProof struct {
// STR representing a range of the STR hash chain. If the range only
// covers the latest epoch, the list only contains a single STR.
// A CONIKS auditor returns this DirectoryResponse type upon an
// AudutingRequest.
// AudutingRequest from a client, and a CONIKS directory returns
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

@masomel masomel merged commit 153edc2 into master Sep 21, 2017
@masomel masomel moved this from In Review to Done in Auditing Sep 21, 2017
@masomel masomel moved this from In Review to Done in Sprint: Nov 24 - Dec 7 Sep 21, 2017
@vqhuy vqhuy deleted the auditor-server branch September 22, 2017 07:41
@masomel masomel removed this from Done in Sprint: Nov 24 - Dec 7 Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants