mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-03 04:27:39 +03:00
Prevent KeeShare from merging database custom data
This issue previously caused parent databases to be marked as modified on unlock. This was because of the new protections against byte-by-byte side channel attacks adds a randomized string to the database custom data. We should never be merging database custom data with keeshare or imports since we are merging groups only. Also prevent overwrite of auto-generated custom data fields, Last Modified and Random Slug.
This commit is contained in:
parent
4f12f57a0b
commit
3829bcdd8f
9 changed files with 68 additions and 5 deletions
|
@ -87,18 +87,54 @@ void TestMerge::testMergeNoChanges()
|
|||
m_clock->advanceSecond(1);
|
||||
|
||||
Merger merger1(dbSource.data(), dbDestination.data());
|
||||
merger1.merge();
|
||||
auto changes = merger1.merge();
|
||||
|
||||
QVERIFY(changes.isEmpty());
|
||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||
QCOMPARE(dbSource->rootGroup()->entriesRecursive().size(), 2);
|
||||
|
||||
m_clock->advanceSecond(1);
|
||||
|
||||
Merger merger2(dbSource.data(), dbDestination.data());
|
||||
merger2.merge();
|
||||
changes = merger2.merge();
|
||||
|
||||
QVERIFY(changes.isEmpty());
|
||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||
QCOMPARE(dbSource->rootGroup()->entriesRecursive().size(), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merging without database custom data (used by imports and KeeShare)
|
||||
*/
|
||||
void TestMerge::testMergeCustomData()
|
||||
{
|
||||
QScopedPointer<Database> dbDestination(createTestDatabase());
|
||||
QScopedPointer<Database> dbSource(
|
||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||
|
||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||
QCOMPARE(dbSource->rootGroup()->entriesRecursive().size(), 2);
|
||||
|
||||
dbDestination->metadata()->customData()->set("TEST_CUSTOM_DATA", "OLD TESTING");
|
||||
|
||||
m_clock->advanceSecond(1);
|
||||
|
||||
dbSource->metadata()->customData()->set("TEST_CUSTOM_DATA", "TESTING");
|
||||
|
||||
// First check that the custom data is not merged when skipped
|
||||
Merger merger1(dbSource.data(), dbDestination.data());
|
||||
merger1.setSkipDatabaseCustomData(true);
|
||||
auto changes = merger1.merge();
|
||||
|
||||
QVERIFY(changes.isEmpty());
|
||||
QCOMPARE(dbDestination->metadata()->customData()->value("TEST_CUSTOM_DATA"), QString("OLD TESTING"));
|
||||
|
||||
// Second check that the custom data is merged otherwise
|
||||
Merger merger2(dbSource.data(), dbDestination.data());
|
||||
changes = merger2.merge();
|
||||
|
||||
QCOMPARE(changes.size(), 1);
|
||||
QCOMPARE(dbDestination->metadata()->customData()->value("TEST_CUSTOM_DATA"), QString("TESTING"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,6 +30,7 @@ private slots:
|
|||
void cleanup();
|
||||
void testMergeIntoNew();
|
||||
void testMergeNoChanges();
|
||||
void testMergeCustomData();
|
||||
void testResolveConflictNewer();
|
||||
void testResolveConflictExisting();
|
||||
void testResolveGroupConflictOlder();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue