v5 Fix Resource Listing (#82)

* Fix json Listing

* Always Decrypt Resource
This commit is contained in:
Samuel Lorch 2025-08-11 15:30:31 +02:00 committed by GitHub
parent 1ce31ace46
commit a3c466919c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 38 deletions

View file

@ -5,8 +5,6 @@ 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"
@ -38,28 +36,20 @@ 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": 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)
},
"Id": resource.ID,
"FolderParentID": resource.FolderParentID,
"Name": name,
"Username": username,
"URI": uri,
"Password": pass,
"Description": desc,
"CreatedTimestamp": resource.Created.Time,
"ModifiedTimestamp": resource.Modified.Time,
})