pass Get unmarshaling error
- Linguagem predominante
- Go
- Estrelas
- 657
- Forks
- 155
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
for a given entry with pass:
```
$ pass show dummy
plop
```
The given code is stumbling upon some unmarshall issue:
```go
func Execute() {
fmt.Println(Pass("", "dummy"))
}
func Pass(prefix string,key string) string {
ring, err := keyring.Open(keyring.Config{
ServiceName: "example",
PassCmd: "pass",
AllowedBackends: []keyring.BackendType{"pass"},
PassDir: "~/.password-store",
PassPrefix: prefix,
})
if err != nil {
panic(err)
}
i, err := ring.Get(key)
if err != nil {
panic(err)
}
return string(i.Data)
}
```
So `ring.Get(key)` is failing with the following error:
```
panic: invalid character 'p' looking for beginning of value
```
From what I could gather, in the [Get function](https://github.com/99designs/keyring/blob/v1.2.2/pass.go#L73) - I have annoted value I get some delve debugging.
```go
func (k *passKeyring) Get(key string) (Item, error) {
if !k.itemExists(key) {
return Item{}, ErrKeyNotFound
}
name := filepath.Join(k.prefix, key)
// this is working
cmd := k.pass("show", name)
output, err := cmd.Output()
// output value is "plop\n"
if err != nil {
return Item{}, err
}
var decoded Item
err = json.Unmarshal(output, &decoded)
// this is failing
// in json.Unmarshal -> err := checkValid(data, &d.scan)
// is msg: "invalid character 'p' looking for beginning of value",
return decoded, err
}
```
I am not sure what is the issue, nor why it needs to be unmarshalled, pass is not returning no json, just a string.
Am I missing something?
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
O problema está na função Get de pass.go, que espera saída JSON do comando 'pass', mas recebe texto simples. Examine a implementação do backend pass para entender o formato de dados esperado. Veja como outros backends (como file ou secret-service) serializam items. A correção provavelmente envolve alterar a invocação do comando pass para gerar JSON ou ajustar a lógica de unmarshaling para lidar com texto simples. Verifique se existe uma flag de 'pass' para saída JSON ou se a struct Item precisa ser populada de forma diferente.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Domínio
- cli, security
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 55/100