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

OnePassword library assumes incorrectly that a field als an attribute 'value' #7240

Closed
1 task done
wkleinheerenbrink opened this issue Sep 11, 2023 · 3 comments · Fixed by #7241
Closed
1 task done
Labels
bug This issue/PR relates to a bug has_pr lookup lookup plugin plugins plugin (any type)

Comments

@wkleinheerenbrink
Copy link
Contributor

Summary

When using the 'lookup' method to get a field value from a field in a OnePassword Vault, the method might raise a KeyError when trying to access the key 'value' on the field dict. Given a template in the OnePassword vault, a label for a field might exist without a value if the user has omitted this value on purpose.

Issue Type

Bug Report

Component Name

onepassword

Ansible Version

$ ansible --version
ansible [core 2.15.3]
  python version = 3.9.17 (main, Jun 20 2023, 17:20:08) [Clang 14.0.3 (clang-1403.0.22.14.1)] 
  jinja version = 3.0.1

Community.general Version

$ ansible-galaxy collection list community.general
community.general 7.3.0  
community.general 2.0.1  

Configuration

$ ansible-config dump --only-changed

OS / Environment

No response

Steps to Reproduce

1. Create a onepassword item
2. Add a field with a label 'some-omitted-property'
3. Leave the value empty
4. Add a rule lookup(..., 'some-omitted-property') to an ansible script
5. Run ansible

Expected Results

Empty (or None-like) value at the location of lookup(..., 'some-omitted-property')

Actual Results

KeyError("value", "value")

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
wkleinheerenbrink added a commit to wkleinheerenbrink/community.general that referenced this issue Sep 11, 2023
…-collections#7240)

A OnePassword field item might not have a value (property) when the user has omitted it (on purpose).
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@samdoran
Copy link
Contributor

Very good find. In the v1 class, the .get() method is used to protect against this.

Simple reproducer playbook
- hosts: localhost

  tasks:
    - debug:
        msg: "{{ lookup('onepassword', 'Dummy Login', field='some-omitted-property') }}"

wkleinheerenbrink added a commit to wkleinheerenbrink/community.general that referenced this issue Sep 12, 2023
…-collections#7240)

A OnePassword field item might not have a value (property) when the user has omitted it (on purpose).
wkleinheerenbrink added a commit to wkleinheerenbrink/community.general that referenced this issue Sep 12, 2023
…-collections#7240)

A OnePassword field item might not have a value (property) when the user has omitted it (on purpose).
felixfontein pushed a commit that referenced this issue Sep 13, 2023
…7241)

A OnePassword field item might not have a value (property) when the user has omitted it (on purpose).
patchback bot pushed a commit that referenced this issue Sep 13, 2023
…7241)

A OnePassword field item might not have a value (property) when the user has omitted it (on purpose).

(cherry picked from commit 1beb38c)
patchback bot pushed a commit that referenced this issue Sep 13, 2023
…7241)

A OnePassword field item might not have a value (property) when the user has omitted it (on purpose).

(cherry picked from commit 1beb38c)
felixfontein pushed a commit that referenced this issue Sep 13, 2023
…for safe lookup of value (Fixes #7240) (#7258)

Use `get(..)` instead of [..] for safe lookup of value (Fixes #7240) (#7241)

A OnePassword field item might not have a value (property) when the user has omitted it (on purpose).

(cherry picked from commit 1beb38c)

Co-authored-by: Wouter Klein Heerenbrink <[email protected]>
felixfontein pushed a commit that referenced this issue Sep 13, 2023
…for safe lookup of value (Fixes #7240) (#7257)

Use `get(..)` instead of [..] for safe lookup of value (Fixes #7240) (#7241)

A OnePassword field item might not have a value (property) when the user has omitted it (on purpose).

(cherry picked from commit 1beb38c)

Co-authored-by: Wouter Klein Heerenbrink <[email protected]>
etrombly pushed a commit to etrombly/community.general that referenced this issue Oct 25, 2023
…-collections#7240) (ansible-collections#7241)

A OnePassword field item might not have a value (property) when the user has omitted it (on purpose).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr lookup lookup plugin plugins plugin (any type)
Projects
None yet
3 participants