Skip to content

Commit

Permalink
go mod tidy; rename full_secret_path to data_path
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Swenson committed Sep 7, 2023
1 parent 5770892 commit 23b9d41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ require (
github.com/hashicorp/consul/api v1.23.0
github.com/hashicorp/errwrap v1.1.0
github.com/hashicorp/eventlogger v0.2.3
github.com/hashicorp/go-bexpr v0.1.12
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-discover v0.0.0-20210818145131-c573d69da192
github.com/hashicorp/go-gcp-common v0.8.0
Expand Down Expand Up @@ -380,7 +381,6 @@ 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
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.1 // indirect
github.com/hashicorp/go-msgpack/v2 v2.0.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions sdk/logical/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@ type EventReceivedBexpr struct {
EventType string `bexpr:"event_type"`
Operation string `bexpr:"operation"`
SourcePluginMount string `bexpr:"source_plugin_mount"`
FullSecretPath string `bexpr:"full_secret_path"`
DataPath string `bexpr:"data_path"`
Namespace string `bexpr:"namespace"`
}

// BexprDatum returns a copy of EventReceived formatted for use in evaluating go-bexpr boolean expressions.
func (x *EventReceived) BexprDatum() any {
operation := ""
fullSecretPath := ""
dataPath := ""

if x.Event != nil {
if x.Event.Metadata != nil {
operationValue := x.Event.Metadata.Fields[EventMetadataOperation]
if operationValue != nil {
operation = operationValue.GetStringValue()
}
fullSecretPathValue := x.Event.Metadata.Fields[EventMetadataDataPath]
if fullSecretPathValue != nil {
fullSecretPath = fullSecretPathValue.GetStringValue()
dataPathValue := x.Event.Metadata.Fields[EventMetadataDataPath]
if dataPathValue != nil {
dataPath = dataPathValue.GetStringValue()
}
}
}
Expand All @@ -99,7 +99,7 @@ func (x *EventReceived) BexprDatum() any {
EventType: x.EventType,
Operation: operation,
SourcePluginMount: x.PluginInfo.MountPath,
FullSecretPath: fullSecretPath,
DataPath: dataPath,
Namespace: x.Namespace,
}
}
6 changes: 3 additions & 3 deletions vault/eventbus/bus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,9 @@ func TestBexpr(t *testing.T) {
shouldPassFilter bool
}{
{"empty expression", "", true},
{"non-matching expression", "full_secret_path == nothing", false},
{"matching expression", "full_secret_path == secret/my/secret/path", true},
{"full matching expression", "full_secret_path == secret/my/secret/path and operation != read and source_plugin_mount == secret/ and source_plugin_mount != somethingelse", true},
{"non-matching expression", "data_path == nothing", false},
{"matching expression", "data_path == secret/my/secret/path", true},
{"full matching expression", "data_path == secret/my/secret/path and operation != read and source_plugin_mount == secret/ and source_plugin_mount != somethingelse", true},
}

for _, testCase := range testCases {
Expand Down

0 comments on commit 23b9d41

Please sign in to comment.