id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c29100
if !ok { return "" } return a }
c29101
context.WithValue(ctx, ctxKeyAutoPrint, bv) }
c29102
:= ctx.Value(ctxKeyAutoPrint).(bool) return ok }
c29103
:= ctx.Value(ctxKeyAutoPrint).(bool) if !ok { return false } return bv }
c29104
context.WithValue(ctx, ctxKeyGitInit, bv) }
c29105
:= ctx.Value(ctxKeyGitInit).(bool) return ok }
c29106
:= ctx.Value(ctxKeyGitInit).(bool) if !ok { return true } return bv }
c29107
if err != nil { return "", err } buf := &bytes.Buffer{} if err := tpl.Execute(buf, a); err != nil { return "", err } return buf.String(), nil }
c29108
if !strings.HasSuffix(name, Suffix) { name += Suffix } buf, err := binaryGet(ctx, name, store) if err != nil { return action.ExitError(ctx, action.ExitDecrypt, err, "failed to read secret: %s", err) } h := sha256.New() _, _ = h.Write(buf) out.Yellow(ctx, "%x", h.Sum(nil)) return nil }
c29109
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 }
c29110
:= api.ReadAndRespond(ctx); err != nil { return api.RespondError(err) } return nil }
c29111
if !found { return nil, fmt.Errorf("entry not found") } return sec, nil }
c29112
[]byte) error { m.Lock() defer m.Unlock() m.data[name] = value return nil }
c29113
defer m.Unlock() delete(m.data, name) return nil }
c29114
_, found := m.data[name] return found }
c29115
k := range m.data { keys = append(keys, k) } sort.Strings(keys) return keys, nil }
c29116
if strings.HasPrefix(k, name+"/") { return true } } return false }
c29117
deleted++ } } if deleted < 1 { return fmt.Errorf("not found") } return nil }
c29118
PublicKey: *pub, Identity: &xcpb.Identity{}, }, Encrypted: true, privateKey: *priv, } err = k.Encrypt(passphrase) return k, err }
c29119
!= nil { return err } p.Nonce = nonce p.EncryptedData = secretbox.Seal(nil, p.privateKey[:], &nonce, &secretKey) return nil }
c29120
{ return fmt.Errorf("decryption error") } copy(p.privateKey[:], decrypted) p.Encrypted = false return nil }
c29121
= append(acts, cui.Action{Name: "AWS Secret Key", Fn: s.createAWS}) acts = append(acts, cui.Action{Name: "GCP Service Account", Fn: s.createGCP}) act, sel := cui.GetSelection(ctx, "Please select the type of secret you would like to create", "<↑/↓> to change the selection, <→> to select, <ESC> to quit", acts.Selectio...
c29122
= "http://" + urlStr } u, err := url.Parse(urlStr) if err == nil { if ch := fsutil.CleanFilename(u.Hostname()); ch != "" { return ch } } return fsutil.CleanFilename(in) }
c29123
if already taken if store != "" { store += "/" } name := fmt.Sprintf("%saws/iam/%s/%s", store, fsutil.CleanFilename(account), fsutil.CleanFilename(username)) if s.store.Exists(ctx, name) { name, err = termio.AskForString(ctx, "Secret already exists, please choose another path", name) if err != nil { retur...
c29124
{ store = cui.AskForStore(ctx, s.store) } // generate name, ask for override if already taken if store != "" { store += "/" } name := fmt.Sprintf("%sgcp/iam/%s/%s", store, fsutil.CleanFilename(project), fsutil.CleanFilename(username)) if s.store.Exists(ctx, name) { name, err = termio.AskForString(ctx, fmt...
c29125
username := p[0] p = strings.Split(p[1], ".") if len(p) < 1 { return username, "", fmt.Errorf("hostname contains not enough separators") } return username, p[0], nil }
c29126
termio.AskForString(ctx, "Secret already exists, please choose another path", name) if err != nil { return err } } sec := secret.New(password, "") out.Print(ctx, fmtfn(2, "3", "Enter zero or more key value pairs for this secret:")) for { key, err := termio.AskForString(ctx, fmtfn(4, "a", "Name (enter to q...
c29127
} symbols, err := termio.AskForBool(ctx, fmtfn(4, "c", "Include symbols?"), false) if err != nil { return "", err } corp, err := termio.AskForBool(ctx, fmtfn(4, "d", "Strict rules?"), false) if err != nil { return "", err } if corp { return pwgen.GeneratePasswordWithAllClasses(length) } return pwgen.Ge...
c29128
nil { return "", err } return pwgen.GeneratePasswordCharset(length, "0123456789"), nil }
c29129
{ ctx = WithCryptoBackend(ctx, cb) } return ctx }
c29130
context.WithValue(ctx, ctxKeyCryptoBackend, be) }
c29131
:= ctx.Value(ctxKeyCryptoBackend).(CryptoBackend) return ok }
c29132
return WithRCSBackend(ctx, be) } return WithRCSBackend(ctx, Noop) }
c29133
context.WithValue(ctx, ctxKeyRCSBackend, sb) }
c29134
:= ctx.Value(ctxKeyRCSBackend).(RCSBackend) return ok }
c29135
WithStorageBackend(ctx, storageBackendFromName(sb)) }
c29136
context.WithValue(ctx, ctxKeyStorageBackend, sb) }
c29137
:= ctx.Value(ctxKeyStorageBackend).(StorageBackend) return ok }
c29138
false, NoPager: false, SafeContent: false, UseSymbols: false, Notifications: true, }, Mounts: make(map[string]*StoreConfig), } }
c29139
found && sc != nil { return sc.RecipientHash[name] } return "" }
c29140
found := c.Mounts[alias]; found && sc != nil { sc.setRecipientHash(name, value) } } return c.Save() }
c29141
_, path := range lst { if !strings.HasSuffix(path, cExt) { continue } path = strings.TrimSuffix(path, cExt) if s.alias != "" { path = s.alias + sep + path } out = append(out, path) } return out, nil }
c29142
Do you want to run the onboarding wizard?", true); err == nil && ok { if err := s.InitOnboarding(ctx, c); err != nil { return ExitError(ctx, ExitUnknown, err, "failed to run onboarding wizard: %s", err) } return nil } return nil }
c29143
out.Error(ctx, "WARNING: Store is already initialized") } if err := s.init(ctx, alias, path, c.Args()...); err != nil { return ExitError(ctx, ExitUnknown, err, "failed to initialize store: %s", err) } return nil }
c29144
s.cfg.Root.AutoSync = want } } else { s.cfg.Root.AutoSync = false } // noconfirm if want, err := termio.AskForBool(ctx, out.Prefix(ctx)+"Do you want to always confirm recipients when encrypting?", false); err == nil { s.cfg.Root.NoConfirm = !want } // save config if err := s.cfg.Save(); err != nil { r...
c29145
s.init(out.WithHidden(ctx, true), team, ""); err != nil { return errors.Wrapf(err, "failed to init shared store") } out.Green(ctx, " -> OK") out.Print(ctx, "Configuring the git remote ...") if err := s.initSetupGitRemote(ctx, team, remote); err != nil { return errors.Wrapf(err, "failed to setup git remote") ...
c29146
call := obj.Call("org.freedesktop.Notifications.Notify", 0, "gopass", uint32(0), iconURI(), subj, msg, []string{}, map[string]dbus.Variant{}, int32(5000)) if call.Err != nil { return err } return nil }
c29147
_ = binary.Write(d, binary.LittleEndian, p.PubKeyAlgo) _, _ = d.Write(p.PublicKey[:]) _, _ = d.Read(h) return fmt.Sprintf("%x", h) }
c29148
`\` { return `\\\\` } return `\\` + c }) }
c29149
} list, err := s.Store.List(ctx, 0) if err != nil { return } for _, v := range list { fmt.Fprintln(stdout, bashEscape(v)) } }
c29150
{ opts = append(opts, opt.Name) if len(opt.Aliases) > 0 { opts = append(opts, strings.Join(opt.Aliases, " ")) } } fmt.Fprintf(stdout, out, strings.Join(opts, " ")) return nil }
c29151
-F _gopass_bash_autocomplete " + s.Name if runtime.GOOS == "windows" { out += "\ncomplete -F _gopass_bash_autocomplete " + s.Name + ".exe" } fmt.Fprintln(stdout, out) return nil }
c29152
return err } fmt.Fprintln(stdout, comp) return nil }
c29153
return err } fmt.Fprintln(stdout, comp) return nil }
c29154
(net.Conn, error) { return net.Dial("unix", socket) }, }, Timeout: 10 * time.Minute, }, } }
c29155
} resp, err := pc.Get("http://unix/ping") if err != nil { return err } _ = resp.Body.Close() return nil }
c29156
build request url") } values := u.Query() values.Set("key", key) u.RawQuery = values.Encode() resp, err := c.http.Get(u.String()) if err != nil { return errors.Wrapf(err, "failed to talk to agent") } defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { return fmt.Errorf("reque...
c29157
{ if err := x.pubring.Import(buf); err != nil { return err } return x.pubring.Save() }
c29158
{ if err := x.secring.Import(buf); err != nil { return err } return x.secring.Save() }
c29159
pkr, _ := keyring.LoadPubring(filepath.Join(dir, pubringFilename), skr) return &XC{ dir: dir, pubring: pkr, secring: skr, client: client, }, nil }
c29160
x.pubring.Remove(id); err != nil { return err } return x.pubring.Save() } return fmt.Errorf("not found") }
c29161
x.client == nil { return fmt.Errorf("client not initialized") } if err := x.client.Ping(ctx); err != nil { return fmt.Errorf("agent not running") } return nil }
c29162
semver.Version{ Patch: 1, } }
c29163
- Found '%s' at '%s' (%s)", b, p, gb.ver.String()) bv = append(bv, gb) } } if len(bv) < 1 { return "", errors.New("no gpg binary found") } sort.Sort(bv) binary := bv[len(bv)-1].path //out.Debug(ctx, "gpg.detectBinary - using '%s'", binary) return binary, nil }
c29164
context.WithValue(ctx, ctxKeyPrefix, prefix) }
c29165
return WithPrefix(ctx, prefix) } return WithPrefix(ctx, pfx+prefix) }
c29166
:= ctx.Value(ctxKeyPrefix).(string) if !ok { return "" } return sv }
c29167
context.WithValue(ctx, ctxKeyHidden, hidden) }
c29168
:= ctx.Value(ctxKeyHidden).(bool) if !ok { return false } return bv }
c29169
context.WithValue(ctx, ctxKeyNewline, nl) }
c29170
{ return ExitError(ctx, ExitAborted, nil, "not overwriting your current secret") } } if err := s.Store.Move(ctx, from, to); err != nil { return ExitError(ctx, ExitUnknown, err, "%s", err) } return nil }
c29171
save(c.filename, c.passphrase, map[string]string{}) return c, err } _, err := c.Get("") if err != nil { return nil, errors.Wrapf(err, "failed to open existing secrects config %s: %s", fn, err) } return c, nil }
c29172
:= load(c.filename, c.passphrase) return data[key], err }
c29173
value == old { return nil } data[key] = value return save(c.filename, c.passphrase, data) }
c29174
if !found { return nil } delete(data, key) return save(c.filename, c.passphrase, data) }
c29175
return nil, fmt.Errorf("failed to decrypt") } data := map[string]string{} if err := json.Unmarshal(decrypted, &data); err != nil { return nil, err } return data, nil }
c29176
{ return err } return ioutil.WriteFile(filename, buf, 0600) }
c29177
if _, err := crypto_rand.Read(salt); err != nil { return nil, err } secretKey := deriveKey(passphrase, salt) prefix := append(salt, nonce[:]...) return secretbox.Seal(prefix, jstr, &nonce, &secretKey), nil }
c29178
fmt.Fprintf(Stdout, "[%d] %s - %s\n", i, crypto.Name(), crypto.FormatKey(ctx, k)) } iv, err := termio.AskForInt(ctx, fmt.Sprintf("Please enter the number of a key (0-%d, [q]uit)", len(kl)-1), 0) if err != nil { if err.Error() == "user aborted" { return "", err } continue } if iv >= 0 && iv <...
c29179
PrivateKeys: make([]*xcpb.PrivateKey, 0, 10), }, } }
c29180
return nil, err } if err := proto.Unmarshal(buf, pr.data); err != nil { return nil, err } return pr, nil }
c29181
pk.PublicKey.Fingerprint == fp { return true } } return false }
c29182
ids = append(ids, pk.PublicKey.Fingerprint) } sort.Strings(ids) return ids }
c29183
if withPrivate { return proto.Marshal(xpk) } return proto.Marshal(xpk.PublicKey) }
c29184
if err := proto.Unmarshal(buf, pk); err != nil { return err } p.insert(pk) return nil }
c29185
defer p.Unlock() p.insert(secKRToPB(pk)) return nil }
c29186
{ match = i break } } if match < 0 || match > len(p.data.PrivateKeys) { return fmt.Errorf("not found") } p.data.PrivateKeys = append(p.data.PrivateKeys[:match], p.data.PrivateKeys[match+1:]...) return nil }
c29187
:= c.String("store") return s.sync(ctx, c, store) }
c29188
".git")) { return nil, fmt.Errorf("git repo does not exist") } return &Git{ path: path, }, nil }
c29189
repo, path); err != nil { return nil, err } g.path = path return g, nil }
c29190
g, nil } // initialize the local git config if err := g.InitConfig(ctx, userName, userEmail); err != nil { return g, errors.Errorf("failed to configure git: %s", err) } out.Red(ctx, "git configured at %s", g.path) // add current content of the store if err := g.Add(ctx, g.path); err != nil { return g, err...
c29191
out.Debug(ctx, "Output:\n Stdout: '%s'\n Stderr: '%s'", string(stdout), string(stderr)) return err } return nil }
c29192
%s", err) return v } svStr := strings.TrimPrefix(string(cmdout), "git version ") if p := strings.Fields(svStr); len(p) > 0 { svStr = p[0] } sv, err := semver.ParseTolerant(svStr) if err != nil { out.Debug(ctx, "Failed to parse '%s' as semver: %s", svStr, err) return v } return sv }
c29193
range files { files[i] = strings.TrimPrefix(files[i], g.path+"/") } args := []string{"add", "--all", "--force"} args = append(args, files...) return g.Cmd(ctx, "gitAdd", args...) }
c29194
"gitDiffIndex", "diff-index", "--quiet", "HEAD"); err != nil { return true } return false }
c29195
return store.ErrGitNothingToCommit } return g.Cmd(ctx, "gitCommit", "commit", "-m", msg) }
c29196
return g.PushPull(ctx, "push", remote, branch) }
c29197
len(pk) < 32 { return "", errors.New("exported key too small") } if err := s.storage.Set(ctx, filename, pk); err != nil { return "", errors.Wrapf(err, "failed to write exported public key to store") } return filename, nil }
c29198
continue } pk, err := s.storage.Get(ctx, filename) if err != nil { return err } return s.crypto.ImportPublicKey(ctx, pk) } return fmt.Errorf("public key not found in store") }
c29199
ExitError(ctx, ExitList, err, "failed to list store: %s", err) } if filter == "" { return s.listAll(ctx, l, limit, flat, folders) } return s.listFiltered(ctx, l, limit, flat, folders, stripPrefix, filter) }