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

Search for DB entry by title/url + regex #48

Open
EdificomSA opened this issue Jul 19, 2023 · 4 comments · May be fixed by #53
Open

Search for DB entry by title/url + regex #48

EdificomSA opened this issue Jul 19, 2023 · 4 comments · May be fixed by #53
Labels
enhancement New feature or request

Comments

@EdificomSA
Copy link

entry = kp.find_entries_by_path(path, first=True)

Using find_entries as in https://github.com/libkeepass/pykeepass#finding-entries
Maybe implementing another lookup plugin or maybe there is a way to add this feature in the existing lookup ?

@viczem viczem added the enhancement New feature or request label Jul 19, 2023
@viczem
Copy link
Owner

viczem commented Jul 19, 2023

This feature may be added in the existing lookup plugin

@hgtok
Copy link

hgtok commented Aug 4, 2024

working on an implementation.
approach with minimum code change, yet extend flexibility by sending kwargs directly to pykeepass.

- "{{ lookup('keepass', 'path/to/entry', 'username') }}"
- "{{ lookup('keepass', 'path/to/entry', 'password') }}"
- "{{ lookup('keepass', 'path/to/entry', 'custom_properties', 'my_prop_name') }}"
- "{{ lookup('keepass', 'path/to/entry', 'attachments', 'my_file_name') }}"

# assumes title search if '/' is not found in 'path/to/entry' 
# additional complex params can also be sent to pykeepass. (url, regex, etc)
- "{{ lookup('keepass', 'entry', 'username') }}"                                # default regex=false
- "{{ lookup('keepass', 'entry', 'password', regex=false) }}"
- "{{ lookup('keepass', 'entry', 'password', url='github.com', regex=true) }}"  # match both entry, url 
- "{{ lookup('keepass', 'entry', 'password', url='github.com', string={'custom_field1': 'custom value', 'custom_field2': 'custom value'}, regex=true, history=true) }}"  # complex

@viczem
Copy link
Owner

viczem commented Aug 4, 2024

@hgtok I have an idea how it implement

"{{ lookup('keepass', 'spam-[0-9]+$', 'password', regex=true) }}"  # default is regexp match by path
"{{ lookup('keepass', 'spam-[0-9]+$', 'password', regex=url) }}"  # regexp match by url attribute
"{{ lookup('keepass', 'spam-[0-9]+$', 'password', regex=username) }}"  # regexp match by username attribute
... other attributes

"{{ lookup('keepass', 'spam-[0-9]+$', 'password') }}"  # regexp is not used - search by path as default

@hgtok
Copy link

hgtok commented Aug 4, 2024

looks good. when can it be released?

a possible limitation of your implementation: unable to support complex search like 'string' or multiple conditions.

have submitted my implementation for this issue under #53 for your considerations.

@hgtok hgtok linked a pull request Aug 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants