Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Filter would be exported entries based on JSONPath filter expression #208

Merged
merged 6 commits into from
Jan 24, 2024

Conversation

davidandreoletti
Copy link
Contributor

@davidandreoletti davidandreoletti commented Jan 23, 2024

Here is an example, for imported entries with a 'tags' field, one can only export entries with tag value containing 'Defaults'.

This filter is independent of the input file format used as it runs prior to exporting entries to the target password manager.

pass-import --force --verbose --filter
'$.entries[*].tags[?@="Defaults"]' csv 1password /tmp/1Password.1pif/data.1pif --out /tmp/data.csv

Tested on:

  • 1password 1PIF format manually
  • generic password manager automatically (see unit test)

Documentation:

  • --help documentation updated. The helper function seems not to support a long form description. The doc is added to the help field instead.
  • README --help updated too.

@davidandreoletti davidandreoletti marked this pull request as draft January 23, 2024 15:45
@davidandreoletti davidandreoletti changed the title Filter would be exported entries based on JSONPath filter expression feat: Filter would be exported entries based on JSONPath filter expression Jan 23, 2024
@davidandreoletti davidandreoletti force-pushed the filter-on-tags branch 3 times, most recently from 2784350 to 592c673 Compare January 23, 2024 17:41
@davidandreoletti davidandreoletti marked this pull request as ready for review January 23, 2024 17:48
@davidandreoletti davidandreoletti marked this pull request as draft January 23, 2024 17:53
@roddhjav
Copy link
Owner

Thanks. Nice feature.

Can you make jsonpath_ng an optional requirement. As it is only supported in 1password, I don't want to require it as a strict deps.

@davidandreoletti
Copy link
Contributor Author

davidandreoletti commented Jan 23, 2024

It was tested on 1Password but the logic is password manager independent.

See unit test.

With this filter feature, people can filter on anything data field exported.

I filtered on tags and used 1Password as it is my use case.

Let me know if your POV changed.

@roddhjav
Copy link
Owner

I would rather keep it optional for now (I am the one getting the issue regarding missing deps...)

@davidandreoletti
Copy link
Contributor Author

davidandreoletti commented Jan 23, 2024

Got it. There it is fixed.

@roddhjav roddhjav merged commit 8359dda into roddhjav:master Jan 24, 2024
0 of 3 checks passed
@roddhjav
Copy link
Owner

roddhjav commented Jan 24, 2024

Thanks. Merged

Edit: I was a bit fast to merge, now that I have fixed the CI, your PR seems to have some edge case: https://github.com/roddhjav/pass-import/actions/runs/7641446941/job/20818786230

@davidandreoletti
Copy link
Contributor Author

davidandreoletti commented Jan 25, 2024

Will look into it today and address the changes is #209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants