From c56f7b5f1b81fd0ba5abba5ea5b7515285e4c229 Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Fri, 19 Oct 2018 21:11:32 -0400 Subject: [PATCH] teach bitwarden lookup how to sync set sync=true in the lookup call to call `bw sync` before looking up data --- lookup_plugins/bitwarden.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lookup_plugins/bitwarden.py b/lookup_plugins/bitwarden.py index 3758705..c00dd6a 100755 --- a/lookup_plugins/bitwarden.py +++ b/lookup_plugins/bitwarden.py @@ -47,6 +47,8 @@ DOCUMENTATION = """ custom_field: description: If True, look up named field in custom fields instead of top-level dictionary. + sync: + description: If True, call `bw sync` before lookup """ EXAMPLES = """ @@ -103,6 +105,9 @@ class Bitwarden(object): "{0}".format(out)) return out.strip() + def sync(self): + self._run(['sync']) + def get_entry(self, key, field): return self._run(["get", field, key]).decode('utf-8') @@ -123,6 +128,10 @@ class LookupModule(LookupBase): field = kwargs.get('field', 'password') values = [] + + if kwargs.get('sync'): + bw.sync() + for term in terms: if kwargs.get('custom_field'): values.append(bw.get_custom_field(term, field))