id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c28800
string) error { return nil }
c28801
remote string) error { return nil }
c28802
nil, fmt.Errorf("not yet implemented for %s", g.Name()) }
c28803
context.WithValue(ctx, ctxKeyPassPromptFunc, ppf) }
c28804
ctx.Value(ctxKeyPassPromptFunc).(PassPromptFunc) return ok && ppf != nil }
c28805
path = prefix + sep + path } tpls[path] = struct{}{} } out := make([]string, 0, len(tpls)) for k := range tpls { out = append(out, k) } sort.Strings(out) return out }
c28806
strings.TrimPrefix(filepath.Join(name, TemplateFile), string(filepath.Separator)) }
c28807
return s.storage.Exists(ctx, s.templatefile(name)) }
c28808
return s.storage.Get(ctx, s.templatefile(name)) }
c28809
p } } else if runtime.GOOS == "windows" { // only trim if this is a local path, e. g. file:///C:/Users/... // (specified in https://blogs.msdn.microsoft.com/ie/2006/12/06/file-uris-in-windows/) // In that case, u.Path will contain a leading slash. // (correctly, as per RFC 3986, see https://github.com/golan...
c28810
umf(&path); err != nil { return err } um, err := ParseURL(path) if err != nil { return err } *u = *um return nil }
c28811
backend.GetRCSBackend(ctx), s.url.Path, un, ue) if err != nil { return err } s.rcs = rcs return nil }
c28812
p := s.passfile(name) return s.rcs.Revisions(ctx, p) }
c28813
if err != nil { out.Debug(ctx, "Decryption failed: %s", err) return nil, store.ErrDecrypt } sec, err := secret.Parse(content) if err != nil { out.Debug(ctx, "Failed to parse YAML: %s", err) } return sec, nil }
c28814
return false } switch k.Validity { case "m": return true case "f": return true case "u": return true } return false }
c28815
if !k.ExpirationDate.IsZero() { out += fmt.Sprintf(" [expires: %s]", k.ExpirationDate.Format("2006-01-02")) } out += "\n Key fingerprint = " + k.Fingerprint for _, id := range k.Identities { out += fmt.Sprintf("\n" + id.String()) } return out }
c28816
append(ids, i) } sort.Slice(ids, func(i, j int) bool { return ids[i].CreationDate.After(ids[j].CreationDate) }) for _, i := range ids { return i } return Identity{} }
c28817
return fmt.Sprintf("0x%s", k.Fingerprint[24:]) }
c28818
clone repo [mount]", s.Name) } repo := c.Args()[0] mount := "" if len(c.Args()) > 1 { mount = c.Args()[1] } path := c.String("path") return s.clone(ctx, repo, mount, path) }
c28819
{ l = append(l, k.ID()) } sort.Strings(l) return l }
c28820
if ident.Email == id { return k, nil } } for sk := range k.SubKeys { if strings.HasSuffix(sk, id) { return k, nil } } } return Key{}, errors.Errorf("No matching key found") }
c28821
x.encryptHeader(ctx, privKey, sessionKey[:], recipients) if err != nil { return errors.Wrapf(err, "failed to encrypt header: %s", err) } // create the encoder enc := binary.NewEncoder(ciphertext) // write verion if err := enc.Encode(0x1); err != nil { return err } // write header if err := enc.Encode(he...
c28822
in the header sk, err := x.decryptSessionKey(ctx, header) if err != nil { return err } var secretKey [32]byte copy(secretKey[:], sk) // read body num := 0 var buf []byte br := &byteReader{ciphertext} for { l, err := stdbin.ReadUvarint(br) if err != nil { if err == io.EOF { return nil } r...
c28823
out.Debug(ctx, "Stacktrace: %+v", err) } return cli.NewExitError(fmt.Sprintf(format, args...), exitCode) }
c28824
} // It is not possible to perform concurrent git add and git commit commands // so we need to skip this step when using concurrency and perform them // at the end of the batch processing. if ctxutil.HasConcurrency(ctx) { out.Debug(ctx, "sub.Set(%s) - skipping git ops due to concurrency", p) return nil } ...
c28825
return errors.Wrapf(err, "failed to decrypt '%s'", from) } if err := s.Set(WithReason(ctx, fmt.Sprintf("Moved from %s to %s", from, to)), to, content); err != nil { return errors.Wrapf(err, "failed to write '%s'", to) } if err := s.Delete(ctx, from); err != nil { return errors.Wrapf(err, "failed to delete '%s'...
c28826
// abort if auto sync is not set if !IsAutoSync(ctx) { return nil } if err := s.rcs.Push(ctx, "", ""); err != nil { if errors.Cause(err) == store.ErrGitNotInit || errors.Cause(err) == store.ErrGitNoRemote { return nil } return errors.Wrapf(err, "failed to push change to git remote") } return nil }
c28827
sv semver.Version) (*Action, error) { return newAction(ctx, cfg, sv) }
c28828
:= []string{"--batch", "--gen-key"} cmd := exec.CommandContext(ctx, g.binary, args...) cmd.Stdin = bytes.NewReader(buf.Bytes()) cmd.Stdout = nil cmd.Stderr = nil out.Debug(ctx, "gpg.CreatePrivateKeyBatch: %s %+v", cmd.Path, cmd.Args) if err := cmd.Run(); err != nil { return errors.Wrapf(err, "failed to run co...
c28829
!= nil { return errors.Wrapf(err, "failed to run command: '%s %+v'", cmd.Path, cmd.Args) } g.privKeys = nil g.pubKeys = nil return nil }
c28830
} if err := ioutil.WriteFile(filepath.Join(g.path, ".gitattributes"), []byte("*.gpg diff=gpg\n"), fileMode); err != nil { return errors.Errorf("Failed to initialize git: %s", err) } if err := g.Add(ctx, g.path+"/.gitattributes"); err != nil { out.Yellow(ctx, "Warning: Failed to add .gitattributes to git") } ...
c28831
g.Cmd(ctx, "gitConfigSet", "config", "--local", key, value) }
c28832
out.Debug(ctx, "store.gitConfigGet: %s %+v", cmd.Path, cmd.Args) if err := cmd.Run(); err != nil { return "", err } return strings.TrimSpace(buf.String()), nil }
c28833
out.Debug(ctx, "store.gitConfigList: %s %+v", cmd.Path, cmd.Args) if err := cmd.Run(); err != nil { return nil, err } lines := strings.Split(buf.String(), "\n") kv := make(map[string]string, len(lines)) for _, line := range lines { line = strings.TrimSpace(line) p := strings.SplitN(line, "=", 2) if len...
c28834
ExitList, err, "failed to list recipients: %s", err) } fmt.Fprintln(stdout, tree.Format(0)) return nil }
c28835
fmt.Fprintln(stdout, err) return } for _, v := range tree.List(0) { fmt.Fprintln(stdout, v) } }
c28836
continue } recp := r if len(keys) > 0 { recp = crypto.Fingerprint(ctx, keys[0]) } if !termio.AskForConfirmation(ctx, fmt.Sprintf("Do you want to add '%s' as a recipient to the store '%s'?", crypto.FormatKey(ctx, recp), store)) { continue } if err := s.Store.AddRecipient(ctxutil.WithNoConfirm(c...
c28837
out.Cyan(ctx, "WARNING: Failed to list public key '%s': %s", r, err) if !force { continue } keys = []string{r} } if len(keys) < 1 && !force { out.Cyan(ctx, "Warning: No matching valid key found. If the key is in your keyring you may need to validate it.") out.Cyan(ctx, "If this is your key: g...
c28838
s.cfg.GetRecipientHash(alias, subs.Crypto().IDFile()) != "" { continue } if alias == "" { alias = "<root>" } out.Cyan(ctx, "Please confirm Recipients for %s:", alias) for _, r := range recp { out.Print(ctx, "- %s", subs.Crypto().FormatKey(ctx, r)) } if !termio.AskForConfirmation(ctx, fmt.Sprintf...
c28839
} qrf := c.String("qr") clip := c.Bool("clip") return s.otp(ctx, c, name, qrf, clip, true) }
c28840
by some adversary // decryption will fail var nonce [24]byte binary.BigEndian.PutUint64(nonce[:], uint64(i)) // decrypt and verify the ciphertext //plaintext, err := cp.Open(nil, nonce, chunk.Body, nil) plaintext, ok := secretbox.Open(nil, chunk.Body, &nonce, &secretKey) if !ok { return nil, fmt.Erro...
c28841
if _, found := hdr.Recipients[pk]; found { return x.secring.Get(pk), nil } } return nil, fmt.Errorf("no decryption key found for: %+v", hdr.Recipients) }
c28842
return x.pubring.Get(id), nil } } return nil, fmt.Errorf("no sender found for id '%s'", needle) }
c28843
return nil } // decryption failed, clear cache and wait a moment before trying again if err := x.client.Remove(ctx, fp); err != nil { return errors.Wrapf(err, "failed to clear cache") } time.Sleep(10 * time.Millisecond) } return fmt.Errorf("failed to unlock private key '%s' after %d retries", fp, ma...
c28844
to fixed arrays var nonce [24]byte copy(nonce[:], ciphertext[:24]) var privKey [32]byte pk := recp.PrivateKey() copy(privKey[:], pk[:]) // now we can try to decrypt/verify the ciphertext. unfortunately box doesn't give // us any diagnostic information in case it fails, i.e. we can't discern between // a fail...
c28845
if err := s.cfg.Save(); err != nil { return ExitError(ctx, ExitConfig, err, "failed to write config: %s", err) } out.Green(ctx, "Password Store %s umounted", c.Args()[0]) return nil }
c28846
path := mounts[alias] if err := root.AddMount(alias, path); err != nil { out.Error(ctx, "Failed to add mount to tree: %s", err) } } fmt.Fprintln(stdout, root.Format(0)) return nil }
c28847
s.Store.Mounts() { fmt.Fprintln(stdout, alias) } }
c28848
!= nil { switch e := errors.Cause(err).(type) { case root.AlreadyMountedError: out.Print(ctx, "Store is already mounted") return nil case root.NotInitializedError: out.Print(ctx, "Mount %s is not yet initialized. Initializing ...", e.Alias()) if err := s.init(ctx, e.Alias(), e.Path()); err != nil { ...
c28849
needle := range keys { if strings.HasSuffix(r, needle) { res = append(res, r) } } } return res, nil }
c28850
return staticPrivateKeyList.Recipients(), nil }
c28851
[]byte, recipients []string) ([]byte, error) { return content, nil }
c28852
ciphertext []byte) ([]byte, error) { return ciphertext, nil }
c28853
hexsum := fmt.Sprintf("%X", sum.Sum(nil)) return ioutil.WriteFile(sigf, []byte(hexsum), 0644) }
c28854
_, _ = sum.Write(buf) hexsum := fmt.Sprintf("%X", sum.Sum(nil)) if string(sigb) != hexsum { return fmt.Errorf("hashsum mismatch") } return nil }
c28855
{ return []string{"unsupported"}, nil }
c28856
path string) (backend.RCS, error) { return Clone(ctx, repo, path) }
c28857
if err := cmd.Run(); err != nil { return errors.Wrapf(err, "failed to run command: '%s %+v'", cmd.Path, cmd.Args) } // clear key cache g.privKeys = nil g.pubKeys = nil return nil }
c28858
is in s.binaryCopy if err := binaryCopy(ctx, c, from, to, false, store); err != nil { return action.ExitError(ctx, action.ExitUnknown, err, "%s", err) } return nil }
c28859
goprogressbar.Stdout = ioutil.Discard defer func() { goprogressbar.Stdout = old }() } ctx = ctxutil.WithProgressCallback(ctx, func() { bar.Current++ bar.Text = fmt.Sprintf("%d of %d objects checked", bar.Current, bar.Total) bar.LazyPrint() }) ctx = out.AddPrefix(ctx, "\n") // the main work in done ...
c28860
errors.Errorf("GOOS %s not yet supported", runtime.GOOS) }
c28861
!= nil { return nil, errors.Wrapf(err, "failed to run command '%s %+v'", cmd.Path, cmd.Args) } if len(out) < 1 { return nil, errors.Errorf("Key not found") } return out, nil }
c28862
64); err == nil { t = time.Unix(sec, 0) } return t }
c28863
err == nil { i = int(iv) } return i }
c28864
{ if opts := os.Getenv(en); opts != "" { return strings.Fields(opts) } } return nil }
c28865
string) bool { _, err := s.Get(ctx, name) return err == nil }
c28866
} if sec == nil || sec.Data == nil { return nil, fmt.Errorf("not found") } return &Secret{d: sec.Data}, nil }
c28867
err := s.List(ctx, "") return err == nil }
c28868
err != nil { return false } return len(ls) > 1 }
c28869
:= range keys { keys[i] = path.Join(s.alias, e) } return keys, nil }
c28870
s.Get(ctx, from) if err != nil { return errors.Wrapf(err, "failed to decrypt '%s'", from) } if err := s.Set(ctx, to, content); err != nil { return errors.Wrapf(err, "failed to write '%s'", to) } if err := s.Delete(ctx, from); err != nil { return errors.Wrapf(err, "failed to delete '%s'", from) } return ni...
c28871
} d[passwordKey] = sec.Password() _, err := s.api.Logical().Write(path.Join(s.path, name), d) return err }
c28872
ls { if err := s.Delete(ctx, e); err != nil { return err } } return nil }
c28873
if err != nil { return 0, err } if str == "q" { return 0, ErrAborted } intVal, err := strconv.Atoi(str) if err != nil { return 0, errors.Wrapf(err, "failed to convert to number") } return intVal, nil }
c28874
the public key '%s' (Names: %+v) into your keyring?", key, names), false) if err != nil { return false } return ok }
c28875
passAgain, err := askFn(ctx, fmt.Sprintf("Retype password for %s", name)) if err != nil { return "", err } if pass == passAgain || pass == "" { return pass, nil } out.Error(ctx, "Error: the entered password do not match") } return "", errors.New("no valid user input") }
c28876
ExitError(ctx, ExitUsage, nil, "Usage: %s edit secret", s.Name) } return s.edit(ctx, c, name) }
c28877
the session key per recipient header, err := x.encryptHeader(ctx, privKey, sk, recipients) if err != nil { return nil, errors.Wrapf(err, "failed to encrypt header: %s", err) } msg := &xcpb.Message{ Version: OnDiskVersion, Header: header, Chunks: chunks, Compressed: compressed, } return pro...
c28878
arrays for box var senderPrivateKey [32]byte pk := sender.PrivateKey() copy(senderPrivateKey[:], pk[:]) var nonce [24]byte if _, err := io.ReadFull(crypto_rand.Reader, nonce[:]); err != nil { return nil, err } return box.Seal(nonce[:], sk, &nonce, &recipientPublicKey, &senderPrivateKey), nil }
c28879
var nonce [24]byte binary.BigEndian.PutUint64(nonce[:], uint64(len(chunks))) // encrypt the plaintext using the random nonce chunks = append(chunks, &xcpb.Chunk{ Body: secretbox.Seal(nil, plaintext[offset:min(len(plaintext), offset+chunkSizeMax)], &nonce, &sessionKey), }) offset += chunkSizeMax } ret...
c28880
:= cmd.Output() if err != nil { if bytes.Contains(cmdout, []byte("secret key not available")) { return gpg.KeyList{}, nil } return gpg.KeyList{}, err } kl := parseColons(bytes.NewBuffer(cmdout)) g.listCache.Add(strings.Join(args, ","), kl) return kl, nil }
c28881
g.pubKeys = kl } if gpg.IsAlwaysTrust(ctx) { return g.pubKeys.Recipients(), nil } return g.pubKeys.UseableKeys().Recipients(), nil }
c28882
if gpg.IsAlwaysTrust(ctx) { return kl.Recipients(), nil } return kl.UseableKeys().Recipients(), nil }
c28883
g.privKeys = kl } if gpg.IsAlwaysTrust(ctx) { return g.privKeys.Recipients(), nil } return g.privKeys.UseableKeys().Recipients(), nil }
c28884
return g.findKey(ctx, id).Identity().Email }
c28885
return g.findKey(ctx, id).Identity().Name }
c28886
return g.findKey(ctx, id).OneLine() }
c28887
out.Print(ctx, "%s:\n%s", color.BlueString(v), sec.Password()) } if strings.Contains(sec.Body(), needle) { out.Print(ctx, "%s:\n%s", color.BlueString(v), sec.Body()) } } if errors > 0 { return ExitError(ctx, ExitDecrypt, nil, "some secrets failed to decrypt") } if matches < 1 { return ExitError(ctx...
c28888
{ return nil, err } g := &GPG{ pubring: pubring, secring: secring, pubfn: pubfn, secfn: secfn, } return g, nil }
c28889
case *packet.EncryptedKey: for _, key := range g.pubring { if key.PrimaryKey == nil { continue } if key.PrimaryKey.KeyId == p.KeyId { recps = append(recps, key.PrimaryKey.KeyIdString()) } } } } return recps, nil }
c28890
err != nil { return nil, errors.Wrapf(err, "failed to encrypt") } if _, err := io.Copy(wc, bytes.NewReader(plaintext)); err != nil { return nil, errors.Wrapf(err, "failed to write plaintext to encoder") } if err := wc.Close(); err != nil { return nil, errors.Wrapf(err, "failed to finalize encryption") } re...
c28891
if err != nil { return err } g.pubring = append(g.pubring, el...) return nil }
c28892
semver.Version { return semver.Version{Major: 1} }
c28893
if err != nil { return err } defer sigfh.Close() wc, err := clearsign.Encode(sigfh, signKeys[0].PrivateKey, nil) if err != nil { return err } infh, err := os.Open(in) if err != nil { return err } defer infh.Close() if _, err := io.Copy(wc, infh); err != nil { return err } return wc.Close() }
c28894
defer infh.Close() _, err = openpgp.CheckDetachedSignature(g.pubring, infh, bytes.NewReader(b.Bytes)) if err != nil { return err } return nil }
c28895
if id.UserId == nil { return name } return id.UserId.Email } return "" }
c28896
if id.UserId == nil { return name } return id.UserId.Name } return "" }
c28897
Key must contain exactly one Entity") } names := make([]string, 0, len(el[0].Identities)) for _, v := range el[0].Identities { names = append(names, v.Name) } return names, nil }
c28898
clipboard.Clear(ctx, checksum, force); err != nil { return ExitError(ctx, ExitIO, err, "Failed to clear clipboard: %s", err) } return nil }
c28899
return ExitError(ctx, ExitUsage, nil, "Usage: %s find <NEEDLE>", s.Name) } return s.find(ctx, c, c.Args().First(), s.show) }