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

Check eldest KID in ComputeKeyDiffs, fix ugly warning messages when eldest key not pgp key #1419

Merged
merged 6 commits into from
Nov 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/client/cmd_pgp_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewCmdPGPUpdate(cl *libcmdline.CommandLine) cli.Command {
Action: func(c *cli.Context) {
cl.ChooseCommand(&CmdPGPUpdate{}, "update", c)
},
Description: `'keybase pgp update' pushed updated PGP public keys to the server.
Description: `'keybase pgp update' pushes updated PGP public keys to the server.
Public PGP keys are exported from your local GPG keyring and sent
to the Keybase server, where they will supersede PGP keys that have been
previously updated. This feature is for updating PGP subkeys, identities,
Expand Down
14 changes: 14 additions & 0 deletions go/engine/track_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ func TestTrackMultiple(t *testing.T) {
trackAlice(tc, fu)
}

func TestTrackNewUserWithPGP(t *testing.T) {
tc := SetupEngineTest(t, "track")
defer tc.Cleanup()
fu := createFakeUserWithPGPSibkey(tc)
Logout(tc)

tracker := CreateAndSignupFakeUser(tc, "track")
t.Logf("first track:")
runTrack(tc, tracker, fu.Username)

t.Logf("second track:")
runTrack(tc, tracker, fu.Username)
}

// see issue #578
func TestTrackRetrack(t *testing.T) {
tc := SetupEngineTest(t, "track")
Expand Down
33 changes: 16 additions & 17 deletions go/libkb/id_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,12 @@ func trackedKeyFromJSON(jw *jsonw.Wrapper) (TrackedKey, error) {
return TrackedKey{}, err
}
ret.KID = kid
// TODO: Should we tolerate missing fingerprints? Will "body.track.key"
// ever be a non-PGP key, for example? I'm *very* hesitant about defining a
// new type that's basically a FOKID, right after we did all that work to
// delete FOKID.

// It's ok if key_fingerprint doesn't exist. But if it does, then include it:
fp, err := GetPGPFingerprint(jw.AtKey("key_fingerprint"))
if err != nil {
return TrackedKey{}, err
if err == nil && fp != nil {
ret.Fingerprint = *fp
}
ret.Fingerprint = *fp
return ret, nil
}

Expand All @@ -441,16 +438,6 @@ func (l *TrackChainLink) GetTrackedKeys() ([]TrackedKey, error) {

var res []TrackedKey

keyJSON := l.payloadJSON.AtPath("body.track.key")
if !keyJSON.IsNil() {
tracked, err := trackedKeyFromJSON(keyJSON)
if err != nil {
return nil, err
}
res = append(res, tracked)
set[tracked.KID] = true
}

pgpKeysJSON := l.payloadJSON.AtPath("body.track.pgp_keys")
if !pgpKeysJSON.IsNil() {
n, err := pgpKeysJSON.Len()
Expand All @@ -472,6 +459,18 @@ func (l *TrackChainLink) GetTrackedKeys() ([]TrackedKey, error) {
return res, nil
}

func (l *TrackChainLink) GetEldestKID() (kid keybase1.KID, err error) {
keyJSON := l.payloadJSON.AtPath("body.track.key")
if keyJSON.IsNil() {
return kid, nil
}
tracked, err := trackedKeyFromJSON(keyJSON)
if err != nil {
return kid, err
}
return tracked.KID, nil
}

func (l *TrackChainLink) GetTrackedUID() (keybase1.UID, error) {
return GetUID(l.payloadJSON.AtPath("body.track.id"))
}
Expand Down
11 changes: 11 additions & 0 deletions go/libkb/identify_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ func (s *IdentifyState) ComputeKeyDiffs(dhook func(keybase1.IdentifyKey)) {
dhook(k)
}

// first check the eldest key
observedEldest := s.u.GetEldestKID()
if s.track != nil {
trackedEldest := s.track.GetEldestKID()
if observedEldest.NotEqual(trackedEldest) {
diff := TrackDiffNewEldest{tracked: trackedEldest, observed: observedEldest}
s.res.KeyDiffs = append(s.res.KeyDiffs, diff)
display(observedEldest, diff)
}
}

found := s.u.GetActivePGPKIDs(true)
foundMap := mapify(found)
var tracked []keybase1.KID
Expand Down
29 changes: 29 additions & 0 deletions go/libkb/track.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ func (l TrackLookup) GetTrackedKeys() []TrackedKey {
return ret
}

func (l TrackLookup) GetEldestKID() keybase1.KID {
ret, err := l.link.GetEldestKID()
if err != nil {
G.Log.Warning("Error in lookup of eldest KID: %s", err)
}
return ret
}

func (l TrackLookup) IsRemote() bool {
return l.link.IsRemote()
}
Expand Down Expand Up @@ -296,6 +304,27 @@ func (t TrackDiffRemoteChanged) IsSameAsTracked() bool {
return false
}

type TrackDiffNewEldest struct {
tracked keybase1.KID
observed keybase1.KID
}

func (t TrackDiffNewEldest) BreaksTracking() bool {
return true
}
func (t TrackDiffNewEldest) IsSameAsTracked() bool {
return false
}
func (t TrackDiffNewEldest) GetTrackDiffType() keybase1.TrackDiffType {
return keybase1.TrackDiffType_NEW_ELDEST
}
func (t TrackDiffNewEldest) ToDisplayString() string {
return fmt.Sprintf("Changed from %s to %s", t.tracked, t.observed)
}
func (t TrackDiffNewEldest) ToDisplayMarkup() *Markup {
return NewMarkup(t.ToDisplayString())
}

func NewTrackLookup(link *TrackChainLink) *TrackLookup {
sbs := link.ToServiceBlocks()
set := NewTrackSet()
Expand Down
1 change: 1 addition & 0 deletions go/protocol/keybase_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,7 @@ const (
TrackDiffType_REMOTE_FAIL TrackDiffType = 6
TrackDiffType_REMOTE_WORKING TrackDiffType = 7
TrackDiffType_REMOTE_CHANGED TrackDiffType = 8
TrackDiffType_NEW_ELDEST TrackDiffType = 9
)

type TrackDiff struct {
Expand Down
3 changes: 2 additions & 1 deletion protocol/avdl/identify_common.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ protocol identifyCommon {
NEW_5,
REMOTE_FAIL_6,
REMOTE_WORKING_7,
REMOTE_CHANGED_8
REMOTE_CHANGED_8,
NEW_ELDEST_9
}

record TrackDiff {
Expand Down
15 changes: 10 additions & 5 deletions protocol/js/keybase_v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ export default {
'new': 5,
'remoteFail': 6,
'remoteWorking': 7,
'remoteChanged': 8
'remoteChanged': 8,
'newEldest': 9
},
'TrackStatus': {
'newOk': 1,
Expand Down Expand Up @@ -296,7 +297,8 @@ export default {
'new': 5,
'remoteFail': 6,
'remoteWorking': 7,
'remoteChanged': 8
'remoteChanged': 8,
'newEldest': 9
},
'TrackStatus': {
'newOk': 1,
Expand Down Expand Up @@ -608,7 +610,8 @@ export default {
'new': 5,
'remoteFail': 6,
'remoteWorking': 7,
'remoteChanged': 8
'remoteChanged': 8,
'newEldest': 9
},
'TrackStatus': {
'newOk': 1,
Expand Down Expand Up @@ -704,7 +707,8 @@ export default {
'new': 5,
'remoteFail': 6,
'remoteWorking': 7,
'remoteChanged': 8
'remoteChanged': 8,
'newEldest': 9
},
'TrackStatus': {
'newOk': 1,
Expand Down Expand Up @@ -919,7 +923,8 @@ export default {
'new': 5,
'remoteFail': 6,
'remoteWorking': 7,
'remoteChanged': 8
'remoteChanged': 8,
'newEldest': 9
},
'TrackStatus': {
'newOk': 1,
Expand Down
2 changes: 1 addition & 1 deletion protocol/json/identify.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
}, {
"type" : "enum",
"name" : "TrackDiffType",
"symbols" : [ "NONE_0", "ERROR_1", "CLASH_2", "REVOKED_3", "UPGRADED_4", "NEW_5", "REMOTE_FAIL_6", "REMOTE_WORKING_7", "REMOTE_CHANGED_8" ]
"symbols" : [ "NONE_0", "ERROR_1", "CLASH_2", "REVOKED_3", "UPGRADED_4", "NEW_5", "REMOTE_FAIL_6", "REMOTE_WORKING_7", "REMOTE_CHANGED_8", "NEW_ELDEST_9" ]
}, {
"type" : "record",
"name" : "TrackDiff",
Expand Down
2 changes: 1 addition & 1 deletion protocol/json/identify_ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
}, {
"type" : "enum",
"name" : "TrackDiffType",
"symbols" : [ "NONE_0", "ERROR_1", "CLASH_2", "REVOKED_3", "UPGRADED_4", "NEW_5", "REMOTE_FAIL_6", "REMOTE_WORKING_7", "REMOTE_CHANGED_8" ]
"symbols" : [ "NONE_0", "ERROR_1", "CLASH_2", "REVOKED_3", "UPGRADED_4", "NEW_5", "REMOTE_FAIL_6", "REMOTE_WORKING_7", "REMOTE_CHANGED_8", "NEW_ELDEST_9" ]
}, {
"type" : "record",
"name" : "TrackDiff",
Expand Down
2 changes: 1 addition & 1 deletion protocol/json/pgp.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
}, {
"type" : "enum",
"name" : "TrackDiffType",
"symbols" : [ "NONE_0", "ERROR_1", "CLASH_2", "REVOKED_3", "UPGRADED_4", "NEW_5", "REMOTE_FAIL_6", "REMOTE_WORKING_7", "REMOTE_CHANGED_8" ]
"symbols" : [ "NONE_0", "ERROR_1", "CLASH_2", "REVOKED_3", "UPGRADED_4", "NEW_5", "REMOTE_FAIL_6", "REMOTE_WORKING_7", "REMOTE_CHANGED_8", "NEW_ELDEST_9" ]
}, {
"type" : "record",
"name" : "TrackDiff",
Expand Down
2 changes: 1 addition & 1 deletion protocol/json/prove.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
}, {
"type" : "enum",
"name" : "TrackDiffType",
"symbols" : [ "NONE_0", "ERROR_1", "CLASH_2", "REVOKED_3", "UPGRADED_4", "NEW_5", "REMOTE_FAIL_6", "REMOTE_WORKING_7", "REMOTE_CHANGED_8" ]
"symbols" : [ "NONE_0", "ERROR_1", "CLASH_2", "REVOKED_3", "UPGRADED_4", "NEW_5", "REMOTE_FAIL_6", "REMOTE_WORKING_7", "REMOTE_CHANGED_8", "NEW_ELDEST_9" ]
}, {
"type" : "record",
"name" : "TrackDiff",
Expand Down
2 changes: 1 addition & 1 deletion protocol/json/track.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
}, {
"type" : "enum",
"name" : "TrackDiffType",
"symbols" : [ "NONE_0", "ERROR_1", "CLASH_2", "REVOKED_3", "UPGRADED_4", "NEW_5", "REMOTE_FAIL_6", "REMOTE_WORKING_7", "REMOTE_CHANGED_8" ]
"symbols" : [ "NONE_0", "ERROR_1", "CLASH_2", "REVOKED_3", "UPGRADED_4", "NEW_5", "REMOTE_FAIL_6", "REMOTE_WORKING_7", "REMOTE_CHANGED_8", "NEW_ELDEST_9" ]
}, {
"type" : "record",
"name" : "TrackDiff",
Expand Down