Skip to content

Commit

Permalink
Preserve Secret Service exposed group setting on merge
Browse files Browse the repository at this point in the history
* Fixes #9371 - adds secret service custom data key to the list of protected custom data (will not be overwritten on merge)
  • Loading branch information
droidmonkey committed Mar 31, 2024
1 parent 8063ade commit 738ba62
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/core/CustomData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const QString CustomData::Created = QStringLiteral("_CREATED");
const QString CustomData::BrowserKeyPrefix = QStringLiteral("KPXC_BROWSER_");
const QString CustomData::BrowserLegacyKeyPrefix = QStringLiteral("Public Key: ");
const QString CustomData::ExcludeFromReportsLegacy = QStringLiteral("KnownBad");
const QString CustomData::FdoSecretsExposedGroup = QStringLiteral("FDO_SECRETS_EXPOSED_GROUP");

// Fallback item for return by reference
static const CustomData::CustomDataItem NULL_ITEM{};
Expand Down Expand Up @@ -188,7 +189,7 @@ void CustomData::updateLastModified(QDateTime lastModified)

bool CustomData::isProtected(const QString& key) const
{
return key.startsWith(CustomData::BrowserKeyPrefix) || key.startsWith(CustomData::Created);
return key.startsWith(BrowserKeyPrefix) || key == Created || key == FdoSecretsExposedGroup;
}

bool CustomData::operator==(const CustomData& other) const
Expand Down
1 change: 1 addition & 0 deletions src/core/CustomData.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class CustomData : public ModifiableObject
static const QString Created;
static const QString BrowserKeyPrefix;
static const QString BrowserLegacyKeyPrefix;
static const QString FdoSecretsExposedGroup;

// Pre-KDBX 4.1
static const QString ExcludeFromReportsLegacy;
Expand Down
18 changes: 4 additions & 14 deletions src/fdosecrets/FdoSecretsSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@
#include "core/Database.h"
#include "core/Metadata.h"

namespace Keys
{
namespace Db
{
constexpr auto FdoSecretsExposedGroup = "FDO_SECRETS_EXPOSED_GROUP";
} // namespace Db

} // namespace Keys

namespace FdoSecrets
{

Expand Down Expand Up @@ -98,20 +89,19 @@ namespace FdoSecrets
return exposedGroup(db.data());
}

void FdoSecretsSettings::setExposedGroup(const QSharedPointer<Database>& db,
const QUuid& group) // clazy:exclude=function-args-by-value
void FdoSecretsSettings::setExposedGroup(const QSharedPointer<Database>& db, const QUuid& group)
{
setExposedGroup(db.data(), group);
}

QUuid FdoSecretsSettings::exposedGroup(Database* db) const
{
return {db->metadata()->customData()->value(Keys::Db::FdoSecretsExposedGroup)};
return {db->metadata()->customData()->value(CustomData::FdoSecretsExposedGroup)};
}

void FdoSecretsSettings::setExposedGroup(Database* db, const QUuid& group) // clazy:exclude=function-args-by-value
void FdoSecretsSettings::setExposedGroup(Database* db, const QUuid& group)
{
db->metadata()->customData()->set(Keys::Db::FdoSecretsExposedGroup, group.toString());
db->metadata()->customData()->set(CustomData::FdoSecretsExposedGroup, group.toString());
}

} // namespace FdoSecrets

0 comments on commit 738ba62

Please sign in to comment.