Fixed issues with initial commit

This commit is contained in:
pasdam 2018-03-23 11:18:06 +01:00 committed by Jonathan White
parent ad4423d226
commit b4d806ad41
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
17 changed files with 43 additions and 51 deletions

View File

@ -17,6 +17,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QJsonArray>
#include <QInputDialog>
#include <QProgressDialog>
#include <QMessageBox>
#include <QUuid>
#include "BrowserService.h"
#include "BrowserAccessControlDialog.h"
#include "BrowserEntryConfig.h"
@ -26,19 +32,9 @@
#include "core/Group.h"
#include "core/Metadata.h"
#include "core/PasswordGenerator.h"
#include "core/Uuid.h"
#include "gui/MainWindow.h"
#include <QInputDialog>
#include <QJsonArray>
#include <QMessageBox>
#include <QProgressDialog>
// de887cc3-0363-43b8-974b-5911b8816224
static const unsigned char KEEPASSXCBROWSER_UUID_DATA[] =
{0xde, 0x88, 0x7c, 0xc3, 0x03, 0x63, 0x43, 0xb8, 0x97, 0x4b, 0x59, 0x11, 0xb8, 0x81, 0x62, 0x24};
static const Uuid KEEPASSXCBROWSER_UUID =
Uuid(QByteArray::fromRawData(reinterpret_cast<const char*>(KEEPASSXCBROWSER_UUID_DATA),
sizeof(KEEPASSXCBROWSER_UUID_DATA)));
static const QUuid KEEPASSXCBROWSER_UUID = QUuid::fromRfc4122(QByteArray::fromHex("de887cc3036343b8974b5911b8816224"));
static const char KEEPASSXCBROWSER_NAME[] = "KeePassXC-Browser Settings";
static const char ASSOCIATE_KEY_PREFIX[] = "Public Key: ";
static const char KEEPASSXCBROWSER_GROUP_NAME[] = "KeePassXC-Browser Passwords";
@ -118,7 +114,7 @@ QString BrowserService::getDatabaseRootUuid()
return QString();
}
return rootGroup->uuid().toHex();
return QString::fromLatin1(rootGroup->uuid().toRfc4122().toHex());
}
QString BrowserService::getDatabaseRecycleBinUuid()
@ -132,7 +128,7 @@ QString BrowserService::getDatabaseRecycleBinUuid()
if (!recycleBin) {
return QString();
}
return recycleBin->uuid().toHex();
return QString::fromLatin1(recycleBin->uuid().toRfc4122().toHex());
}
Entry* BrowserService::getConfigEntry(bool create)
@ -306,7 +302,7 @@ void BrowserService::addEntry(const QString&,
}
Entry* entry = new Entry();
entry->setUuid(Uuid::random());
entry->setUuid(QUuid::createUuid());
entry->setTitle(QUrl(url).host());
entry->setUrl(url);
entry->setIcon(KEEPASSXCBROWSER_DEFAULT_ICON);
@ -350,7 +346,7 @@ void BrowserService::updateEntry(const QString& id,
return;
}
Entry* entry = db->resolveEntry(Uuid::fromHex(uuid));
Entry* entry = db->resolveEntry(QUuid::fromRfc4122(QByteArray::fromHex(uuid.toLatin1())));
if (!entry) {
return;
}
@ -631,7 +627,7 @@ QJsonObject BrowserService::prepareEntry(const Entry* entry)
res["login"] = entry->resolveMultiplePlaceholders(entry->username());
res["password"] = entry->resolveMultiplePlaceholders(entry->password());
res["name"] = entry->resolveMultiplePlaceholders(entry->title());
res["uuid"] = entry->resolveMultiplePlaceholders(entry->uuid().toHex());
res["uuid"] = entry->resolveMultiplePlaceholders(QString::fromLatin1(entry->uuid().toRfc4122().toHex()));
if (entry->hasTotp()) {
res["totp"] = entry->totp();
@ -693,7 +689,7 @@ Group* BrowserService::findCreateAddEntryGroup()
}
Group* group = new Group();
group->setUuid(Uuid::random());
group->setUuid(QUuid::createUuid());
group->setName(groupName);
group->setIcon(KEEPASSXCBROWSER_DEFAULT_ICON);
group->setParent(rootGroup);

View File

@ -17,8 +17,6 @@
#include "TimeInfo.h"
#include "core/Tools.h"
TimeInfo::TimeInfo()
: m_expires(false)
, m_usageCount(0)

View File

@ -19,7 +19,7 @@
#define KEEPASSX_KDF_H
#include <QVariant>
#include <QUuid.h>
#include <QUuid>
#define KDF_DEFAULT_SEED_SIZE 32
#define KDF_DEFAULT_ROUNDS 1000000ull

View File

@ -19,7 +19,7 @@
#include "core/Database.h"
#include "core/Endian.h"
#define UUID_LENGHT 16
#define UUID_LENGTH 16
/**
* Read KDBX magic header numbers from a device.
@ -135,7 +135,7 @@ KeePass2::ProtectedStreamAlgo KdbxReader::protectedStreamAlgo() const
*/
void KdbxReader::setCipher(const QByteArray& data)
{
if (data.size() != UUID_LENGHT) {
if (data.size() != UUID_LENGTH) {
raiseError(tr("Invalid cipher uuid length: %1 (length=%2)").arg(QString(data)).arg(data.size()));
return;
}

View File

@ -28,7 +28,7 @@
#include <QBuffer>
#include <QFile>
#define UUID_LENGHT 16
#define UUID_LENGTH 16
/**
* @param version KDBX version
@ -1099,7 +1099,7 @@ QUuid KdbxXmlReader::readUuid()
if (uuidBin.isEmpty()) {
return QUuid();
}
if (uuidBin.length() != UUID_LENGHT) {
if (uuidBin.length() != UUID_LENGTH) {
if (m_strictMode) {
raiseError(tr("Invalid uuid value"));
}

View File

@ -21,7 +21,7 @@
#include "crypto/kdf/Argon2Kdf.h"
#include <QSharedPointer>
#define UUID_LENGHT 16
#define UUID_LENGTH 16
const QUuid KeePass2::CIPHER_AES = QUuid::fromRfc4122(QByteArray::fromHex("31c1f2e6bf714350be5805216afc5aff"));
const QUuid KeePass2::CIPHER_TWOFISH = QUuid::fromRfc4122(QByteArray::fromHex("ad68f29f576f4bb9a36ad47af965346c"));
@ -76,7 +76,7 @@ QByteArray KeePass2::hmacKey(QByteArray masterSeed, QByteArray transformedMaster
QSharedPointer<Kdf> KeePass2::kdfFromParameters(const QVariantMap& p)
{
QByteArray uuidBytes = p.value(KDFPARAM_UUID).toByteArray();
if (uuidBytes.size() != UUID_LENGHT) {
if (uuidBytes.size() != UUID_LENGTH) {
return {};
}

View File

@ -105,9 +105,8 @@ void DatabaseSettingsWidget::load(Database* db)
}
m_uiEncryption->algorithmComboBox->clear();
for (auto& cipher : asConst(KeePass2::CIPHERS)) {
m_uiEncryption->algorithmComboBox->addItem(QCoreApplication::translate("KeePass2", cipher.second.toUtf8()),
cipher.first.toByteArray());
for (auto& cipher: asConst(KeePass2::CIPHERS)) {
m_uiEncryption->algorithmComboBox->addItem(QCoreApplication::translate("KeePass2", cipher.second.toUtf8()), cipher.first);
}
int cipherIndex = m_uiEncryption->algorithmComboBox->findData(m_db->cipher().toRfc4122());
if (cipherIndex > -1) {
@ -118,12 +117,12 @@ void DatabaseSettingsWidget::load(Database* db)
m_uiEncryption->kdfComboBox->blockSignals(true);
m_uiEncryption->kdfComboBox->clear();
for (auto& kdf: asConst(KeePass2::KDFS)) {
m_uiEncryption->kdfComboBox->addItem(kdf.second, kdf.first.toRfc4122());
m_uiEncryption->kdfComboBox->addItem(QCoreApplication::translate("KeePass2", kdf.second.toUtf8()), kdf.first);
}
m_uiEncryption->kdfComboBox->blockSignals(false);
auto kdfUuid = m_db->kdf()->uuid();
int kdfIndex = m_uiEncryption->kdfComboBox->findData(kdfUuid.toRfc4122());
int kdfIndex = m_uiEncryption->kdfComboBox->findData(kdfUuid);
if (kdfIndex > -1) {
m_uiEncryption->kdfComboBox->setCurrentIndex(kdfIndex);
kdfChanged(kdfIndex);

View File

@ -24,7 +24,7 @@
#include <QUrl>
#include <QWidget>
#include <QNetworkAccessManager>
#include <QUuid.h>
#include <QUuid>
#include "config-keepassx.h"
#include "core/Global.h"

View File

@ -17,7 +17,7 @@
#include "EditWidgetProperties.h"
#include <QUuid.h>
#include <QUuid>
#include "MessageBox.h"
#include "ui_EditWidgetProperties.h"

View File

@ -17,7 +17,7 @@
#include "IconModels.h"
#include <QUuid.h>
#include <QUuid>
#include "core/DatabaseIcons.h"

View File

@ -234,11 +234,11 @@ bool SSHAgent::removeIdentity(OpenSSHKey& key)
return true;
}
void SSHAgent::removeIdentityAtLock(const OpenSSHKey& key, const Uuid& uuid)
void SSHAgent::removeIdentityAtLock(const OpenSSHKey& key, const QUuid& uuid)
{
OpenSSHKey copy = key;
copy.clearPrivate();
m_keys[uuid.toHex()].insert(copy);
m_keys[uuid].insert(copy);
}
void SSHAgent::databaseModeChanged(DatabaseWidget::Mode mode)
@ -249,17 +249,17 @@ void SSHAgent::databaseModeChanged(DatabaseWidget::Mode mode)
return;
}
Uuid uuid = widget->database()->uuid();
const QUuid& uuid = widget->database()->uuid();
if (mode == DatabaseWidget::LockedMode && m_keys.contains(uuid.toHex())) {
if (mode == DatabaseWidget::LockedMode && m_keys.contains(uuid)) {
QSet<OpenSSHKey> keys = m_keys.take(uuid.toHex());
QSet<OpenSSHKey> keys = m_keys.take(uuid);
for (OpenSSHKey key : keys) {
if (!removeIdentity(key)) {
emit error(m_error);
}
}
} else if (mode == DatabaseWidget::ViewMode && !m_keys.contains(uuid.toHex())) {
} else if (mode == DatabaseWidget::ViewMode && !m_keys.contains(uuid)) {
for (Entry* e : widget->database()->rootGroup()->entriesRecursive()) {
if (widget->database()->metadata()->recycleBinEnabled()

View File

@ -71,7 +71,7 @@ private:
const quint32 AGENT_COPYDATA_ID = 0x804e50ba;
#endif
QMap<QString, QSet<OpenSSHKey>> m_keys;
QMap<QUuid, QSet<OpenSSHKey>> m_keys;
QString m_error;
};

View File

@ -282,8 +282,8 @@ void TestEntry::testResolveRecursivePlaceholders()
auto* entry7 = new Entry();
entry7->setGroup(root);
entry7->setUuid(Uuid::random());
entry7->setTitle(QString("{REF:T@I:%1} and something else").arg(entry3->uuid().toHex()));
entry7->setUuid(QUuid::createUuid());
entry7->setTitle(QString("{REF:T@I:%1} and something else").arg(QString(entry3->uuid().toRfc4122().toHex())));
entry7->setUsername(QString("{TITLE}"));
entry7->setPassword(QString("PASSWORD"));

View File

@ -220,11 +220,11 @@ void TestEntryModel::testCustomIconModel()
QHash<QUuid, QPixmap> icons;
QList<QUuid> iconsOrder;
QUuid iconUuid(QByteArray(16, '2'));
QUuid iconUuid = QUuid::fromRfc4122(QByteArray(16, '2'));
icons.insert(iconUuid, QPixmap());
iconsOrder << iconUuid;
QUuid iconUuid2(QByteArray(16, '1'));
QUuid iconUuid2 = QUuid::fromRfc4122(QByteArray(16, '1'));
icons.insert(iconUuid2, QPixmap());
iconsOrder << iconUuid2;

View File

@ -19,7 +19,6 @@
#define KEEPASSXC_TESTGLOBAL_H
#include "core/Group.h"
#include "core/Uuid.h"
#include <QDateTime>
#include <QTest>

View File

@ -577,12 +577,12 @@ void TestKeePass2Format::testDuplicateAttachments()
auto entry1 = new Entry();
entry1->setGroup(db->rootGroup());
entry1->setUuid(QUuid::fromRfc4122(QByteArray::fromHex("aaaaaaaaaaaaaaaa")));
entry1->setUuid(QUuid::fromRfc4122("aaaaaaaaaaaaaaaa"));
entry1->attachments()->set("a", attachment1);
auto entry2 = new Entry();
entry2->setGroup(db->rootGroup());
entry2->setUuid(QUuid::fromRfc4122(QByteArray::fromHex("bbbbbbbbbbbbbbbb")));
entry2->setUuid(QUuid::fromRfc4122("bbbbbbbbbbbbbbbb"));
entry2->attachments()->set("b1", attachment1);
entry2->beginUpdate();
entry2->attachments()->set("b2", attachment1);
@ -596,7 +596,7 @@ void TestKeePass2Format::testDuplicateAttachments()
auto entry3 = new Entry();
entry3->setGroup(db->rootGroup());
entry3->setUuid(QUuid::fromRfc4122(QByteArray::fromHex("cccccccccccccccc")));
entry3->setUuid(QUuid::fromRfc4122("cccccccccccccccc"));
entry3->attachments()->set("c1", attachment2);
entry3->attachments()->set("c2", attachment2);
entry3->attachments()->set("c3", attachment3);

View File

@ -73,7 +73,7 @@ void TestGuiPixmaps::testEntryIcons()
QCOMPARE(pixmapCached1.cacheKey(), pixmap.cacheKey());
QCOMPARE(pixmapCached2.cacheKey(), pixmap.cacheKey());
Uuid iconUuid = Uuid::random();
QUuid iconUuid = QUuid::createUuid();
icon = QImage(2, 1, QImage::Format_RGB32);
icon.setPixel(0, 0, qRgb(0, 0, 0));
icon.setPixel(1, 0, qRgb(0, 0, 50));
@ -116,7 +116,7 @@ void TestGuiPixmaps::testGroupIcons()
QCOMPARE(pixmapCached1.cacheKey(), pixmap.cacheKey());
QCOMPARE(pixmapCached2.cacheKey(), pixmap.cacheKey());
Uuid iconUuid = Uuid::random();
QUuid iconUuid = QUuid::createUuid();
icon = QImage(2, 1, QImage::Format_RGB32);
icon.setPixel(0, 0, qRgb(0, 0, 0));
icon.setPixel(1, 0, qRgb(0, 0, 50));