Skip to content

Commit

Permalink
Merge branch 'main' into vault-helm-doc-update-nlb
Browse files Browse the repository at this point in the history
  • Loading branch information
rajesht-source authored Jul 23, 2024
2 parents 23cb8e7 + 6a6a35a commit ff7720c
Show file tree
Hide file tree
Showing 90 changed files with 1,507 additions and 294 deletions.
12 changes: 12 additions & 0 deletions audit/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ func (b *Broker) LogRequest(ctx context.Context, in *logical.LogInput) (ret erro

// Audit event ended up in at least 1 sink.
if len(status.CompleteSinks()) > 0 {
// We should log warnings to the operational logs regardless of whether
// we consider the overall auditing attempt to be successful.
if len(status.Warnings) > 0 {
b.logger.Error("log request underlying pipeline error(s)", "error", &multierror.Error{Errors: status.Warnings})
}

return retErr.ErrorOrNil()
}

Expand Down Expand Up @@ -397,6 +403,12 @@ func (b *Broker) LogResponse(ctx context.Context, in *logical.LogInput) (ret err

// Audit event ended up in at least 1 sink.
if len(status.CompleteSinks()) > 0 {
// We should log warnings to the operational logs regardless of whether
// we consider the overall auditing attempt to be successful.
if len(status.Warnings) > 0 {
b.logger.Error("log response underlying pipeline error(s)", "error", &multierror.Error{Errors: status.Warnings})
}

return retErr.ErrorOrNil()
}

Expand Down
12 changes: 6 additions & 6 deletions builtin/logical/database/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func TestBackend_BadConnectionString(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, _ := postgreshelper.PrepareTestContainer(t, "13.4-buster")
cleanup, _ := postgreshelper.PrepareTestContainer(t)
defer cleanup()

respCheck := func(req *logical.Request) {
Expand Down Expand Up @@ -410,7 +410,7 @@ func TestBackend_basic(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "13.4-buster")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// Configure a connection
Expand Down Expand Up @@ -665,7 +665,7 @@ func TestBackend_connectionCrud(t *testing.T) {
dbFactory.sys = sys
client := cluster.Cores[0].Client.Logical()

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "13.4-buster")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// Mount the database plugin.
Expand Down Expand Up @@ -872,7 +872,7 @@ func TestBackend_roleCrud(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "13.4-buster")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// Configure a connection
Expand Down Expand Up @@ -1121,7 +1121,7 @@ func TestBackend_allowedRoles(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "13.4-buster")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// Configure a connection
Expand Down Expand Up @@ -1318,7 +1318,7 @@ func TestBackend_RotateRootCredentials(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "13.4-buster")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

connURL = strings.ReplaceAll(connURL, "postgres:secret", "{{username}}:{{password}}")
Expand Down
8 changes: 4 additions & 4 deletions builtin/logical/database/path_roles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func TestBackend_StaticRole_Config(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// create the database user
Expand Down Expand Up @@ -487,7 +487,7 @@ func TestBackend_StaticRole_ReadCreds(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// create the database user
Expand Down Expand Up @@ -667,7 +667,7 @@ func TestBackend_StaticRole_Updates(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// create the database user
Expand Down Expand Up @@ -966,7 +966,7 @@ func TestBackend_StaticRole_Role_name_check(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// create the database user
Expand Down
6 changes: 3 additions & 3 deletions builtin/logical/database/rollback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestBackend_RotateRootCredentials_WAL_rollback(t *testing.T) {
}
defer lb.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

connURL = strings.ReplaceAll(connURL, "postgres:secret", "{{username}}:{{password}}")
Expand Down Expand Up @@ -183,7 +183,7 @@ func TestBackend_RotateRootCredentials_WAL_no_rollback_1(t *testing.T) {
}
defer lb.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

connURL = strings.ReplaceAll(connURL, "postgres:secret", "{{username}}:{{password}}")
Expand Down Expand Up @@ -291,7 +291,7 @@ func TestBackend_RotateRootCredentials_WAL_no_rollback_2(t *testing.T) {
}
defer lb.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

connURL = strings.ReplaceAll(connURL, "postgres:secret", "{{username}}:{{password}}")
Expand Down
16 changes: 8 additions & 8 deletions builtin/logical/database/rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestBackend_StaticRole_Rotation_basic(t *testing.T) {

b.schedule = &TestSchedule{}

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// create the database user
Expand Down Expand Up @@ -274,7 +274,7 @@ func TestBackend_StaticRole_Rotation_Schedule_ErrorRecover(t *testing.T) {

b.schedule = &TestSchedule{}

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
t.Cleanup(cleanup)

// create the database user
Expand Down Expand Up @@ -458,7 +458,7 @@ func TestBackend_StaticRole_Rotation_NonStaticError(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// create the database user
Expand Down Expand Up @@ -562,7 +562,7 @@ func TestBackend_StaticRole_Rotation_Revoke_user(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// create the database user
Expand Down Expand Up @@ -783,7 +783,7 @@ func TestBackend_StaticRole_Rotation_QueueWAL_discard_role_newer_rotation_date(t
t.Fatal("could not convert to db backend")
}

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// create the database user
Expand Down Expand Up @@ -952,7 +952,7 @@ func assertWALCount(t *testing.T, s logical.Storage, expected int, key string) {
type userCreator func(t *testing.T, username, password string)

func TestBackend_StaticRole_Rotation_PostgreSQL(t *testing.T) {
cleanup, connURL := postgreshelper.PrepareTestContainer(t, "13.4-buster")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()
uc := userCreator(func(t *testing.T, username, password string) {
createTestPGUser(t, connURL, username, password, testRoleStaticCreate)
Expand Down Expand Up @@ -1246,7 +1246,7 @@ func TestBackend_StaticRole_Rotation_LockRegression(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// Configure a connection
Expand Down Expand Up @@ -1325,7 +1325,7 @@ func TestBackend_StaticRole_Rotation_Invalid_Role(t *testing.T) {
}
defer b.Cleanup(context.Background())

cleanup, connURL := postgreshelper.PrepareTestContainer(t, "")
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()

// create the database user
Expand Down
6 changes: 6 additions & 0 deletions builtin/logical/database/secret_creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func (b *databaseBackend) secretCredsRenew() framework.OperationFunc {
return nil, fmt.Errorf("secret is missing username internal data")
}
username, ok := usernameRaw.(string)
if !ok {
return nil, fmt.Errorf("username not a string")
}

roleNameRaw, ok := req.Secret.InternalData["role"]
if !ok {
Expand Down Expand Up @@ -98,6 +101,9 @@ func (b *databaseBackend) secretCredsRevoke() framework.OperationFunc {
return nil, fmt.Errorf("secret is missing username internal data")
}
username, ok := usernameRaw.(string)
if !ok {
return nil, fmt.Errorf("username not a string")
}

var resp *logical.Response

Expand Down
3 changes: 3 additions & 0 deletions changelog/27790.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:change
activity (enterprise): filter all fields in client count responses by the request namespace
```
3 changes: 3 additions & 0 deletions changelog/27809.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
audit: Ensure that any underyling errors from audit devices are logged even if we consider auditing to be a success.
```
7 changes: 4 additions & 3 deletions command/agentproxyshared/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,11 @@ func (ah *AuthHandler) Run(ctx context.Context, am AuthMethod) error {
isTokenFileMethod = path == "auth/token/lookup-self"
if isTokenFileMethod {
token, _ := data["token"].(string)
lookupSelfClient, err := clientToUse.CloneWithHeaders()
if err != nil {
// The error is called clientErr as to not shadow the other err above it.
lookupSelfClient, clientErr := clientToUse.CloneWithHeaders()
if clientErr != nil {
ah.logger.Error("failed to clone client to perform token lookup")
return err
return clientErr
}
lookupSelfClient.SetToken(token)
secret, err = lookupSelfClient.Auth().Token().LookupSelf()
Expand Down
4 changes: 4 additions & 0 deletions command/pki_reissue_intermediate.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func (c *PKIReIssueCACommand) Run(args []string) int {
}

templateData, err := parseTemplateCertificate(*certificate, useExistingKey, keyRef)
if err != nil {
c.UI.Error(fmt.Sprintf("Error fetching parsing template certificate: %v", err))
return 1
}
data := updateTemplateWithData(templateData, userData)

return pkiIssue(c.BaseCommand, parentIssuer, intermediateMount, c.flagNewIssuerName, c.flagKeyStorageSource, data)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ require (
golang.org/x/text v0.16.0
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d
google.golang.org/api v0.181.0
google.golang.org/grpc v1.64.0
google.golang.org/grpc v1.64.1
google.golang.org/protobuf v1.34.1
gopkg.in/ory-am/dockertest.v3 v3.3.4
k8s.io/apimachinery v0.29.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3016,8 +3016,8 @@ google.golang.org/grpc v1.52.3/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5v
google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw=
google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g=
google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA=
google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
Expand Down
27 changes: 17 additions & 10 deletions helper/testhelpers/pluginhelpers/pluginhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,17 @@ func CompilePlugin(t testing.TB, typ consts.PluginType, pluginVersion string, pl
var pluginBytes []byte

dir := ""
var err error
pluginRootDir := "builtin"
if typ == consts.PluginTypeDatabase {
pluginRootDir = "plugins"
}
for {
dir, err = os.Getwd()
if err != nil {
t.Fatal(err)
// So that we can assign to dir without overshadowing the other
// err variables.
var getWdErr error
dir, getWdErr = os.Getwd()
if getWdErr != nil {
t.Fatal(getWdErr)
}
// detect if we are in a subdirectory or the root directory and compensate
if _, err := os.Stat(pluginRootDir); os.IsNotExist(err) {
Expand Down Expand Up @@ -128,15 +130,20 @@ func CompilePlugin(t testing.TB, typ consts.PluginType, pluginVersion string, pl
}

// write the cached plugin if necessary
if _, err := os.Stat(pluginPath); os.IsNotExist(err) {
err = os.WriteFile(pluginPath, pluginBytes, 0o755)
}
if err != nil {
t.Fatal(err)
_, statErr := os.Stat(pluginPath)
if os.IsNotExist(statErr) {
err := os.WriteFile(pluginPath, pluginBytes, 0o755)
if err != nil {
t.Fatal(err)
}
} else {
if statErr != nil {
t.Fatal(statErr)
}
}

sha := sha256.New()
_, err = sha.Write(pluginBytes)
_, err := sha.Write(pluginBytes)
if err != nil {
t.Fatal(err)
}
Expand Down
Loading

0 comments on commit ff7720c

Please sign in to comment.