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

events: WebSocket subscriptions support go-bexpr expressions #22835

Merged
merged 3 commits into from
Sep 7, 2023

Conversation

swenson
Copy link
Contributor

@swenson swenson commented Sep 6, 2023

Subscribing to events through a WebSocket now support boolean expressions to filter only the events wanted based on the fields

  • event_type
  • operation
  • source_plugin_mount
  • data_path
  • namespace

Example expressions:

These can be passed to vault events subscribe, e.g.,:

  • event_type == abc
  • source_plugin_mount == secret/
  • event_type != def and operation != write
vault events subscribe -filter='source_plugin_mount == secret/' 'kv*'

The docs for the vault events subscribe command and API endpoint will be coming shortly in a different PR, and will include a better specification for these expressions, similar to (or linking to) https://developer.hashicorp.com/boundary/docs/concepts/filtering

@swenson swenson added this to the 1.15 milestone Sep 6, 2023
@swenson swenson requested review from tomhjp and a team September 6, 2023 21:50
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Sep 6, 2023
@github-actions
Copy link

github-actions bot commented Sep 6, 2023

Build Results:
All builds succeeded! ✅

@github-actions
Copy link

github-actions bot commented Sep 6, 2023

CI Results:
All Go tests succeeded! ✅

Copy link
Contributor

@tomhjp tomhjp left a comment

Choose a reason for hiding this comment

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

LGTM! This came out in fewer lines than I expected

go.mod Outdated
@@ -380,6 +380,7 @@ require (
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/cronexpr v1.1.1 // indirect
github.com/hashicorp/go-bexpr v0.1.12 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Indirect seems weird, does this need a go mod tidy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I re-ran go mod tidy and it moved it to a direct dependency.

EventType string `bexpr:"event_type"`
Operation string `bexpr:"operation"`
SourcePluginMount string `bexpr:"source_plugin_mount"`
FullSecretPath string `bexpr:"full_secret_path"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to use data_path for consistency? I know data_path starts its life from the plugin as not a full path, but from an end user's point of view it always ends up being a full path once we've updated it right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I was mostly just copy-pasting from the RFC, but we should strive for consistency.

Christopher Swenson added 3 commits September 7, 2023 11:07
Subscribing to events through a WebSocket now support boolean
expressions to filter only the events wanted based on the fields

* `event_type`
* `operation`
* `source_plugin_mount`
* `full_secret_path`
* `namespace`

Example expressions:

These can be passed to `vault events subscribe`, e.g.,:
* `event_type == abc`
* `source_plugin_mount == secret/`
* `event_type != def and operation != write`

```sh
vault events subscribe -filter='source_plugin_mount == secret/' 'kv*'
```

The docs for the `vault events subscribe` command and API endpoint
will be coming shortly in a different PR, and will include a better
specification for these expressions, similar to (or linking to)
https://developer.hashicorp.com/boundary/docs/concepts/filtering
@swenson
Copy link
Contributor Author

swenson commented Sep 7, 2023

Thanks!

@swenson swenson enabled auto-merge (squash) September 7, 2023 18:09
@swenson swenson merged commit 022469d into main Sep 7, 2023
102 checks passed
@swenson swenson deleted the vault-19136/events-b-expr branch September 7, 2023 20:11
@tomhjp
Copy link
Contributor

tomhjp commented Sep 7, 2023

Not sure how, but it looks like the build in http/events_test.go broke since this got merged: https://github.com/hashicorp/vault/actions/runs/6114328001/job/16595812688

swenson pushed a commit that referenced this pull request Sep 7, 2023
When #22835 was merged, it was auto-squashed, so the `experiments`
import was removed, but the test still referenced it.

This removes the (now unnecessary) experiment from the test.
swenson pushed a commit that referenced this pull request Sep 7, 2023
When #22835 was merged, it was auto-squashed, so the `experiments`
import was removed, but the test still referenced it.

This removes the (now unnecessary) experiment from the test.
swenson pushed a commit that referenced this pull request Sep 7, 2023
When #22835 was merged, it was auto-squashed, so the `experiments`
import was removed, but the test still referenced it.

This removes the (now unnecessary) experiment from the test.
swenson pushed a commit that referenced this pull request Sep 7, 2023
…ons into release/1.15.x (#22872)

* backport of commit 022469d

* Fix auto-squash events experiments (#22876)

When #22835 was merged, it was auto-squashed, so the `experiments`
import was removed, but the test still referenced it.

This removes the (now unnecessary) experiment from the test.

---------

Co-authored-by: Christopher Swenson <christopher.swenson@hashicorp.com>
sgmiller added a commit that referenced this pull request Sep 8, 2023
* Ignore nonces when encrypting without convergence or with convergence versions > 1

* Honor nonce use warning in non-FIPS modes

* Revert "Honor nonce use warning in non-FIPS modes"

This reverts commit 2aee3db.

* Add a test func that removes a nonce when not needed

* err out rather than ignore the nonce

* Alter unit test to cover, also cover convergent version 3

* More unit test work

* Fix test 14

* changelog

* tests not already in a nonce present path

* Update unit test to not assume warning when nonce provided incorrectly

* remove unused test field

* Fix auto-squash events experiments

When #22835 was merged, it was auto-squashed, so the `experiments`
import was removed, but the test still referenced it.

This removes the (now unnecessary) experiment from the test.

* Allow nonces for managed keys, because we have no way of knowing if the backing cipher/mode needs one

---------

Co-authored-by: Christopher Swenson <christopher.swenson@hashicorp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants