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

Better sensitive value handling in Google pub/sub logging provider #376

Merged
merged 4 commits into from
Mar 4, 2021

Conversation

robwil
Copy link
Contributor

@robwil robwil commented Mar 1, 2021

This allows users to provide secret values for the Google pub/sub log integration, in a similar way that is already implemented for BigQuery and GCS (via an optional environment variable). Importantly, it also marks the private key as a sensitive value so it won't be logged during plan / apply.

cc @jw2340

@Integralist Integralist added the enhancement New feature or request label Mar 2, 2021
Copy link
Collaborator

@Integralist Integralist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @robwil for opening this PR.

The code looks fine to me. I left one comment which is an external conversation that I thought might be interesting to share. Otherwise it would be good if we could validate this change set with a test. Is that something you can add please.

- **topic** (String) The Google Cloud Pub/Sub topic to which logs will be published
- **user** (String) Your Google Cloud Platform service account email address. The `client_email` field in your service account authentication JSON

Optional:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was actually quite interesting to me, so I raised a query with the official terraform documentation maintainers:

hashicorp/terraform-plugin-docs#42

NOTE: this isn't a blocker to the PR getting approved/merged (as it's outside the control of both the contributor and ourselves as maintainers of this terraform provider), it's just something I noticed and thought I'd share.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing worth noting here is that the field does in fact become optional from the perspective of the user, since if you don't explicitly pass it then it will default to "" (empty string). In practice, we can leave secret_key out of the TF config block entirely.

But I do see your point that since it will always have a value, and is required, it is a little strange to call it "optional" in the documentation.

@robwil
Copy link
Contributor Author

robwil commented Mar 2, 2021

The reason I left a test out is because none of the existing envvar overrides are covered with tests, so there wasn't a clear example to follow (as someone unfamiliar with the test setup here). But I can take a shot at it!

@robwil
Copy link
Contributor Author

robwil commented Mar 2, 2021

I just added an attempt at a unit test. I didn't see too many other examples of this, but the way I did it seemed like the most straight-forward way to test that secret_key could receive a value from an envvar override.

Copy link
Collaborator

@Integralist Integralist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thanks @robwil ❤️

Comment on lines +86 to +88
defer func() {
os.Setenv(envVarKey, originalEnvValue)
}()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate this detail 🙂

@Integralist Integralist merged commit 0336dd0 into fastly:master Mar 4, 2021
@robwil robwil deleted the pubsub-log-sensitive-handling branch March 4, 2021 14:44
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 this pull request may close these issues.

2 participants