mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-09-13 06:59:07 +00:00
Compare commits
No commits in common. "e2e0694683cbdf1cdbbc82e6b5667d4f67e90b2b" and "1ce31ace461cc12affda16846d64967d794e3be7" have entirely different histories.
e2e0694683
...
1ce31ace46
4 changed files with 39 additions and 29 deletions
2
go.mod
2
go.mod
|
@ -7,7 +7,7 @@ toolchain go1.23.6
|
|||
require (
|
||||
al.essio.dev/pkg/shellescape v1.6.0
|
||||
github.com/google/cel-go v0.26.0
|
||||
github.com/passbolt/go-passbolt v0.7.3-0.20250811135314-1ffa5a23bd29
|
||||
github.com/passbolt/go-passbolt v0.7.3-0.20250805134827-8b00fcd4971e
|
||||
github.com/pterm/pterm v0.12.81
|
||||
github.com/spf13/cobra v1.9.1
|
||||
github.com/spf13/viper v1.20.1
|
||||
|
|
2
go.sum
2
go.sum
|
@ -79,8 +79,6 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6T
|
|||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/passbolt/go-passbolt v0.7.3-0.20250805134827-8b00fcd4971e h1:hOFvvLNg7JoW0BlBX89Cu1kFRZMggRcAyOC8ZnCoJqo=
|
||||
github.com/passbolt/go-passbolt v0.7.3-0.20250805134827-8b00fcd4971e/go.mod h1:gluZh5f4qwo4QraUD6B68ZM3GHX3i3J2T/HHLcC1O7U=
|
||||
github.com/passbolt/go-passbolt v0.7.3-0.20250811135314-1ffa5a23bd29 h1:4KBVFj492jMi8pu99lZjxrFFfXH49O7Itw8yiCRXkGU=
|
||||
github.com/passbolt/go-passbolt v0.7.3-0.20250811135314-1ffa5a23bd29/go.mod h1:gluZh5f4qwo4QraUD6B68ZM3GHX3i3J2T/HHLcC1O7U=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
|
|
|
@ -5,6 +5,8 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/google/cel-go/cel"
|
||||
"github.com/google/cel-go/common/types"
|
||||
"github.com/google/cel-go/common/types/ref"
|
||||
"github.com/passbolt/go-passbolt-cli/util"
|
||||
"github.com/passbolt/go-passbolt/api"
|
||||
"github.com/passbolt/go-passbolt/helper"
|
||||
|
@ -36,20 +38,28 @@ func filterResources(resources *[]api.Resource, celCmd string, ctx context.Conte
|
|||
|
||||
filteredResources := []api.Resource{}
|
||||
for _, resource := range *resources {
|
||||
// TODO We should decrypt the secret only when required for performance reasonse
|
||||
_, name, username, uri, pass, desc, err := helper.GetResource(ctx, client, resource.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Get Resource %w", err)
|
||||
}
|
||||
|
||||
val, _, err := (*program).ContextEval(ctx, map[string]any{
|
||||
"Id": resource.ID,
|
||||
"FolderParentID": resource.FolderParentID,
|
||||
"Name": name,
|
||||
"Username": username,
|
||||
"URI": uri,
|
||||
"Password": pass,
|
||||
"Description": desc,
|
||||
"Id": resource.ID,
|
||||
"FolderParentID": resource.FolderParentID,
|
||||
"Name": resource.Name,
|
||||
"Username": resource.Username,
|
||||
"URI": resource.URI,
|
||||
"Password": func() ref.Val {
|
||||
_, _, _, _, pass, _, err := helper.GetResource(ctx, client, resource.ID)
|
||||
if err != nil {
|
||||
fmt.Printf("Get Resource %v", err)
|
||||
return types.String("")
|
||||
}
|
||||
return types.String(pass)
|
||||
},
|
||||
"Description": func() ref.Val {
|
||||
_, _, _, _, _, descr, err := helper.GetResource(ctx, client, resource.ID)
|
||||
if err != nil {
|
||||
fmt.Printf("Get Resource %v", err)
|
||||
return types.String("")
|
||||
}
|
||||
return types.String(descr)
|
||||
},
|
||||
"CreatedTimestamp": resource.Created.Time,
|
||||
"ModifiedTimestamp": resource.Modified.Time,
|
||||
})
|
||||
|
|
|
@ -93,16 +93,16 @@ func ResourceList(cmd *cobra.Command, args []string) error {
|
|||
if jsonOutput {
|
||||
outputResources := []ResourceJsonOutput{}
|
||||
for i := range resources {
|
||||
_, name, username, uri, pass, desc, err := helper.GetResource(ctx, client, resources[i].ID)
|
||||
_, _, _, _, pass, desc, err := helper.GetResource(ctx, client, resources[i].ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Get Resource %w", err)
|
||||
}
|
||||
outputResources = append(outputResources, ResourceJsonOutput{
|
||||
ID: &resources[i].ID,
|
||||
FolderParentID: &resources[i].FolderParentID,
|
||||
Name: &name,
|
||||
Username: &username,
|
||||
URI: &uri,
|
||||
Name: &resources[i].Name,
|
||||
Username: &resources[i].Username,
|
||||
URI: &resources[i].URI,
|
||||
Password: &pass,
|
||||
Description: &desc,
|
||||
CreatedTimestamp: &resources[i].Created.Time,
|
||||
|
@ -118,12 +118,6 @@ func ResourceList(cmd *cobra.Command, args []string) error {
|
|||
data := pterm.TableData{columns}
|
||||
|
||||
for _, resource := range resources {
|
||||
// TODO We should decrypt the secret only when required for performance reasonse
|
||||
_, name, username, uri, pass, desc, err := helper.GetResource(ctx, client, resource.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Get Resource %w", err)
|
||||
}
|
||||
|
||||
entry := make([]string, len(columns))
|
||||
for i := range columns {
|
||||
switch strings.ToLower(columns[i]) {
|
||||
|
@ -132,14 +126,22 @@ func ResourceList(cmd *cobra.Command, args []string) error {
|
|||
case "folderparentid":
|
||||
entry[i] = resource.FolderParentID
|
||||
case "name":
|
||||
entry[i] = shellescape.StripUnsafe(name)
|
||||
entry[i] = shellescape.StripUnsafe(resource.Name)
|
||||
case "username":
|
||||
entry[i] = shellescape.StripUnsafe(username)
|
||||
entry[i] = shellescape.StripUnsafe(resource.Username)
|
||||
case "uri":
|
||||
entry[i] = shellescape.StripUnsafe(uri)
|
||||
entry[i] = shellescape.StripUnsafe(resource.URI)
|
||||
case "password":
|
||||
_, _, _, _, pass, _, err := helper.GetResource(ctx, client, resource.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Get Resource %w", err)
|
||||
}
|
||||
entry[i] = shellescape.StripUnsafe(pass)
|
||||
case "description":
|
||||
_, _, _, _, _, desc, err := helper.GetResource(ctx, client, resource.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Get Resource %w", err)
|
||||
}
|
||||
entry[i] = shellescape.StripUnsafe(desc)
|
||||
case "createdtimestamp":
|
||||
entry[i] = resource.Created.Format(time.RFC3339)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue