Skip to content

Commit d0a051b

Browse files
committed
fix(plugins/bitwarden): fix multiple bugs in bitwarden plugins
1 parent ab2f370 commit d0a051b

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6363

6464
### Fixed
6565

66+
* **plugin:bitwarden_item**: Fix missing `raise` in multipart error handling, `break` instead of `continue` in multi-term lookup, `folder_id` wrongly typed as `list` instead of `str` in module, notes default mismatch between documentation and code, and wrong "lookup plugin" wording in module documentation
6667
* **roles**: Fix Ansible 2.19 deprecation warning for conditional results of type `int` by using `| length > 0` instead of `| length`
6768
* **role:firewall**: Fix fwbuilder repo clone being skipped when `run_once` picks a host without `firewall__fwbuilder_repo_url`
6869
* **role:sshd**: Validate sshd config with `sshd -t` before reloading the service

plugins/lookup/bitwarden_item.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def run(self, terms, variables=None, **kwargs):
329329
hostname = term.get('hostname', None)
330330
id_ = term.get('id', None)
331331
name = term.get('name', None)
332-
notes = term.get('notes', 'Automatically generated by Ansible.')
332+
notes = term.get('notes', 'Generated by Ansible.')
333333
organization_id = term.get('organization_id', None)
334334
password_length = term.get('password_length', 60)
335335
password_choice = term.get('password_choice', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
@@ -347,7 +347,7 @@ def run(self, terms, variables=None, **kwargs):
347347
result['username'] = result['login']['username']
348348
result['password'] = result['login']['password']
349349
ret.append(result)
350-
break # done here, go to next term
350+
continue # done here, go to next term
351351
else:
352352
# item not found by ID. if there is an ID given we expect it to exist
353353
raise AnsibleError('Item with id {} not found.'.format(id_))

plugins/module_utils/bitwarden.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def _api_call(self, url_path, method='GET', body=None, body_format='json'):
173173
try:
174174
content_type, body = prepare_multipart_no_base64(body)
175175
except (TypeError, ValueError) as e:
176-
BitwardenException('failed to parse body as form-multipart: %s' % to_native(e))
176+
raise BitwardenException('failed to parse body as form-multipart: %s' % to_native(e))
177177
headers['Content-Type'] = content_type
178178

179179
# mostly taken from ansible.builtin.url lookup plugin

plugins/modules/bitwarden_item.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
- If no password item is found, a new item is created. Useful for automation.
1919
- If you do not specify a name or Bitwarden ID, it searches using the name/title.
2020
- If there is an existing Bitwarden item that differs from the given parameters, the item is updated, and the updated item is returned.
21-
- If a search returns multiple entries, this lookup plugin throws an error, since it cannot decide which one to use.
22-
- On success, this lookup plugin returns the complete Bitwarden item object.
21+
- If a search returns multiple entries, this module throws an error, since it cannot decide which one to use.
22+
- On success, this module returns the complete Bitwarden item object.
2323
- If you don't specify a name/title for a password item, a name/title will be created automatically, using C(hostname - purpose) (for example "C(dbserver - MariaDB)") or just C(hostname) (for example "C(dbserver)", depending on what is provided).
2424
2525
notes:
@@ -288,7 +288,7 @@ def run_module():
288288
module_args = dict(
289289
attachments=dict(type='list', required=False, default=[]),
290290
collection_id=dict(type='str', required=False, default=None),
291-
folder_id=dict(type='list', required=False, default=None),
291+
folder_id=dict(type='str', required=False, default=None),
292292
hostname=dict(type='str', required=False, default=None),
293293
id=dict(type='str', required=False, default=None),
294294
name=dict(type='str', required=False, default=None),

0 commit comments

Comments
 (0)