Skip to content

Commit

Permalink
WOT update (keybase#23006)
Browse files Browse the repository at this point in the history
* list subcommands

* comment

* update fields

* cli

* more

* upgrade avdl-compiler

* note
  • Loading branch information
mlsteele authored Mar 12, 2020
1 parent 16a321f commit c93be50
Show file tree
Hide file tree
Showing 163 changed files with 329 additions and 292 deletions.
3 changes: 1 addition & 2 deletions go/client/cmd_wot_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ func newCmdWotList(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Comma
Action: func(c *cli.Context) {
cl.ChooseCommand(cmd, "list", c)
},
Flags: []cli.Flag{},
Unlisted: true,
Flags: []cli.Flag{},
}
}

Expand Down
3 changes: 1 addition & 2 deletions go/client/cmd_wot_react.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ func newCmdWotAccept(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Com
Action: func(c *cli.Context) {
cl.ChooseCommand(cmd, "accept", c)
},
Flags: flags,
Unlisted: true,
Flags: flags,
}
}

Expand Down
45 changes: 15 additions & 30 deletions go/client/cmd_wot_vouch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client

import (
"errors"
"fmt"
"strings"

"github.com/keybase/cli"
Expand All @@ -18,28 +19,23 @@ type cmdWotVouch struct {
libkb.Contextified
}

// Keep in sync with wot.avdl
const verifiedViaChoices = "in_person, proofs, video, audio, other_chat, familiar, other"

func newCmdWotVouch(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
flags := []cli.Flag{
cli.StringFlag{
Name: "m, message",
Usage: "A message about this user",
},
cli.StringFlag{
Name: "vouched-by",
Usage: "Comma-separated list of keybase users who vouched for this user",
},
cli.StringFlag{
Name: "verified-via",
Usage: "How you verified their identity: audio, video, email, other_chat, in_person",
Usage: fmt.Sprintf("How you verified their identity: %s", verifiedViaChoices),
},
cli.StringFlag{
Name: "other",
Usage: "Other information about your confidence in knowing this user",
},
cli.IntFlag{
Name: "known-for",
Usage: "Number of days you have known this user on keybase",
},
}
cmd := &cmdWotVouch{
Contextified: libkb.NewContextified(g),
Expand All @@ -51,8 +47,7 @@ func newCmdWotVouch(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Comm
Action: func(c *cli.Context) {
cl.ChooseCommand(cmd, "vouch", c)
},
Flags: flags,
Unlisted: true,
Flags: flags,
}
}

Expand All @@ -65,29 +60,19 @@ func (c *cmdWotVouch) ParseArgv(ctx *cli.Context) error {
if len(c.message) == 0 {
return errors.New("vouch requires an attestation e.g. `-m \"Alice plays the banjo\"`")
}
kf := ctx.Int("known-for")
if kf > 0 {
c.confidence.KnownOnKeybaseDays = kf
}
via := ctx.String("verified-via")
if via != "" {
viaType, ok := keybase1.UsernameVerificationTypeMap[strings.ToLower(via)]
if !ok {
return errors.New("invalid verified-via option")
}
c.confidence.UsernameVerifiedVia = viaType
if via == "" {
return errors.New("verified-via is required")
}
vouchingUsernamesRaw := ctx.String("verified-via")
if vouchingUsernamesRaw != "" {
vouchingUsernames := strings.Split(vouchingUsernamesRaw, ",")
var vouchers []keybase1.UID
for _, username := range vouchingUsernames {
uid := libkb.UsernameToUID(username)
vouchers = append(vouchers, uid)
}
c.confidence.VouchedBy = vouchers
viaType, ok := keybase1.UsernameVerificationTypeMap[strings.ToLower(via)]
if !ok {
return fmt.Errorf("invalid verified-via value '%v'. Expected one of: %v", via, verifiedViaChoices)
}
c.confidence.UsernameVerifiedVia = viaType
other := ctx.String("other")
if (other != "") != (c.confidence.UsernameVerifiedVia == keybase1.UsernameVerificationType_OTHER) {
return errors.New("--other must be paired with --verified-via 'other'")
}
if other != "" {
c.confidence.Other = ctx.String("other")
}
Expand Down
42 changes: 22 additions & 20 deletions go/engine/wot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestWebOfTrustVouch(t *testing.T) {
// fu1 vouches for fu2
arg := &WotVouchArg{
Vouchee: fu2.User.ToUserVersion(),
Confidence: keybase1.Confidence{UsernameVerifiedVia: keybase1.UsernameVerificationType_OTHER_CHAT},
VouchTexts: []string{"alice is awesome"},
}

Expand All @@ -69,6 +70,7 @@ func TestWebOfTrustVouch(t *testing.T) {
uv.EldestSeqno++
arg = &WotVouchArg{
Vouchee: uv,
Confidence: keybase1.Confidence{UsernameVerifiedVia: keybase1.UsernameVerificationType_OTHER_CHAT},
VouchTexts: []string{"bob is nice"},
}
eng = NewWotVouch(tc1.G, arg)
Expand All @@ -84,11 +86,7 @@ func TestWebOfTrustVouch(t *testing.T) {
arg = &WotVouchArg{
Vouchee: fu3.User.ToUserVersion(),
VouchTexts: []string{"charlie rocks"},
Confidence: keybase1.Confidence{
UsernameVerifiedVia: keybase1.UsernameVerificationType_VIDEO,
VouchedBy: []keybase1.UID{keybase1.UID("c4c565570e7e87cafd077509abf5f619")}, // t_doug
KnownOnKeybaseDays: 78,
},
Confidence: confidence,
}
eng = NewWotVouch(tc1.G, arg)
err = RunEngine2(mctx, eng)
Expand Down Expand Up @@ -135,6 +133,7 @@ func TestWebOfTrustPending(t *testing.T) {
vouchTexts := []string{firstVouch}
arg := &WotVouchArg{
Vouchee: alice.User.ToUserVersion(),
Confidence: keybase1.Confidence{UsernameVerifiedVia: keybase1.UsernameVerificationType_OTHER_CHAT},
VouchTexts: vouchTexts,
}
eng := NewWotVouch(tcBob.G, arg)
Expand All @@ -148,7 +147,8 @@ func TestWebOfTrustPending(t *testing.T) {
bobVouch := vouches[0]
require.Equal(t, bob.User.GetUID(), bobVouch.Voucher.Uid)
require.Equal(t, vouchTexts, bobVouch.VouchTexts)
require.Nil(t, bobVouch.Confidence)
require.NotNil(t, bobVouch.Confidence)
require.EqualValues(t, keybase1.UsernameVerificationType_OTHER_CHAT, bobVouch.Confidence.UsernameVerifiedVia)
require.Equal(t, keybase1.WotStatusType_PROPOSED, bobVouch.Status)
t.Log("alice sees one pending vouch")
vouches, err = libkb.FetchUserWot(mctxB, alice.User.GetName())
Expand All @@ -169,11 +169,6 @@ func TestWebOfTrustPending(t *testing.T) {
t.Log("alice and charlie follow each other")

vouchTexts = []string{"alice is wondibar and doug agrees"}
confidence := keybase1.Confidence{
UsernameVerifiedVia: keybase1.UsernameVerificationType_VIDEO,
VouchedBy: []keybase1.UID{keybase1.UID("c4c565570e7e87cafd077509abf5f619")}, // t_doug
KnownOnKeybaseDays: 78,
}
arg = &WotVouchArg{
Vouchee: alice.User.ToUserVersion(),
VouchTexts: vouchTexts,
Expand Down Expand Up @@ -223,11 +218,6 @@ func TestWebOfTrustAccept(t *testing.T) {
t.Log("alice and bob follow each other")

vouchTexts := []string{"alice is wondibar and doug agrees"}
confidence := keybase1.Confidence{
UsernameVerifiedVia: keybase1.UsernameVerificationType_VIDEO,
VouchedBy: []keybase1.UID{keybase1.UID("c4c565570e7e87cafd077509abf5f619")}, // t_doug
KnownOnKeybaseDays: 25,
}
argV := &WotVouchArg{
Vouchee: alice.User.ToUserVersion(),
VouchTexts: vouchTexts,
Expand Down Expand Up @@ -300,13 +290,13 @@ func TestWebOfTrustReject(t *testing.T) {
vouchTexts := []string{"alice is wondibar"}
argV := &WotVouchArg{
Vouchee: alice.User.ToUserVersion(),
Confidence: keybase1.Confidence{UsernameVerifiedVia: keybase1.UsernameVerificationType_OTHER_CHAT},
VouchTexts: vouchTexts,
// no confidence
}
engV := NewWotVouch(tcBob.G, argV)
err = RunEngine2(mctxB, engV)
require.NoError(t, err)
t.Log("bob vouches for alice without confidence")
t.Log("bob vouches for alice")

vouches, err := libkb.FetchMyWot(mctxA)
require.NoError(t, err)
Expand Down Expand Up @@ -334,7 +324,8 @@ func TestWebOfTrustReject(t *testing.T) {
require.Equal(t, keybase1.WotStatusType_REJECTED, vouch.Status)
require.Equal(t, bob.User.GetUID(), vouch.Voucher.Uid)
require.Equal(t, vouchTexts, vouch.VouchTexts)
require.Nil(t, vouch.Confidence)
require.NotNil(t, vouch.Confidence)
require.EqualValues(t, keybase1.UsernameVerificationType_OTHER_CHAT, bobVouch.Confidence.UsernameVerifiedVia)
t.Log("alice can see it as rejected")

vouches, err = libkb.FetchUserWot(mctxB, alice.User.GetName())
Expand Down Expand Up @@ -366,10 +357,11 @@ func TestWebOfTrustSigBug(t *testing.T) {
t.Log("alice and bob follow each other")

// bob vouches for alice
firstVouch := "alice is wondibar but i don't have much confidence"
firstVouch := "alice is wondibar cause we texted"
vouchTexts := []string{firstVouch}
argV := &WotVouchArg{
Vouchee: alice.User.ToUserVersion(),
Confidence: keybase1.Confidence{UsernameVerifiedVia: keybase1.UsernameVerificationType_OTHER_CHAT},
VouchTexts: vouchTexts,
}
engV := NewWotVouch(tcBob.G, argV)
Expand Down Expand Up @@ -404,3 +396,13 @@ func TestWebOfTrustSigBug(t *testing.T) {
bobVouch = vouches[0]
require.Equal(t, bobVouch.Status, keybase1.WotStatusType_PROPOSED)
}

var confidence = keybase1.Confidence{
UsernameVerifiedVia: keybase1.UsernameVerificationType_PROOFS,
Proofs: []keybase1.WotProof{
{ProofType: keybase1.ProofType_REDDIT, Name: "reddit", Username: "betaveros"},
{ProofType: keybase1.ProofType_GENERIC_SOCIAL, Name: "mastodon.social", Username: "gammaveros"},
{ProofType: keybase1.ProofType_GENERIC_WEB_SITE, Protocol: "https:", Username: "beta.veros"},
{ProofType: keybase1.ProofType_DNS, Protocol: "dns", Username: "beta.veros"},
},
}
24 changes: 23 additions & 1 deletion go/engine/wot_vouch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package engine

import (
"errors"
"fmt"

"github.com/keybase/client/go/libkb"
keybase1 "github.com/keybase/client/go/protocol/keybase1"
Expand Down Expand Up @@ -63,14 +64,35 @@ func (e *WotVouch) Run(mctx libkb.MetaContext) error {
return errors.New("vouchee has reset, make sure you still know them")
}

if e.arg.Confidence.UsernameVerifiedVia == "" {
return errors.New("missing UsernameVerifiedVia")
}
if _, found := keybase1.UsernameVerificationTypeMap[string(e.arg.Confidence.UsernameVerifiedVia)]; !found {
return fmt.Errorf("unrecognized UsernameVerificationTypeMap value '%v'", e.arg.Confidence.UsernameVerifiedVia)
}

if e.arg.Confidence.UsernameVerifiedVia == keybase1.UsernameVerificationType_PROOFS {
if len(e.arg.Confidence.Proofs) == 0 {
return errors.New("vouching with proofs requires proofs list")
}
} else {
if len(e.arg.Confidence.Proofs) > 0 {
return errors.New("vouching with proof list requires proof type")
}
}

statement := jsonw.NewDictionary()
if err := statement.SetKey("user", them.ToWotStatement()); err != nil {
return err
}
if err := statement.SetKey("vouch_text", libkb.JsonwStringArray(e.arg.VouchTexts)); err != nil {
return err
}
if err := statement.SetKey("confidence", e.arg.Confidence.ToJsonw()); err != nil {
confidenceJw, err := jsonw.WrapperFromObject(e.arg.Confidence)
if err != nil {
return err
}
if err := statement.SetKey("confidence", confidenceJw); err != nil {
return err
}
expansions, sum, err := libkb.EmbedExpansionObj(statement)
Expand Down
2 changes: 1 addition & 1 deletion go/protocol/chat1/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/protocol/chat1/blocking.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/protocol/chat1/chat_ui.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/protocol/chat1/commands.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/protocol/chat1/common.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/protocol/chat1/gregor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/protocol/chat1/local.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/protocol/chat1/notify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/protocol/chat1/remote.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/protocol/chat1/unfurl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/protocol/gregor1/auth.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.6 (https://github.com/keybase/node-avdl-compiler)
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.8 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/gregor1/auth.avdl

package gregor1
Expand Down
2 changes: 1 addition & 1 deletion go/protocol/gregor1/auth_internal.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.6 (https://github.com/keybase/node-avdl-compiler)
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.8 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/gregor1/auth_internal.avdl

package gregor1
Expand Down
2 changes: 1 addition & 1 deletion go/protocol/gregor1/auth_update.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.6 (https://github.com/keybase/node-avdl-compiler)
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.8 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/gregor1/auth_update.avdl

package gregor1
Expand Down
2 changes: 1 addition & 1 deletion go/protocol/gregor1/common.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.6 (https://github.com/keybase/node-avdl-compiler)
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.8 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/gregor1/common.avdl

package gregor1
Expand Down
2 changes: 1 addition & 1 deletion go/protocol/gregor1/incoming.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.6 (https://github.com/keybase/node-avdl-compiler)
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.8 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/gregor1/incoming.avdl

package gregor1
Expand Down
2 changes: 1 addition & 1 deletion go/protocol/gregor1/outgoing.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.6 (https://github.com/keybase/node-avdl-compiler)
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.8 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/gregor1/outgoing.avdl

package gregor1
Expand Down
2 changes: 1 addition & 1 deletion go/protocol/gregor1/remind.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.6 (https://github.com/keybase/node-avdl-compiler)
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.8 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/gregor1/remind.avdl

package gregor1
Expand Down
2 changes: 1 addition & 1 deletion go/protocol/kbgitkbfs1/disk_block_cache.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.6 (https://github.com/keybase/node-avdl-compiler)
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.8 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/kbgitkbfs1/disk_block_cache.avdl

package kbgitkbfs1
Expand Down
2 changes: 1 addition & 1 deletion go/protocol/keybase1/account.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/protocol/keybase1/airdrop.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c93be50

Please sign in to comment.