From 66eca62bd9d575f7a8db207e185dcf29ba9f08e8 Mon Sep 17 00:00:00 2001 From: Lajos Koszti Date: Mon, 15 Apr 2024 08:23:44 +0200 Subject: [PATCH] fix: remove double entry key use We called the use method of entry key twice: once from the entrykeymanager and also when a read was successfull from the entrymanager. That caused an issue, that if the maxRead was not 1, then group members might got no access to the key, because the remaining read counter was zeroed before --- internal/services/entrykeymanager.go | 4 ---- internal/services/entrykeymanager_test.go | 1 - 2 files changed, 5 deletions(-) diff --git a/internal/services/entrykeymanager.go b/internal/services/entrykeymanager.go index fff2aa2..58f14f0 100644 --- a/internal/services/entrykeymanager.go +++ b/internal/services/entrykeymanager.go @@ -201,10 +201,6 @@ func (e *EntryKeyManager) GetDEKTx(ctx context.Context, tx *sql.Tx, entryUUID st return nil, nil, errors.New("model is nil") } - if err := e.model.Use(ctx, tx, entryKeyModel.UUID); err != nil { - return nil, nil, err - } - return dek, modelEntryKeyToEntryKey(entryKeyModel), nil } diff --git a/internal/services/entrykeymanager_test.go b/internal/services/entrykeymanager_test.go index 9ac7061..48dd553 100644 --- a/internal/services/entrykeymanager_test.go +++ b/internal/services/entrykeymanager_test.go @@ -258,7 +258,6 @@ func TestEntryKeyManager_GetDEK(t *testing.T) { Created: time.Now(), }, }, nil) - model.On("Use", ctx, mock.Anything, "test-uuid").Return(nil) crypto := func(key []byte) Encrypter { return encrypter