_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q28800 | AddRemote | train | func (g *Noop) AddRemote(ctx context.Context, remote, url string) error {
return nil
} | go | {
"resource": ""
} |
q28801 | RemoveRemote | train | func (g *Noop) RemoveRemote(ctx context.Context, remote string) error {
return nil
} | go | {
"resource": ""
} |
q28802 | Revisions | train | func (g *Noop) Revisions(context.Context, string) ([]backend.Revision, error) {
return nil, fmt.Errorf("not yet implemented for %s", g.Name())
} | go | {
"resource": ""
} |
q28803 | WithPassPromptFunc | train | func WithPassPromptFunc(ctx context.Context, ppf PassPromptFunc) context.Context {
return context.WithValue(ctx, ctxKeyPassPromptFunc, ppf)
} | go | {
"resource": ""
} |
q28804 | HasPassPromptFunc | train | func HasPassPromptFunc(ctx context.Context) bool {
ppf, ok := ctx.Value(ctxKeyPassPromptFunc).(PassPromptFunc)
return ok && ppf != nil
} | go | {
"resource": ""
} |
q28805 | ListTemplates | train | func (s *Store) ListTemplates(ctx context.Context, prefix string) []string {
lst, err := s.storage.List(ctx, "")
if err != nil {
out.Debug(ctx, "failed to list templates: %s", err)
return nil
}
tpls := make(map[string]struct{}, len(lst))
for _, path := range lst {
if !strings.HasSuffix(path, TemplateFile) {
... | go | {
"resource": ""
} |
q28806 | templatefile | train | func (s *Store) templatefile(name string) string {
return strings.TrimPrefix(filepath.Join(name, TemplateFile), string(filepath.Separator))
} | go | {
"resource": ""
} |
q28807 | HasTemplate | train | func (s *Store) HasTemplate(ctx context.Context, name string) bool {
return s.storage.Exists(ctx, s.templatefile(name))
} | go | {
"resource": ""
} |
q28808 | GetTemplate | train | func (s *Store) GetTemplate(ctx context.Context, name string) ([]byte, error) {
return s.storage.Get(ctx, s.templatefile(name))
} | go | {
"resource": ""
} |
q28809 | ParseURL | train | func ParseURL(us string) (*URL, error) {
// if it's no URL build file URL and parse that
nu, err := url.Parse(us)
if err != nil {
nu, err = url.Parse("gpgcli-gitcli-fs+file://" + us)
if err != nil {
return nil, err
}
}
u := &URL{
url: nu,
}
if err := u.parseScheme(); err != nil {
return u, err
}
u... | go | {
"resource": ""
} |
q28810 | UnmarshalYAML | train | func (u *URL) UnmarshalYAML(umf func(interface{}) error) error {
path := ""
if err := umf(&path); err != nil {
return err
}
um, err := ParseURL(path)
if err != nil {
return err
}
*u = *um
return nil
} | go | {
"resource": ""
} |
q28811 | GitInit | train | func (s *Store) GitInit(ctx context.Context, un, ue string) error {
rcs, err := backend.InitRCS(ctx, backend.GetRCSBackend(ctx), s.url.Path, un, ue)
if err != nil {
return err
}
s.rcs = rcs
return nil
} | go | {
"resource": ""
} |
q28812 | ListRevisions | train | func (s *Store) ListRevisions(ctx context.Context, name string) ([]backend.Revision, error) {
p := s.passfile(name)
return s.rcs.Revisions(ctx, p)
} | go | {
"resource": ""
} |
q28813 | GetRevision | train | func (s *Store) GetRevision(ctx context.Context, name, revision string) (store.Secret, error) {
p := s.passfile(name)
ciphertext, err := s.rcs.GetRevision(ctx, p, revision)
if err != nil {
return nil, errors.Wrapf(err, "failed to get ciphertext of '%s'@'%s'", name, revision)
}
content, err := s.crypto.Decrypt(c... | go | {
"resource": ""
} |
q28814 | IsUseable | train | func (k Key) IsUseable() bool {
if !k.ExpirationDate.IsZero() && k.ExpirationDate.Before(time.Now()) {
return false
}
switch k.Validity {
case "m":
return true
case "f":
return true
case "u":
return true
}
return false
} | go | {
"resource": ""
} |
q28815 | String | train | func (k Key) String() string {
fp := ""
if len(k.Fingerprint) > 24 {
fp = k.Fingerprint[24:]
}
out := fmt.Sprintf("%s %dD/0x%s %s", k.KeyType, k.KeyLength, fp, k.CreationDate.Format("2006-01-02"))
if !k.ExpirationDate.IsZero() {
out += fmt.Sprintf(" [expires: %s]", k.ExpirationDate.Format("2006-01-02"))
}
... | go | {
"resource": ""
} |
q28816 | Identity | train | func (k Key) Identity() Identity {
ids := make([]Identity, 0, len(k.Identities))
for _, i := range k.Identities {
ids = 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{}
} | go | {
"resource": ""
} |
q28817 | ID | train | func (k Key) ID() string {
if len(k.Fingerprint) < 25 {
return ""
}
return fmt.Sprintf("0x%s", k.Fingerprint[24:])
} | go | {
"resource": ""
} |
q28818 | Clone | train | func (s *Action) Clone(ctx context.Context, c *cli.Context) error {
if c.IsSet("crypto") {
ctx = backend.WithCryptoBackendString(ctx, c.String("crypto"))
}
if c.IsSet("sync") {
ctx = backend.WithRCSBackendString(ctx, c.String("sync"))
}
if len(c.Args()) < 1 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s... | go | {
"resource": ""
} |
q28819 | Recipients | train | func (kl KeyList) Recipients() []string {
l := make([]string, 0, len(kl))
for _, k := range kl {
l = append(l, k.ID())
}
sort.Strings(l)
return l
} | go | {
"resource": ""
} |
q28820 | FindKey | train | func (kl KeyList) FindKey(id string) (Key, error) {
id = strings.TrimPrefix(id, "0x")
for _, k := range kl {
if k.Fingerprint == id {
return k, nil
}
if strings.HasSuffix(k.Fingerprint, id) {
return k, nil
}
for _, ident := range k.Identities {
if ident.Name == id {
return k, nil
}
if ide... | go | {
"resource": ""
} |
q28821 | EncryptStream | train | func (x *XC) EncryptStream(ctx context.Context, plaintext io.Reader, recipients []string, ciphertext io.Writer) error {
privKeyIDs := x.secring.KeyIDs()
if len(privKeyIDs) < 1 {
return fmt.Errorf("no signing keys available on our keyring")
}
privKey := x.secring.Get(privKeyIDs[0])
// generate session / encrypti... | go | {
"resource": ""
} |
q28822 | DecryptStream | train | func (x *XC) DecryptStream(ctx context.Context, ciphertext io.Reader, plaintext io.Writer) error {
dec := binary.NewDecoder(ciphertext)
// read version
ver := 0
if err := dec.Decode(&ver); err != nil {
return err
}
if ver != 0x1 {
return fmt.Errorf("wrong version")
}
// read header
header := &xcpb.Header{... | go | {
"resource": ""
} |
q28823 | ExitError | train | func ExitError(ctx context.Context, exitCode int, err error, format string, args ...interface{}) error {
if err != nil {
out.Debug(ctx, "Stacktrace: %+v", err)
}
return cli.NewExitError(fmt.Sprintf(format, args...), exitCode)
} | go | {
"resource": ""
} |
q28824 | Set | train | func (s *Store) Set(ctx context.Context, name string, sec store.Secret) error {
if strings.Contains(name, "//") {
return errors.Errorf("invalid secret name: %s", name)
}
p := s.passfile(name)
if s.IsDir(ctx, name) {
return errors.Errorf("a folder named %s already exists", name)
}
recipients, err := s.useab... | go | {
"resource": ""
} |
q28825 | Move | train | func (s *Store) Move(ctx context.Context, from, to string) error {
// recursive move?
if s.IsDir(ctx, from) {
return errors.Errorf("recursive operations are not supported")
}
content, err := s.Get(ctx, from)
if err != nil {
return errors.Wrapf(err, "failed to decrypt '%s'", from)
}
if err := s.Set(WithReaso... | go | {
"resource": ""
} |
q28826 | delete | train | func (s *Store) delete(ctx context.Context, name string, recurse bool) error {
path := s.passfile(name)
if recurse {
if err := s.deleteRecurse(ctx, name, path); err != nil {
return err
}
}
if err := s.deleteSingle(ctx, path); err != nil {
if !recurse {
return err
}
}
if !ctxutil.IsGitCommit(ctx) {... | go | {
"resource": ""
} |
q28827 | New | train | func New(ctx context.Context, cfg *config.Config, sv semver.Version) (*Action, error) {
return newAction(ctx, cfg, sv)
} | go | {
"resource": ""
} |
q28828 | CreatePrivateKeyBatch | train | func (g *GPG) CreatePrivateKeyBatch(ctx context.Context, name, email, passphrase string) error {
buf := &bytes.Buffer{}
// https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=doc/DETAILS;h=de0f21ccba60c3037c2a155156202df1cd098507;hb=refs/heads/STABLE-BRANCH-1-4#l716
_, _ = buf.WriteString(`%echo Generating... | go | {
"resource": ""
} |
q28829 | CreatePrivateKey | train | func (g *GPG) CreatePrivateKey(ctx context.Context) error {
args := []string{"--gen-key"}
cmd := exec.CommandContext(ctx, g.binary, args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
out.Debug(ctx, "gpg.CreatePrivateKey: %s %+v", cmd.Path, cmd.Args)
if err := cmd.Run(); err != nil {
r... | go | {
"resource": ""
} |
q28830 | InitConfig | train | func (g *Git) InitConfig(ctx context.Context, userName, userEmail string) error {
if userName == "" || userEmail == "" || !strings.Contains(userEmail, "@") {
return fmt.Errorf("username and email must not be empty and valid")
}
// set commit identity
if err := g.ConfigSet(ctx, "user.name", userName); err != nil {... | go | {
"resource": ""
} |
q28831 | ConfigSet | train | func (g *Git) ConfigSet(ctx context.Context, key, value string) error {
return g.Cmd(ctx, "gitConfigSet", "config", "--local", key, value)
} | go | {
"resource": ""
} |
q28832 | ConfigGet | train | func (g *Git) ConfigGet(ctx context.Context, key string) (string, error) {
if !g.IsInitialized() {
return "", store.ErrGitNotInit
}
buf := &strings.Builder{}
cmd := exec.CommandContext(ctx, "git", "config", "--get", key)
cmd.Dir = g.path
cmd.Stdout = buf
cmd.Stderr = os.Stderr
out.Debug(ctx, "store.gitConf... | go | {
"resource": ""
} |
q28833 | ConfigList | train | func (g *Git) ConfigList(ctx context.Context) (map[string]string, error) {
if !g.IsInitialized() {
return nil, store.ErrGitNotInit
}
buf := &strings.Builder{}
cmd := exec.CommandContext(ctx, "git", "config", "--list")
cmd.Dir = g.path
cmd.Stdout = buf
cmd.Stderr = os.Stderr
out.Debug(ctx, "store.gitConfigL... | go | {
"resource": ""
} |
q28834 | RecipientsPrint | train | func (s *Action) RecipientsPrint(ctx context.Context, c *cli.Context) error {
out.Cyan(ctx, "Hint: run 'gopass sync' to import any missing public keys")
tree, err := s.Store.RecipientsTree(ctx, true)
if err != nil {
return ExitError(ctx, ExitList, err, "failed to list recipients: %s", err)
}
fmt.Fprintln(stdou... | go | {
"resource": ""
} |
q28835 | RecipientsComplete | train | func (s *Action) RecipientsComplete(ctx context.Context, c *cli.Context) {
tree, err := s.Store.RecipientsTree(out.WithHidden(ctx, true), false)
if err != nil {
fmt.Fprintln(stdout, err)
return
}
for _, v := range tree.List(0) {
fmt.Fprintln(stdout, v)
}
} | go | {
"resource": ""
} |
q28836 | RecipientsAdd | train | func (s *Action) RecipientsAdd(ctx context.Context, c *cli.Context) error {
store := c.String("store")
force := c.Bool("force")
added := 0
// select store
if store == "" {
store = cui.AskForStore(ctx, s.Store)
}
crypto := s.Store.Crypto(ctx, store)
// select recipient
recipients := []string(c.Args())
if ... | go | {
"resource": ""
} |
q28837 | RecipientsRemove | train | func (s *Action) RecipientsRemove(ctx context.Context, c *cli.Context) error {
store := c.String("store")
force := c.Bool("force")
removed := 0
// select store
if store == "" {
store = cui.AskForStore(ctx, s.Store)
}
crypto := s.Store.Crypto(ctx, store)
// select recipient
recipients := []string(c.Args())... | go | {
"resource": ""
} |
q28838 | RecipientsUpdate | train | func (s *Action) RecipientsUpdate(ctx context.Context, c *cli.Context) error {
changed := 0
mps := s.Store.MountPoints()
sort.Sort(store.ByPathLen(mps))
for _, alias := range append(mps, "") {
subs, err := s.Store.GetSubStore(alias)
if err != nil || subs == nil {
continue
}
recp, err := subs.GetRecipien... | go | {
"resource": ""
} |
q28839 | OTP | train | func (s *Action) OTP(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
if name == "" {
return ExitError(ctx, ExitUsage, nil, "Usage: %s otp <NAME>", s.Name)
}
qrf := c.String("qr")
clip := c.Bool("clip")
return s.otp(ctx, c, name, qrf, clip, true)
} | go | {
"resource": ""
} |
q28840 | Decrypt | train | func (x *XC) Decrypt(ctx context.Context, buf []byte) ([]byte, error) {
// unmarshal the protobuf message, the header and body are still encrypted
// afterwards (parts of the header are plaintext!)
msg := &xcpb.Message{}
if err := proto.Unmarshal(buf, msg); err != nil {
return nil, err
}
// try to find a suite... | go | {
"resource": ""
} |
q28841 | findDecryptionKey | train | func (x *XC) findDecryptionKey(hdr *xcpb.Header) (*keyring.PrivateKey, error) {
for _, pk := range x.secring.KeyIDs() {
if _, found := hdr.Recipients[pk]; found {
return x.secring.Get(pk), nil
}
}
return nil, fmt.Errorf("no decryption key found for: %+v", hdr.Recipients)
} | go | {
"resource": ""
} |
q28842 | findPublicKey | train | func (x *XC) findPublicKey(needle string) (*keyring.PublicKey, error) {
for _, id := range x.pubring.KeyIDs() {
if id == needle {
return x.pubring.Get(id), nil
}
}
return nil, fmt.Errorf("no sender found for id '%s'", needle)
} | go | {
"resource": ""
} |
q28843 | decryptPrivateKey | train | func (x *XC) decryptPrivateKey(ctx context.Context, recp *keyring.PrivateKey) error {
fp := recp.Fingerprint()
for i := 0; i < maxUnlockAttempts; i++ {
// retry asking for key in case it's wrong
passphrase, err := x.client.Passphrase(ctx, fp, fmt.Sprintf("Unlock private key %s", recp.Fingerprint()))
if err != ... | go | {
"resource": ""
} |
q28844 | decryptSessionKey | train | func (x *XC) decryptSessionKey(ctx context.Context, hdr *xcpb.Header) ([]byte, error) {
// find a suiteable decryption key, i.e. a recipient entry which was encrypted
// for one of our private keys
recp, err := x.findDecryptionKey(hdr)
if err != nil {
return nil, errors.Wrapf(err, "unable to find decryption key")... | go | {
"resource": ""
} |
q28845 | MountRemove | train | func (s *Action) MountRemove(ctx context.Context, c *cli.Context) error {
if len(c.Args()) != 1 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s mount remove [alias]", s.Name)
}
if err := s.Store.RemoveMount(ctx, c.Args()[0]); err != nil {
out.Error(ctx, "Failed to remove mount: %s", err)
}
if err := s.cfg... | go | {
"resource": ""
} |
q28846 | MountsPrint | train | func (s *Action) MountsPrint(ctx context.Context, c *cli.Context) error {
if len(s.Store.Mounts()) < 1 {
out.Cyan(ctx, "No mounts")
return nil
}
root := simple.New(color.GreenString(fmt.Sprintf("gopass (%s)", s.Store.Path())))
mounts := s.Store.Mounts()
mps := s.Store.MountPoints()
sort.Sort(store.ByPathLen(... | go | {
"resource": ""
} |
q28847 | MountsComplete | train | func (s *Action) MountsComplete(*cli.Context) {
for alias := range s.Store.Mounts() {
fmt.Fprintln(stdout, alias)
}
} | go | {
"resource": ""
} |
q28848 | MountAdd | train | func (s *Action) MountAdd(ctx context.Context, c *cli.Context) error {
alias := c.Args().Get(0)
localPath := c.Args().Get(1)
if alias == "" {
return ExitError(ctx, ExitUsage, nil, "usage: %s mounts add <alias> [local path]", s.Name)
}
if localPath == "" {
localPath = config.PwStoreDir(alias)
}
keys := make... | go | {
"resource": ""
} |
q28849 | FindPublicKeys | train | func (m *Mocker) FindPublicKeys(ctx context.Context, keys ...string) ([]string, error) {
rs := staticPrivateKeyList.Recipients()
res := make([]string, 0, len(rs))
for _, r := range rs {
for _, needle := range keys {
if strings.HasSuffix(r, needle) {
res = append(res, r)
}
}
}
return res, nil
} | go | {
"resource": ""
} |
q28850 | RecipientIDs | train | func (m *Mocker) RecipientIDs(context.Context, []byte) ([]string, error) {
return staticPrivateKeyList.Recipients(), nil
} | go | {
"resource": ""
} |
q28851 | Encrypt | train | func (m *Mocker) Encrypt(ctx context.Context, content []byte, recipients []string) ([]byte, error) {
return content, nil
} | go | {
"resource": ""
} |
q28852 | Decrypt | train | func (m *Mocker) Decrypt(ctx context.Context, ciphertext []byte) ([]byte, error) {
return ciphertext, nil
} | go | {
"resource": ""
} |
q28853 | Sign | train | func (m *Mocker) Sign(ctx context.Context, in string, sigf string) error {
buf, err := ioutil.ReadFile(in)
if err != nil {
return err
}
sum := sha256.New()
_, _ = sum.Write(buf)
hexsum := fmt.Sprintf("%X", sum.Sum(nil))
return ioutil.WriteFile(sigf, []byte(hexsum), 0644)
} | go | {
"resource": ""
} |
q28854 | Verify | train | func (m *Mocker) Verify(ctx context.Context, sigf string, in string) error {
sigb, err := ioutil.ReadFile(sigf)
if err != nil {
return err
}
buf, err := ioutil.ReadFile(in)
if err != nil {
return err
}
sum := sha256.New()
_, _ = sum.Write(buf)
hexsum := fmt.Sprintf("%X", sum.Sum(nil))
if string(sigb) !=... | go | {
"resource": ""
} |
q28855 | ReadNamesFromKey | train | func (m *Mocker) ReadNamesFromKey(ctx context.Context, buf []byte) ([]string, error) {
return []string{"unsupported"}, nil
} | go | {
"resource": ""
} |
q28856 | Clone | train | func (l loader) Clone(ctx context.Context, repo, path string) (backend.RCS, error) {
return Clone(ctx, repo, path)
} | go | {
"resource": ""
} |
q28857 | ImportPublicKey | train | func (g *GPG) ImportPublicKey(ctx context.Context, buf []byte) error {
if len(buf) < 1 {
return errors.Errorf("empty input")
}
args := append(g.args, "--import")
cmd := exec.CommandContext(ctx, g.binary, args...)
cmd.Stdin = bytes.NewReader(buf)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
out.Debug(ctx, "... | go | {
"resource": ""
} |
q28858 | Copy | train | func Copy(ctx context.Context, c *cli.Context, store storer) error {
from := c.Args().Get(0)
to := c.Args().Get(1)
// argument checking 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
} | go | {
"resource": ""
} |
q28859 | Fsck | train | func (s *Action) Fsck(ctx context.Context, c *cli.Context) error {
out.Print(ctx, "Checking store integrity ...")
// make sure config is in the right place
// we may have loaded it from one of the fallback locations
if err := s.cfg.Save(); err != nil {
return ExitError(ctx, ExitConfig, err, "failed to save config... | go | {
"resource": ""
} |
q28860 | Notify | train | func Notify(ctx context.Context, subj, msg string) error {
return errors.Errorf("GOOS %s not yet supported", runtime.GOOS)
} | go | {
"resource": ""
} |
q28861 | ExportPublicKey | train | func (g *GPG) ExportPublicKey(ctx context.Context, id string) ([]byte, error) {
if id == "" {
return nil, errors.Errorf("id is empty")
}
args := append(g.args, "--armor", "--export", id)
cmd := exec.CommandContext(ctx, g.binary, args...)
out.Debug(ctx, "gpg.ExportPublicKey: %s %+v", cmd.Path, cmd.Args)
out, e... | go | {
"resource": ""
} |
q28862 | parseTS | train | func parseTS(str string) time.Time {
t := time.Time{}
if sec, err := strconv.ParseInt(str, 10, 64); err == nil {
t = time.Unix(sec, 0)
}
return t
} | go | {
"resource": ""
} |
q28863 | parseInt | train | func parseInt(str string) int {
i := 0
if iv, err := strconv.ParseInt(str, 10, 32); err == nil {
i = int(iv)
}
return i
} | go | {
"resource": ""
} |
q28864 | GPGOpts | train | func GPGOpts() []string {
for _, en := range []string{"GOPASS_GPG_OPTS", "PASSWORD_STORE_GPG_OPTS"} {
if opts := os.Getenv(en); opts != "" {
return strings.Fields(opts)
}
}
return nil
} | go | {
"resource": ""
} |
q28865 | Exists | train | func (s *Store) Exists(ctx context.Context, name string) bool {
_, err := s.Get(ctx, name)
return err == nil
} | go | {
"resource": ""
} |
q28866 | Get | train | func (s *Store) Get(ctx context.Context, name string) (store.Secret, error) {
key := path.Join(s.path, name)
out.Debug(ctx, "Get(%s) %s", name, key)
sec, err := s.api.Logical().Read(key)
if err != nil {
return nil, err
}
if sec == nil || sec.Data == nil {
return nil, fmt.Errorf("not found")
}
return &Secret... | go | {
"resource": ""
} |
q28867 | Initialized | train | func (s *Store) Initialized(ctx context.Context) bool {
_, err := s.List(ctx, "")
return err == nil
} | go | {
"resource": ""
} |
q28868 | IsDir | train | func (s *Store) IsDir(ctx context.Context, name string) bool {
ls, err := s.List(ctx, name)
if err != nil {
return false
}
return len(ls) > 1
} | go | {
"resource": ""
} |
q28869 | List | train | func (s *Store) List(ctx context.Context, prefix string) ([]string, error) {
keys, err := s.list(ctx, prefix)
if err != nil {
return nil, err
}
for i, e := range keys {
keys[i] = path.Join(s.alias, e)
}
return keys, nil
} | go | {
"resource": ""
} |
q28870 | Move | train | func (s *Store) Move(ctx context.Context, from string, to string) error {
// recursive move?
if s.IsDir(ctx, from) {
if s.Exists(ctx, to) {
return errors.Errorf("Can not move dir to file")
}
sf, err := s.List(ctx, "")
if err != nil {
return errors.Wrapf(err, "failed to list store")
}
destPrefix := t... | go | {
"resource": ""
} |
q28871 | Set | train | func (s *Store) Set(ctx context.Context, name string, sec store.Secret) error {
d := sec.Data()
if d == nil {
d = make(map[string]interface{}, 1)
}
d[passwordKey] = sec.Password()
_, err := s.api.Logical().Write(path.Join(s.path, name), d)
return err
} | go | {
"resource": ""
} |
q28872 | Prune | train | func (s *Store) Prune(ctx context.Context, name string) error {
ls, err := s.List(ctx, name)
if err != nil {
return err
}
for _, e := range ls {
if err := s.Delete(ctx, e); err != nil {
return err
}
}
return nil
} | go | {
"resource": ""
} |
q28873 | AskForInt | train | func AskForInt(ctx context.Context, text string, def int) (int, error) {
if ctxutil.IsAlwaysYes(ctx) {
return def, nil
}
str, err := AskForString(ctx, text, strconv.Itoa(def))
if err != nil {
return 0, err
}
if str == "q" {
return 0, ErrAborted
}
intVal, err := strconv.Atoi(str)
if err != nil {
return... | go | {
"resource": ""
} |
q28874 | AskForKeyImport | train | func AskForKeyImport(ctx context.Context, key string, names []string) bool {
if ctxutil.IsAlwaysYes(ctx) {
return true
}
if !ctxutil.IsInteractive(ctx) {
return false
}
ok, err := AskForBool(ctx, fmt.Sprintf("Do you want to import the public key '%s' (Names: %+v) into your keyring?", key, names), false)
if e... | go | {
"resource": ""
} |
q28875 | AskForPassword | train | func AskForPassword(ctx context.Context, name string) (string, error) {
if ctxutil.IsAlwaysYes(ctx) {
return "", nil
}
askFn := GetPassPromptFunc(ctx)
for i := 0; i < maxTries; i++ {
// check for context cancelation
select {
case <-ctx.Done():
return "", ErrAborted
default:
}
pass, err := askFn(c... | go | {
"resource": ""
} |
q28876 | Edit | train | func (s *Action) Edit(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
if name == "" {
return ExitError(ctx, ExitUsage, nil, "Usage: %s edit secret", s.Name)
}
return s.edit(ctx, c, name)
} | go | {
"resource": ""
} |
q28877 | Encrypt | train | func (x *XC) Encrypt(ctx context.Context, plaintext []byte, recipients []string) ([]byte, error) {
privKeyIDs := x.secring.KeyIDs()
if len(privKeyIDs) < 1 {
return nil, fmt.Errorf("no signing keys available on our keyring")
}
privKey := x.secring.Get(privKeyIDs[0])
var compressed bool
plaintext, compressed = c... | go | {
"resource": ""
} |
q28878 | encryptForRecipient | train | func (x *XC) encryptForRecipient(ctx context.Context, sender *keyring.PrivateKey, sk []byte, recipient string) ([]byte, error) {
recp := x.pubring.Get(recipient)
if recp == nil {
return nil, fmt.Errorf("recipient public key not available for %s", recipient)
}
var recipientPublicKey [32]byte
copy(recipientPublic... | go | {
"resource": ""
} |
q28879 | encryptBody | train | func encryptBody(plaintext []byte) ([]byte, []*xcpb.Chunk, error) {
// generate session / encryption key
var sessionKey [32]byte
if _, err := crypto_rand.Read(sessionKey[:]); err != nil {
return nil, nil, err
}
chunks := make([]*xcpb.Chunk, 0, (len(plaintext)/chunkSizeMax)+1)
offset := 0
for offset < len(pla... | go | {
"resource": ""
} |
q28880 | listKeys | train | func (g *GPG) listKeys(ctx context.Context, typ string, search ...string) (gpg.KeyList, error) {
args := []string{"--with-colons", "--with-fingerprint", "--fixed-list-mode", "--list-" + typ + "-keys"}
args = append(args, search...)
if e, found := g.listCache.Get(strings.Join(args, ",")); found {
if ev, ok := e.(gp... | go | {
"resource": ""
} |
q28881 | ListPublicKeyIDs | train | func (g *GPG) ListPublicKeyIDs(ctx context.Context) ([]string, error) {
if g.pubKeys == nil {
kl, err := g.listKeys(ctx, "public")
if err != nil {
return nil, err
}
g.pubKeys = kl
}
if gpg.IsAlwaysTrust(ctx) {
return g.pubKeys.Recipients(), nil
}
return g.pubKeys.UseableKeys().Recipients(), nil
} | go | {
"resource": ""
} |
q28882 | FindPublicKeys | train | func (g *GPG) FindPublicKeys(ctx context.Context, search ...string) ([]string, error) {
kl, err := g.listKeys(ctx, "public", search...)
if err != nil || kl == nil {
return nil, err
}
if gpg.IsAlwaysTrust(ctx) {
return kl.Recipients(), nil
}
return kl.UseableKeys().Recipients(), nil
} | go | {
"resource": ""
} |
q28883 | ListPrivateKeyIDs | train | func (g *GPG) ListPrivateKeyIDs(ctx context.Context) ([]string, error) {
if g.privKeys == nil {
kl, err := g.listKeys(ctx, "secret")
if err != nil {
return nil, err
}
g.privKeys = kl
}
if gpg.IsAlwaysTrust(ctx) {
return g.privKeys.Recipients(), nil
}
return g.privKeys.UseableKeys().Recipients(), nil
} | go | {
"resource": ""
} |
q28884 | EmailFromKey | train | func (g *GPG) EmailFromKey(ctx context.Context, id string) string {
return g.findKey(ctx, id).Identity().Email
} | go | {
"resource": ""
} |
q28885 | NameFromKey | train | func (g *GPG) NameFromKey(ctx context.Context, id string) string {
return g.findKey(ctx, id).Identity().Name
} | go | {
"resource": ""
} |
q28886 | FormatKey | train | func (g *GPG) FormatKey(ctx context.Context, id string) string {
return g.findKey(ctx, id).OneLine()
} | go | {
"resource": ""
} |
q28887 | Grep | train | func (s *Action) Grep(ctx context.Context, c *cli.Context) error {
if !c.Args().Present() {
return ExitError(ctx, ExitUsage, nil, "Usage: %s grep arg", s.Name)
}
// get the search term
needle := c.Args().First()
haystack, err := s.Store.List(ctx, 0)
if err != nil {
return ExitError(ctx, ExitList, err, "fail... | go | {
"resource": ""
} |
q28888 | New | train | func New(ctx context.Context) (*GPG, error) {
pubfn := filepath.Join(gpgHome(ctx), "pubring.gpg")
pubring, err := readKeyring(pubfn)
if err != nil {
return nil, err
}
secfn := filepath.Join(gpgHome(ctx), "secring.gpg")
secring, err := readKeyring(secfn)
if err != nil {
return nil, err
}
g := &GPG{
pubrin... | go | {
"resource": ""
} |
q28889 | RecipientIDs | train | func (g *GPG) RecipientIDs(ctx context.Context, ciphertext []byte) ([]string, error) {
recps := make([]string, 0, 1)
packets := packet.NewReader(bytes.NewReader(ciphertext))
for {
p, err := packets.Next()
if err != nil {
if err == io.EOF {
break
}
return nil, err
}
switch p := p.(type) {
case ... | go | {
"resource": ""
} |
q28890 | Encrypt | train | func (g *GPG) Encrypt(ctx context.Context, plaintext []byte, recipients []string) ([]byte, error) {
ciphertext := &bytes.Buffer{}
ents := g.recipientsToEntities(recipients)
wc, err := openpgp.Encrypt(ciphertext, ents, nil, nil, nil)
if err != nil {
return nil, errors.Wrapf(err, "failed to encrypt")
}
if _, err ... | go | {
"resource": ""
} |
q28891 | ImportPublicKey | train | func (g *GPG) ImportPublicKey(ctx context.Context, buf []byte) error {
el, err := openpgp.ReadArmoredKeyRing(bytes.NewReader(buf))
if err != nil {
return err
}
g.pubring = append(g.pubring, el...)
return nil
} | go | {
"resource": ""
} |
q28892 | Version | train | func (g *GPG) Version(context.Context) semver.Version {
return semver.Version{Major: 1}
} | go | {
"resource": ""
} |
q28893 | Sign | train | func (g *GPG) Sign(ctx context.Context, in string, sigf string) error {
signKeys := g.SigningKeys()
if len(signKeys) < 1 {
return fmt.Errorf("no signing keys available")
}
sigfh, err := os.OpenFile(sigf, os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
return err
}
defer sigfh.Close()
wc, err := clearsign.E... | go | {
"resource": ""
} |
q28894 | Verify | train | func (g *GPG) Verify(ctx context.Context, sigf string, in string) error {
sig, err := ioutil.ReadFile(sigf)
if err != nil {
return err
}
b, _ := clearsign.Decode(sig)
infh, err := os.Open(in)
if err != nil {
return err
}
defer infh.Close()
_, err = openpgp.CheckDetachedSignature(g.pubring, infh, bytes.NewR... | go | {
"resource": ""
} |
q28895 | EmailFromKey | train | func (g *GPG) EmailFromKey(ctx context.Context, id string) string {
ent := g.findEntity(id)
if ent == nil || ent.Identities == nil {
return ""
}
for name, id := range ent.Identities {
if id.UserId == nil {
return name
}
return id.UserId.Email
}
return ""
} | go | {
"resource": ""
} |
q28896 | NameFromKey | train | func (g *GPG) NameFromKey(ctx context.Context, id string) string {
ent := g.findEntity(id)
if ent == nil || ent.Identities == nil {
return ""
}
for name, id := range ent.Identities {
if id.UserId == nil {
return name
}
return id.UserId.Name
}
return ""
} | go | {
"resource": ""
} |
q28897 | ReadNamesFromKey | train | func (g *GPG) ReadNamesFromKey(ctx context.Context, buf []byte) ([]string, error) {
el, err := openpgp.ReadArmoredKeyRing(bytes.NewReader(buf))
if err != nil {
return nil, errors.Wrapf(err, "failed to read key ring")
}
if len(el) != 1 {
return nil, errors.Errorf("Public Key must contain exactly one Entity")
}
... | go | {
"resource": ""
} |
q28898 | Unclip | train | func (s *Action) Unclip(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
timeout := c.Int("timeout")
checksum := os.Getenv("GOPASS_UNCLIP_CHECKSUM")
time.Sleep(time.Second * time.Duration(timeout))
if err := clipboard.Clear(ctx, checksum, force); err != nil {
return ExitError(ctx, ExitIO, e... | go | {
"resource": ""
} |
q28899 | Find | train | func (s *Action) Find(ctx context.Context, c *cli.Context) error {
if c.IsSet("clip") {
ctx = WithClip(ctx, c.Bool("clip"))
}
if !c.Args().Present() {
return ExitError(ctx, ExitUsage, nil, "Usage: %s find <NEEDLE>", s.Name)
}
return s.find(ctx, c, c.Args().First(), s.show)
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.