Skip to content

Commit

Permalink
wot vouch cli fills in failing_proofs (keybase#23092)
Browse files Browse the repository at this point in the history
* wot cli fills in failing_proofs

* rm unused
  • Loading branch information
mlsteele authored Mar 17, 2020
1 parent 38faed9 commit 9cd6bdd
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 25 deletions.
6 changes: 5 additions & 1 deletion go/client/cmd_wot_vouch.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/keybase/client/go/libcmdline"
"github.com/keybase/client/go/libkb"
keybase1 "github.com/keybase/client/go/protocol/keybase1"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)

Expand Down Expand Up @@ -80,12 +81,15 @@ func (c *cmdWotVouch) ParseArgv(ctx *cli.Context) error {
}

func (c *cmdWotVouch) Run() error {
protocols := []rpc.Protocol{NewIdentifyUIProtocol(c.G())}
if err := RegisterProtocolsWithContext(protocols, c.G()); err != nil {
return err
}
arg := keybase1.WotVouchCLIArg{
Assertion: c.assertion,
VouchTexts: []string{c.message},
Confidence: c.confidence,
}

cli, err := GetWebOfTrustClient(c.G())
if err != nil {
return err
Expand Down
34 changes: 34 additions & 0 deletions go/engine/identify2_with_uid.go
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,40 @@ func (e *Identify2WithUID) Result(m libkb.MetaContext) (*keybase1.Identify2ResUP
return res, nil
}

func (e *Identify2WithUID) ResultWotFailingProofs(mctx libkb.MetaContext) (failingProofs []keybase1.WotProof, err error) {
for _, row := range e.state.Result().ProofChecks {
if row.GetError() != nil {
proofType := row.GetLink().GetProofType()
key, value := row.GetLink().ToKeyValuePair()
switch proofType {
case keybase1.ProofType_TWITTER, keybase1.ProofType_GITHUB, keybase1.ProofType_REDDIT,
keybase1.ProofType_COINBASE, keybase1.ProofType_HACKERNEWS, keybase1.ProofType_FACEBOOK,
keybase1.ProofType_GENERIC_SOCIAL, keybase1.ProofType_ROOTER:
failingProofs = append(failingProofs, keybase1.WotProof{
ProofType: proofType,
Name: key,
Username: value,
})
case keybase1.ProofType_GENERIC_WEB_SITE:
failingProofs = append(failingProofs, keybase1.WotProof{
ProofType: proofType,
Protocol: key,
Hostname: value,
})
case keybase1.ProofType_DNS:
failingProofs = append(failingProofs, keybase1.WotProof{
ProofType: proofType,
Protocol: key,
Domain: value,
})
default:
return nil, fmt.Errorf("unexpected proof failure of type: %v", proofType)
}
}
}
return failingProofs, nil
}

func (e *Identify2WithUID) GetProofSet() *libkb.ProofSet {
return e.remotesReceived
}
Expand Down
7 changes: 7 additions & 0 deletions go/engine/resolve_identify2.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ func (e *ResolveThenIdentify2) Result(m libkb.MetaContext) (*keybase1.Identify2R
return e.i2eng.Result(m)
}

func (e *ResolveThenIdentify2) ResultWotFailingProofs(mctx libkb.MetaContext) (failingProofs []keybase1.WotProof, err error) {
if e.i2eng == nil {
return nil, errors.New("ResolveThenIdentify2#ResultWotFailingProofs: no result available if the engine did not run")
}
return e.i2eng.ResultWotFailingProofs(mctx)
}

func (e *ResolveThenIdentify2) SetResponsibleGregorItem(item gregor.Item) {
e.responsibleGregorItem = item
}
Expand Down
22 changes: 16 additions & 6 deletions go/engine/wot_vouch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (
)

type WotVouchArg struct {
Vouchee keybase1.UserVersion
Confidence keybase1.Confidence
VouchTexts []string
Vouchee keybase1.UserVersion
Confidence keybase1.Confidence
FailingProofs []keybase1.WotProof
VouchTexts []string
}

// WotVouch is an engine.
Expand Down Expand Up @@ -85,16 +86,25 @@ func (e *WotVouch) Run(mctx libkb.MetaContext) error {
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
}
confidenceJw, err := jsonw.WrapperFromObject(e.arg.Confidence)
if err != nil {
return err
}
if err := statement.SetKey("confidence", confidenceJw); err != nil {
return err
}
if len(e.arg.FailingProofs) > 0 {
failingProofsJw, err := jsonw.WrapperFromObject(e.arg.FailingProofs)
if err != nil {
return err
}
if err := statement.SetKey("failing_proofs", failingProofsJw); err != nil {
return err
}
}
if err := statement.SetKey("vouch_text", libkb.JsonwStringArray(e.arg.VouchTexts)); err != nil {
return err
}
expansions, sum, err := libkb.EmbedExpansionObj(statement)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions go/protocol/keybase1/wot.go

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

52 changes: 40 additions & 12 deletions go/service/wot.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (h *WebOfTrustHandler) WotVouch(ctx context.Context, arg keybase1.WotVouchA
mctx := libkb.NewMetaContext(ctx, h.G())

earg := &engine.WotVouchArg{
Vouchee: arg.Uv,
Vouchee: arg.Vouchee,
VouchTexts: arg.VouchTexts,
Confidence: arg.Confidence,
}
Expand All @@ -40,21 +40,49 @@ func (h *WebOfTrustHandler) WotVouchCLI(ctx context.Context, arg keybase1.WotVou
ctx = libkb.WithLogTag(ctx, "WOT")
mctx := libkb.NewMetaContext(ctx, h.G())

// TODO PICNIC-875 fill in FailingProofs by ID-ing the vouchee.

upak, _, err := h.G().GetUPAKLoader().Load(libkb.NewLoadUserArg(h.G()).WithName(arg.Assertion))
if err != nil {
return err
}

earg := &engine.WotVouchArg{
Vouchee: upak.Base.ToUserVersion(),
VouchTexts: arg.VouchTexts,
Confidence: arg.Confidence,
eng := engine.NewResolveThenIdentify2(mctx.G(), &keybase1.Identify2Arg{
Uid: upak.GetUID(),
UserAssertion: arg.Assertion,
NeedProofSet: true,
UseDelegateUI: true,
Reason: keybase1.IdentifyReason{Reason: fmt.Sprintf("Vouch for %v", arg.Assertion)},
IdentifyBehavior: keybase1.TLFIdentifyBehavior_CLI,
})
err = engine.RunEngine2(mctx.WithUIs(libkb.UIs{
IdentifyUI: h.NewRemoteIdentifyUI(arg.SessionID, mctx.G()),
}), eng)
if err != nil {
return err
}

eng := engine.NewWotVouch(h.G(), earg)
return engine.RunEngine2(mctx, eng)
idRes, err := eng.Result(mctx)
if err != nil {
return err
}
if idRes == nil {
return fmt.Errorf("missing identify result")
}
if idRes.TrackBreaks != nil {
mctx.Debug("WotVouchCLI TrackBreaks: %+v", idRes.TrackBreaks)
return libkb.TrackingBrokeError{}
}
failingProofs, err := eng.ResultWotFailingProofs(mctx)
if err != nil {
return err
}
for i, proof := range failingProofs {
mctx.Debug("WotVouchCLI failingProofs %v/%v %+v", i+1, len(failingProofs), proof)
}
return engine.RunEngine2(mctx, engine.NewWotVouch(h.G(), &engine.WotVouchArg{
Vouchee: idRes.Upk.Current.ToUserVersion(),
Confidence: arg.Confidence,
FailingProofs: failingProofs,
VouchTexts: arg.VouchTexts,
}))
}

func (h *WebOfTrustHandler) WotListCLI(ctx context.Context, arg keybase1.WotListCLIArg) (res []keybase1.WotVouch, err error) {
Expand All @@ -71,7 +99,7 @@ func (h *WebOfTrustHandler) WotReact(ctx context.Context, arg keybase1.WotReactA
mctx := libkb.NewMetaContext(ctx, h.G())

earg := &engine.WotReactArg{
Voucher: arg.Uv,
Voucher: arg.Voucher,
Proof: arg.Proof,
Reaction: arg.Reaction,
}
Expand Down Expand Up @@ -123,7 +151,7 @@ func (h *WebOfTrustHandler) WotReactCLI(ctx context.Context, arg keybase1.WotRea

rarg := keybase1.WotReactArg{
SessionID: arg.SessionID,
Uv: expectedVoucher,
Voucher: expectedVoucher,
Proof: reactingVouch.VouchProof,
Reaction: arg.Reaction,
}
Expand Down
4 changes: 2 additions & 2 deletions protocol/avdl/keybase1/wot.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ protocol wot {
string other;
}

void wotVouch(int sessionID, UserVersion uv /* vouchee */, array<string> vouchTexts, Confidence confidence);
void wotVouch(int sessionID, UserVersion vouchee, array<string> vouchTexts, Confidence confidence);
void wotVouchCLI(int sessionID, string assertion, array<string> vouchTexts, Confidence confidence);

enum WotReactionType {
ACCEPT_0,
REJECT_1
}
void wotReact(int sessionID, UserVersion uv /* voucher */, SigID proof, WotReactionType reaction);
void wotReact(int sessionID, UserVersion voucher, SigID proof, WotReactionType reaction);
void wotReactCLI(int sessionID, string username /* voucher */, WotReactionType reaction);

record WotVouch {
Expand Down
4 changes: 2 additions & 2 deletions protocol/json/keybase1/wot.json

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

0 comments on commit 9cd6bdd

Please sign in to comment.