From 570fa7c3598118ded6df7ced0a5326f54e7a43e2 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sat, 20 Aug 2022 22:47:19 +0200 Subject: [bugfix] Fix potential dereference of accounts on own instance (#757) * add GetAccountByUsernameDomain * simplify search * add escape to not deref accounts on own domain * check if local + we have account by ap uri --- internal/db/bundb/account_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'internal/db/bundb/account_test.go') diff --git a/internal/db/bundb/account_test.go b/internal/db/bundb/account_test.go index 59b51386d..3c19e84d9 100644 --- a/internal/db/bundb/account_test.go +++ b/internal/db/bundb/account_test.go @@ -58,6 +58,18 @@ func (suite *AccountTestSuite) TestGetAccountByIDWithExtras() { suite.NotEmpty(account.HeaderMediaAttachment.URL) } +func (suite *AccountTestSuite) TestGetAccountByUsernameDomain() { + testAccount1 := suite.testAccounts["local_account_1"] + account1, err := suite.db.GetAccountByUsernameDomain(context.Background(), testAccount1.Username, testAccount1.Domain) + suite.NoError(err) + suite.NotNil(account1) + + testAccount2 := suite.testAccounts["remote_account_1"] + account2, err := suite.db.GetAccountByUsernameDomain(context.Background(), testAccount2.Username, testAccount2.Domain) + suite.NoError(err) + suite.NotNil(account2) +} + func (suite *AccountTestSuite) TestUpdateAccount() { testAccount := suite.testAccounts["local_account_1"] -- cgit v1.2.3