lastpass / lastpass-cli

LastPass command line interface tool
GNU General Public License v2.0
2.85k stars 292 forks source link

show --json output excludes custom fields #543

Open smckellips opened 4 years ago

smckellips commented 4 years ago

lpass show 'SecretName' Folder/SecretName [id: 999999999999999999] URL: https://url input0: MyUser input1: p@ssw0rd

lpass show --json 'SecretName' --all [ { "id": "999999999999999999", "name": "SecretName", "fullname": "FolderSecretName, "username": "", "password": "", "last_modified_gmt": "1234567890", "last_touch": "1234567890", "group": "Folder", "url": "https://url", "note": "" } ]

fabricat commented 4 years ago

This is related to #547 since the JSON view also ignores eventual attachments

trinitronx commented 2 months ago

Seems that with lpass version 1.3.5, the custom item data is included in the "note" JSON field.

So, a workaround would be to process the colon-separated syntax in "notes":

lpass show --json  'item-id or pattern' | \
jq -r '.[].note' | \
perl -ne 'BEGIN{ print "{\n"; my @arr; }  if (  s/^(.+):(.*)/"\1": "\2"/m  ) { chomp($_); push(@arr, $_); }; $lines = join(",\n", @arr);  END{ print $lines ; print "\n}";}'

Quite a kludge / hack, and will probably not work for custom items that themselves have colon-separated multi-line text in the embedded Notes field.

Ideally, this should probably be implemented by lpass internally, because the Lastpass browser extension has some way of parsing these custom items and displaying all fields including custom-item embedded Notes field properly. So, it follows that Lastpass has some way of doing this and that lpass-cli should be able to know how to parse the internal representation of custom items and convert this to JSON.