Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions service/policy/attributes/attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,15 @@ func Test_GetAttributeRequest(t *testing.T) {
{
name: "Valid Deprecated Id",
req: &attributes.GetAttributeRequest{
//nolint:staticcheck // these cases exist to validate the deprecated Id field, so they must set it
Id: validUUID,
},
expectError: false,
},
{
name: "Invalid Deprecated Id (empty string)",
req: &attributes.GetAttributeRequest{
//nolint:staticcheck // these cases exist to validate the deprecated Id field, so they must set it
Id: "",
},
expectError: true,
Expand Down Expand Up @@ -301,6 +303,7 @@ func Test_GetAttributeRequest(t *testing.T) {
{
name: "Invalid can't have both Id and Identifier",
req: &attributes.GetAttributeRequest{
//nolint:staticcheck // these cases exist to validate the deprecated Id field, so they must set it
Id: validUUID,
Identifier: &attributes.GetAttributeRequest_Fqn{
Fqn: "https://example.com/valid_fqn",
Expand Down Expand Up @@ -806,13 +809,15 @@ func Test_GetAttributeValueRequest(t *testing.T) {
{
name: "Valid Deprecated Id",
req: &attributes.GetAttributeValueRequest{
//nolint:staticcheck // these cases exist to validate the deprecated Id field, so they must set it
Id: validUUID,
},
expectError: false,
},
{
name: "Invalid Deprecated Id (empty string)",
req: &attributes.GetAttributeValueRequest{
//nolint:staticcheck // these cases exist to validate the deprecated Id field, so they must set it
Id: "",
},
expectError: true,
Expand Down Expand Up @@ -859,6 +864,7 @@ func Test_GetAttributeValueRequest(t *testing.T) {
{
name: "Invalid can't have both Id and Identifier",
req: &attributes.GetAttributeValueRequest{
//nolint:staticcheck // these cases exist to validate the deprecated Id field, so they must set it
Id: validUUID,
Identifier: &attributes.GetAttributeValueRequest_Fqn{
Fqn: "https://example.com/valid_fqn_value",
Expand Down
1 change: 1 addition & 0 deletions service/policy/db/attribute_fqn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func TestResolveEffectiveKasKeys(t *testing.T) {
return &policy.KeyAccessServer{
Uri: uri,
Id: id,
//nolint:staticcheck // fixture mirrors stored grants, which still carry the deprecated PublicKey
PublicKey: &policy.PublicKey{
PublicKey: &policy.PublicKey_Cached{
Cached: &policy.KasPublicKeySet{Keys: []*policy.KasPublicKey{
Expand Down
1 change: 1 addition & 0 deletions service/policy/db/grant_mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func mapKasKeysToGrants(keys []*policy.SimpleKasKey, existingGrants []*policy.Ke
grant := &policy.KeyAccessServer{
Uri: key.GetKasUri(),
Id: key.GetKasId(),
//nolint:staticcheck // grants are mapped back onto the deprecated PublicKey field for clients that have not moved to multiple key pairs
PublicKey: &policy.PublicKey{
PublicKey: &policy.PublicKey_Cached{
Cached: &policy.KasPublicKeySet{Keys: []*policy.KasPublicKey{newKasPublicKey}},
Expand Down
23 changes: 14 additions & 9 deletions service/policy/db/key_access_server_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ func (c PolicyDBClient) GetKeyAccessServer(ctx context.Context, identifier any)
}

return &policy.KeyAccessServer{
Id: kas.ID,
Uri: kas.Uri,
Id: kas.ID,
Uri: kas.Uri,
//nolint:staticcheck // responses still populate the deprecated PublicKey for clients that have not moved to multiple key pairs
PublicKey: publicKey,
Name: kas.Name.String,
Metadata: metadata,
Expand Down Expand Up @@ -210,8 +211,9 @@ func (c PolicyDBClient) CreateKeyAccessServer(ctx context.Context, r *kasregistr
}

return &policy.KeyAccessServer{
Id: createdID,
Uri: uri,
Id: createdID,
Uri: uri,
//nolint:staticcheck // responses still populate the deprecated PublicKey for clients that have not moved to multiple key pairs
PublicKey: publicKey,
Name: name,
Metadata: metadata,
Expand Down Expand Up @@ -277,9 +279,10 @@ func (c PolicyDBClient) UpdateKeyAccessServer(ctx context.Context, id string, r
}

return &policy.KeyAccessServer{
Id: id,
Uri: uri,
Name: name,
Id: id,
Uri: uri,
Name: name,
//nolint:staticcheck // responses still populate the deprecated PublicKey for clients that have not moved to multiple key pairs
PublicKey: publicKey,
Metadata: metadata,
SourceType: r.GetSourceType(),
Expand Down Expand Up @@ -327,8 +330,9 @@ func (c PolicyDBClient) ListKeyAccessServerGrants(ctx context.Context, r *kasreg
return nil, fmt.Errorf("failed to unmarshal KAS public key: %w", err)
}
kas := &policy.KeyAccessServer{
Id: grant.KasID,
Uri: grant.KasUri,
Id: grant.KasID,
Uri: grant.KasUri,
//nolint:staticcheck // responses still populate the deprecated PublicKey for clients that have not moved to multiple key pairs
PublicKey: pubKey,
Name: grant.KasName.String,
}
Expand Down Expand Up @@ -358,6 +362,7 @@ func (c PolicyDBClient) ListKeyAccessServerGrants(ctx context.Context, r *kasreg
nextOffset = getNextOffset(offset, limit, total)
}
return &kasregistry.ListKeyAccessServerGrantsResponse{ //nolint:staticcheck // Compatibility path for deprecated RPC.
//nolint:staticcheck // compatibility path for the deprecated ListKeyAccessServerGrants RPC
Grants: grants,
Pagination: &policy.PageResponse{
CurrentOffset: params.Offset,
Expand Down
4 changes: 2 additions & 2 deletions service/policy/dynamicvaluemapping/dynamic_value_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (s DynamicValueMappingService) CreateDynamicValueMapping(ctx context.Contex
return nil
})
if err != nil {
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("dynamicValueMapping", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("dynamic_value_mapping", req.Msg.String()))
}
return connect.NewResponse(rsp), nil
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func (s DynamicValueMappingService) UpdateDynamicValueMapping(ctx context.Contex
return nil
})
if err != nil {
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextUpdateFailed, slog.String("id", id), slog.String("dynamicValueMapping", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextUpdateFailed, slog.String("id", id), slog.String("dynamic_value_mapping", req.Msg.String()))
}

return connect.NewResponse(rsp), nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func Test_GetKeyAccessServerRequest(t *testing.T) {
Identifier: &kasregistry.GetKeyAccessServerRequest_Name{
Name: "kas-name",
},
//nolint:staticcheck // asserts that setting both the deprecated Id and an Identifier is rejected
Id: validUUID,
},
expectError: true,
Expand Down
10 changes: 5 additions & 5 deletions service/policy/keymanagement/key_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (ksvc Service) CreateProviderConfig(ctx context.Context, req *connect.Reque
return nil
})
if err != nil {
return nil, db.StatusifyError(ctx, ksvc.logger, err, db.ErrTextCreationFailed, slog.String("keyManagementService", req.Msg.GetName()))
return nil, db.StatusifyError(ctx, ksvc.logger, err, db.ErrTextCreationFailed, slog.String("key_management_service", req.Msg.GetName()))
}

return connect.NewResponse(rsp), nil
Expand All @@ -154,7 +154,7 @@ func (ksvc Service) GetProviderConfig(ctx context.Context, req *connect.Request[

pc, err := ksvc.dbClient.GetProviderConfig(ctx, req.Msg)
if err != nil {
return nil, db.StatusifyError(ctx, ksvc.logger, err, db.ErrTextGetRetrievalFailed, slog.String("keyManagementService", req.Msg.String()))
return nil, db.StatusifyError(ctx, ksvc.logger, err, db.ErrTextGetRetrievalFailed, slog.String("key_management_service", req.Msg.String()))
}

rsp.ProviderConfig = pc
Expand All @@ -166,7 +166,7 @@ func (ksvc Service) ListProviderConfigs(ctx context.Context, req *connect.Reques

resp, err := ksvc.dbClient.ListProviderConfigs(ctx, req.Msg.GetPagination())
if err != nil {
return nil, db.StatusifyError(ctx, ksvc.logger, err, db.ErrTextGetRetrievalFailed, slog.String("keyManagementService", req.Msg.String()))
return nil, db.StatusifyError(ctx, ksvc.logger, err, db.ErrTextGetRetrievalFailed, slog.String("key_management_service", req.Msg.String()))
}

return connect.NewResponse(resp), nil
Expand Down Expand Up @@ -227,7 +227,7 @@ func (ksvc Service) UpdateProviderConfig(ctx context.Context, req *connect.Reque
return nil
})
if err != nil {
return nil, db.StatusifyError(ctx, ksvc.logger, err, db.ErrTextUpdateFailed, slog.String("keyManagementService", req.Msg.GetId()))
return nil, db.StatusifyError(ctx, ksvc.logger, err, db.ErrTextUpdateFailed, slog.String("key_management_service", req.Msg.GetId()))
}

return connect.NewResponse(rsp), nil
Expand All @@ -246,7 +246,7 @@ func (ksvc Service) DeleteProviderConfig(ctx context.Context, req *connect.Reque
pc, err := ksvc.dbClient.DeleteProviderConfig(ctx, req.Msg.GetId())
if err != nil {
ksvc.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, ksvc.logger, err, db.ErrTextDeletionFailed, slog.String("keyManagementService", req.Msg.GetId()))
return nil, db.StatusifyError(ctx, ksvc.logger, err, db.ErrTextDeletionFailed, slog.String("key_management_service", req.Msg.GetId()))
}

auditParams.ObjectID = pc.GetId()
Expand Down
2 changes: 2 additions & 0 deletions service/policy/keymanagement/key_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func Test_GetProviderConfigRequest(t *testing.T) {
name: "Invalid Name (empty) identifier",
req: &keymanagement.GetProviderConfigRequest{
Identifier: &keymanagement.GetProviderConfigRequest_Name{
//nolint:staticcheck // exercises the deprecated Name identifier, which must keep validating until it is removed
Name: "",
},
},
Expand All @@ -142,6 +143,7 @@ func Test_GetProviderConfigRequest(t *testing.T) {
name: "Valid Name Identifier",
req: &keymanagement.GetProviderConfigRequest{
Identifier: &keymanagement.GetProviderConfigRequest_Name{
//nolint:staticcheck // exercises the deprecated Name identifier, which must keep validating until it is removed
Name: validName,
},
},
Expand Down
6 changes: 3 additions & 3 deletions service/policy/namespaces/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (ns NamespacesService) RemoveKeyAccessServerFromNamespace(ctx context.Conte
namespaceKas, err := ns.dbClient.RemoveKeyAccessServerFromNamespace(ctx, grant)
if err != nil {
ns.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, ns.logger, err, db.ErrTextDeletionFailed, slog.String("namespaceKas", grant.String()))
return nil, db.StatusifyError(ctx, ns.logger, err, db.ErrTextDeletionFailed, slog.String("namespace_kas", grant.String()))
}
ns.logger.Audit.PolicyCRUDSuccess(ctx, auditParams)

Expand All @@ -273,7 +273,7 @@ func (ns NamespacesService) AssignPublicKeyToNamespace(ctx context.Context, r *c
namespaceKey, err := ns.dbClient.AssignPublicKeyToNamespace(ctx, key)
if err != nil {
ns.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, ns.logger, err, db.ErrTextCreationFailed, slog.String("namespaceKey", key.String()))
return nil, db.StatusifyError(ctx, ns.logger, err, db.ErrTextCreationFailed, slog.String("namespace_key", key.String()))
}
ns.logger.Audit.PolicyCRUDSuccess(ctx, auditParams)

Expand All @@ -295,7 +295,7 @@ func (ns NamespacesService) RemovePublicKeyFromNamespace(ctx context.Context, r
_, err := ns.dbClient.RemovePublicKeyFromNamespace(ctx, key)
if err != nil {
ns.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, ns.logger, err, db.ErrTextDeletionFailed, slog.String("namespaceKey", key.String()))
return nil, db.StatusifyError(ctx, ns.logger, err, db.ErrTextDeletionFailed, slog.String("namespace_key", key.String()))
}
ns.logger.Audit.PolicyCRUDSuccess(ctx, auditParams)

Expand Down
4 changes: 4 additions & 0 deletions service/policy/namespaces/namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ func Test_GetNamespaceRequest(t *testing.T) {
{
name: "Valid Deprecated Id",
req: &namespaces.GetNamespaceRequest{
//nolint:staticcheck // these cases exist to validate the deprecated Id field, so they must set it
Id: validUUID,
},
expectError: false,
},
{
name: "Invalid Deprecated Id (empty string)",
req: &namespaces.GetNamespaceRequest{
//nolint:staticcheck // these cases exist to validate the deprecated Id field, so they must set it
Id: "",
},
expectError: true,
Expand All @@ -176,6 +178,7 @@ func Test_GetNamespaceRequest(t *testing.T) {
{
name: "Invalid Deprecated Id (invalid UUID)",
req: &namespaces.GetNamespaceRequest{
//nolint:staticcheck // these cases exist to validate the deprecated Id field, so they must set it
Id: "invalid-uuid",
},
expectError: true,
Expand Down Expand Up @@ -223,6 +226,7 @@ func Test_GetNamespaceRequest(t *testing.T) {
{
name: "Invalid can't have both Id and Identifier",
req: &namespaces.GetNamespaceRequest{
//nolint:staticcheck // these cases exist to validate the deprecated Id field, so they must set it
Id: validUUID,
Identifier: &namespaces.GetNamespaceRequest_Fqn{
Fqn: "https://namespace.org",
Expand Down
10 changes: 5 additions & 5 deletions service/policy/obligations/obligations.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (s *Service) CreateObligationValue(ctx context.Context, req *connect.Reques
})
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("obligation value", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("obligation_value", req.Msg.String()))
}

return connect.NewResponse(rsp), nil
Expand Down Expand Up @@ -311,7 +311,7 @@ func (s *Service) UpdateObligationValue(ctx context.Context, req *connect.Reques
})
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextUpdateFailed, slog.String("obligation value", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextUpdateFailed, slog.String("obligation_value", req.Msg.String()))
}
return connect.NewResponse(rsp), nil
}
Expand All @@ -330,7 +330,7 @@ func (s *Service) DeleteObligationValue(ctx context.Context, req *connect.Reques
deleted, err := s.dbClient.DeleteObligationValue(ctx, req.Msg)
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextDeletionFailed, slog.String("obligation value", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextDeletionFailed, slog.String("obligation_value", req.Msg.String()))
}

s.logger.Audit.PolicyCRUDSuccess(ctx, auditParams)
Expand Down Expand Up @@ -399,7 +399,7 @@ func (s *Service) AddObligationTrigger(ctx context.Context, req *connect.Request
})
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("obligation trigger", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("obligation_trigger", req.Msg.String()))
}

return connect.NewResponse(rsp), nil
Expand All @@ -419,7 +419,7 @@ func (s *Service) RemoveObligationTrigger(ctx context.Context, req *connect.Requ
deleted, err := s.dbClient.DeleteObligationTrigger(ctx, req.Msg)
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextDeletionFailed, slog.String("obligation trigger", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextDeletionFailed, slog.String("obligation_trigger", req.Msg.String()))
}

s.logger.Audit.PolicyCRUDSuccess(ctx, auditParams)
Expand Down
12 changes: 6 additions & 6 deletions service/policy/registeredresources/registered_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (s *RegisteredResourcesService) CreateRegisteredResource(ctx context.Contex
})
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("registered resource", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("registered_resource", req.Msg.String()))
}

return connect.NewResponse(rsp), nil
Expand Down Expand Up @@ -187,7 +187,7 @@ func (s *RegisteredResourcesService) UpdateRegisteredResource(ctx context.Contex
})
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextUpdateFailed, slog.String("registered resource", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextUpdateFailed, slog.String("registered_resource", req.Msg.String()))
}

return connect.NewResponse(rsp), nil
Expand All @@ -209,7 +209,7 @@ func (s *RegisteredResourcesService) DeleteRegisteredResource(ctx context.Contex
deleted, err := s.dbClient.DeleteRegisteredResource(ctx, resourceID)
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextDeletionFailed, slog.String("registered resource", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextDeletionFailed, slog.String("registered_resource", req.Msg.String()))
}

s.logger.Audit.PolicyCRUDSuccess(ctx, auditParams)
Expand Down Expand Up @@ -246,7 +246,7 @@ func (s *RegisteredResourcesService) CreateRegisteredResourceValue(ctx context.C
})
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("registered resource value", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("registered_resource_value", req.Msg.String()))
}

return connect.NewResponse(rsp), nil
Expand Down Expand Up @@ -331,7 +331,7 @@ func (s *RegisteredResourcesService) UpdateRegisteredResourceValue(ctx context.C
})
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextUpdateFailed, slog.String("registered resource value", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextUpdateFailed, slog.String("registered_resource_value", req.Msg.String()))
}

return connect.NewResponse(rsp), nil
Expand All @@ -358,7 +358,7 @@ func (s *RegisteredResourcesService) DeleteRegisteredResourceValue(ctx context.C
})
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextDeletionFailed, slog.String("registered resource value", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextDeletionFailed, slog.String("registered_resource_value", req.Msg.String()))
}

s.logger.Audit.PolicyCRUDSuccess(ctx, auditParams)
Expand Down
6 changes: 3 additions & 3 deletions service/policy/resourcemapping/resource_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (s ResourceMappingService) CreateResourceMappingGroup(ctx context.Context,
})
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("resourceMappingGroup", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("resource_mapping_group", req.Msg.String()))
}

auditParams.ObjectID = rmGroup.GetId()
Expand Down Expand Up @@ -285,7 +285,7 @@ func (s ResourceMappingService) CreateResourceMapping(ctx context.Context,
})
if err != nil {
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("resourceMapping", req.Msg.String()))
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextCreationFailed, slog.String("resource_mapping", req.Msg.String()))
}

auditParams.ObjectID = rm.GetId()
Expand Down Expand Up @@ -330,7 +330,7 @@ func (s ResourceMappingService) UpdateResourceMapping(ctx context.Context,
s.logger.Audit.PolicyCRUDFailure(ctx, auditParams)
return nil, db.StatusifyError(ctx, s.logger, err, db.ErrTextUpdateFailed,
slog.String("id", req.Msg.GetId()),
slog.String("resourceMapping", req.Msg.String()),
slog.String("resource_mapping", req.Msg.String()),
)
}

Expand Down
Loading
Loading