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

Unable to access fields explicitly defined through value via register variables #55

Open
kujenga opened this issue Jan 29, 2022 · 1 comment
Labels
bug Something isn't working tracked Issue is tracked in 1Password's internal ticketing system as well.

Comments

@kujenga
Copy link

kujenga commented Jan 29, 2022

Your environment

Collection Version: 2.2.0

Connect Server Version: 1.5.0

OS: macos 12.2

Ansible Version: 2.12.1

What happened?

When creating a new item via onepassword.connect.generic_item as specified in the README for this repo, I am unable to reference fields that are explicitly specified through the value: method which are replaced with the value VALUE_SPECIFIED_IN_NO_LOG_PARAMETER when creating an item.

What did you expect to happen?

I was expecting to be able to reference these values through the registered variable, in the same way that generated values are able to be accessed.

Steps to reproduce

  1. Create an item as described in the README here: https://github.com/1Password/ansible-onepasswordconnect-collection#example-usage in the "Create a new Item" sub-section
  2. Attempt to access the value of the Codeword field via the op_item register as follows: {{ op_item.op_item.fields.Codeword.value }}
  3. Observe that the output value is VALUE_SPECIFIED_IN_NO_LOG_PARAMETER

It's worth noting that this behavior does not happen for auto-generated values, just for ones that are explicitly specified.

Notes & Logs

This appears to be because of the use of no_log=True in this line:

value=dict(type="str", no_log=True),

There are a variety of ways to work around this issue, but it seemed inconsistent and surprising that values from the task definition are inaccessible, but auto-generated values are readily accessible.

@kujenga kujenga added the bug Something isn't working label Jan 29, 2022
@edif2008 edif2008 changed the title Unable to access fields explicitly defined through value via register variables [4] Unable to access fields explicitly defined through value via register variables Feb 8, 2022
@verkaufer
Copy link
Member

👋 Thanks for reporting this issue! It's definitely not the behavior we intended. This is caused by how Ansible interprets no_log and how we create those generated values.

As you mentioned, the no_log option is hiding the value you provide to each field.value configuration. This is in line with how Ansible describes the no_log option in the argument spec.

The surprising behavior for generated fields comes from how Connect creates those values. The play simply sends the generator config to Connect and Connect returns the generated secret. As far as I know, the no_log parameter doesn't sanitize data returned from plays, just data provided to it.


What kind of behavior do you expect when mixing known secrets with values you want to generate?

We designed it the way we did because:

  1. We wanted to protect the secrets you were providing to Connect (i.e. not leaking them when sending to Connect)
  2. We assumed the generated secret needed to be returned in plaintext so you could pass its value to some other Ansible play.

Unfortunately, It looks like there's no easy way to no_log specific fields using Ansible's built-in options. Best I could find was this SO answer.

@edif2008 edif2008 added the tracked Issue is tracked in 1Password's internal ticketing system as well. label May 30, 2022
@edif2008 edif2008 changed the title [4] Unable to access fields explicitly defined through value via register variables Unable to access fields explicitly defined through value via register variables May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked Issue is tracked in 1Password's internal ticketing system as well.
Projects
None yet
Development

No branches or pull requests

3 participants