From 40f5c75b698871243a3acce30d3ba0568b569b70 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sun, 25 Aug 2024 08:17:16 -0400 Subject: [PATCH] Add Proton Pass importer * Closes #10465 --- COPYING | 1 + .../application/scalable/actions/proton.svg | 1 + share/icons/icons.qrc | 1 + share/translations/keepassxc_en.ts | 24 +- src/CMakeLists.txt | 1 + src/format/ProtonPassReader.cpp | 221 ++++++++++++++++++ src/format/ProtonPassReader.h | 43 ++++ src/gui/DatabaseTabWidget.cpp | 3 + src/gui/wizard/ImportWizard.h | 1 + src/gui/wizard/ImportWizardPageReview.cpp | 41 +++- src/gui/wizard/ImportWizardPageReview.h | 4 +- src/gui/wizard/ImportWizardPageSelect.cpp | 7 +- tests/TestImports.cpp | 56 +++++ tests/TestImports.h | 1 + tests/data/protonpass_export.json | 173 ++++++++++++++ 15 files changed, 562 insertions(+), 16 deletions(-) create mode 100644 share/icons/application/scalable/actions/proton.svg create mode 100644 src/format/ProtonPassReader.cpp create mode 100644 src/format/ProtonPassReader.h create mode 100644 tests/data/protonpass_export.json diff --git a/COPYING b/COPYING index 23dd1d168e..ea30ffac0d 100644 --- a/COPYING +++ b/COPYING @@ -137,6 +137,7 @@ Files: share/icons/badges/2_Expired.svg share/icons/database/C46_Help.svg share/icons/database/C53_Apply.svg share/icons/database/C61_Services.svg + share/icons/application/scalable/actions/proton.svg Copyright: 2022 KeePassXC Team License: MIT diff --git a/share/icons/application/scalable/actions/proton.svg b/share/icons/application/scalable/actions/proton.svg new file mode 100644 index 0000000000..89515ddec9 --- /dev/null +++ b/share/icons/application/scalable/actions/proton.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/share/icons/icons.qrc b/share/icons/icons.qrc index 4e86186d63..b0d301e7d6 100644 --- a/share/icons/icons.qrc +++ b/share/icons/icons.qrc @@ -71,6 +71,7 @@ application/scalable/actions/password-generator.svg application/scalable/actions/password-show-off.svg application/scalable/actions/password-show-on.svg + application/scalable/actions/proton.svg application/scalable/actions/qrcode.svg application/scalable/actions/refresh.svg application/scalable/actions/remote-sync.svg diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts index 7180159138..bc32a4b31f 100644 --- a/share/translations/keepassxc_en.ts +++ b/share/translations/keepassxc_en.ts @@ -4635,6 +4635,14 @@ You can enable the DuckDuckGo website icon service in the security section of th KeePass1 Database + + Proton Pass (.json) + + + + Proton Pass JSON Export + + Temporary Database @@ -4651,10 +4659,6 @@ You can enable the DuckDuckGo website icon service in the security section of th Input: - - Remote Database (.kdbx) - - e.g.: get DatabaseOnRemote.kdbx {TEMP_DATABASE} @@ -4665,6 +4669,10 @@ The command has to exit. In case of `sftp` as last commend `exit` has to be sent + + Remote Database (.kdbx) + + KMessageWidget @@ -9002,6 +9010,14 @@ This option is deprecated, use --set-key-file instead. Cannot generate valid passphrases because the wordlist is too short + + Encrypted files are not supported. + + + + Proton Pass Import + + Delete plugin data? diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 67aada93fe..551db9cbfc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -90,6 +90,7 @@ set(core_SOURCES format/OpVaultReaderAttachments.cpp format/OpVaultReaderBandEntry.cpp format/OpVaultReaderSections.cpp + format/ProtonPassReader.cpp keys/CompositeKey.cpp keys/FileKey.cpp keys/PasswordKey.cpp diff --git a/src/format/ProtonPassReader.cpp b/src/format/ProtonPassReader.cpp new file mode 100644 index 0000000000..105adde79f --- /dev/null +++ b/src/format/ProtonPassReader.cpp @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2024 KeePassXC Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "ProtonPassReader.h" + +#include "core/Database.h" +#include "core/Entry.h" +#include "core/Group.h" +#include "core/Metadata.h" +#include "core/Tools.h" +#include "core/Totp.h" +#include "crypto/CryptoHash.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ + Entry* readItem(const QJsonObject& item) + { + const auto itemMap = item.toVariantMap(); + const auto dataMap = itemMap.value("data").toMap(); + const auto metadataMap = dataMap.value("metadata").toMap(); + + // Create entry and assign basic values + QScopedPointer entry(new Entry()); + entry->setUuid(QUuid::createUuid()); + entry->setTitle(metadataMap.value("name").toString()); + entry->setNotes(metadataMap.value("note").toString()); + + if (itemMap.value("pinned").toBool()) { + entry->addTag(QObject::tr("Favorite", "Tag for favorite entries")); + } + + // Handle specific item types + auto type = dataMap.value("type").toString(); + + // Login + if (type.compare("login", Qt::CaseInsensitive) == 0) { + const auto loginMap = dataMap.value("content").toMap(); + entry->setUsername(loginMap.value("itemUsername").toString()); + entry->setPassword(loginMap.value("password").toString()); + if (loginMap.contains("totpUri")) { + auto totp = loginMap.value("totpUri").toString(); + if (!totp.startsWith("otpauth://")) { + QUrl url(QString("otpauth://totp/%1:%2?secret=%3") + .arg(QString(QUrl::toPercentEncoding(entry->title())), + QString(QUrl::toPercentEncoding(entry->username())), + QString(QUrl::toPercentEncoding(totp)))); + totp = url.toString(QUrl::FullyEncoded); + } + entry->setTotp(Totp::parseSettings(totp)); + } + + if (loginMap.contains("itemEmail")) { + entry->attributes()->set("login_email", loginMap.value("itemEmail").toString()); + } + + // Set the entry url(s) + int i = 1; + for (const auto& urlObj : loginMap.value("urls").toList()) { + const auto url = urlObj.toString(); + if (entry->url().isEmpty()) { + // First url encountered is set as the primary url + entry->setUrl(url); + } else { + // Subsequent urls + entry->attributes()->set( + QString("%1_%2").arg(EntryAttributes::AdditionalUrlAttribute, QString::number(i)), url); + ++i; + } + } + } + // Credit Card + else if (type.compare("creditCard", Qt::CaseInsensitive) == 0) { + const auto cardMap = dataMap.value("content").toMap(); + entry->setUsername(cardMap.value("number").toString()); + entry->setPassword(cardMap.value("verificationNumber").toString()); + const QStringList attrs({"cardholderName", "pin", "expirationDate"}); + const QStringList sensitive({"pin"}); + for (const auto& attr : attrs) { + auto value = cardMap.value(attr).toString(); + if (!value.isEmpty()) { + entry->attributes()->set("card_" + attr, value, sensitive.contains(attr)); + } + } + } + + // Parse extra fields + for (const auto& field : dataMap.value("extraFields").toList()) { + // Derive a prefix for attribute names using the title or uuid if missing + const auto fieldMap = field.toMap(); + auto name = fieldMap.value("fieldName").toString(); + if (entry->attributes()->hasKey(name)) { + name = QString("%1_%2").arg(name, QUuid::createUuid().toString().mid(1, 5)); + } + + QString value; + const auto fieldType = fieldMap.value("type").toString(); + if (fieldType.compare("totp", Qt::CaseInsensitive) == 0) { + value = fieldMap.value("data").toJsonObject().value("totpUri").toString(); + } else { + value = fieldMap.value("data").toJsonObject().value("content").toString(); + } + + entry->attributes()->set(name, value, fieldType.compare("hidden", Qt::CaseInsensitive) == 0); + } + + // Checked expired/deleted state + if (itemMap.value("state").toInt() == 2) { + entry->setExpires(true); + entry->setExpiryTime(QDateTime::currentDateTimeUtc()); + } + + // Collapse any accumulated history + entry->removeHistoryItems(entry->historyItems()); + + // Adjust the created and modified times + auto timeInfo = entry->timeInfo(); + const auto createdTime = QDateTime::fromSecsSinceEpoch(itemMap.value("createTime").toULongLong(), Qt::UTC); + const auto modifiedTime = QDateTime::fromSecsSinceEpoch(itemMap.value("modifyTime").toULongLong(), Qt::UTC); + timeInfo.setCreationTime(createdTime); + timeInfo.setLastModificationTime(modifiedTime); + timeInfo.setLastAccessTime(modifiedTime); + entry->setTimeInfo(timeInfo); + + return entry.take(); + } + + void writeVaultToDatabase(const QJsonObject& vault, QSharedPointer db) + { + // Create groups from vaults and store a temporary map of id -> uuid + const auto vaults = vault.value("vaults").toObject().toVariantMap(); + for (const auto& vaultId : vaults.keys()) { + auto vaultObj = vaults.value(vaultId).toJsonObject(); + auto group = new Group(); + group->setUuid(QUuid::createUuid()); + group->setName(vaultObj.value("name").toString()); + group->setNotes(vaultObj.value("description").toString()); + group->setParent(db->rootGroup()); + + const auto items = vaultObj.value("items").toArray(); + for (const auto& item : items) { + auto entry = readItem(item.toObject()); + if (entry) { + entry->setGroup(group, false); + } + } + } + } +} // namespace + +bool ProtonPassReader::hasError() +{ + return !m_error.isEmpty(); +} + +QString ProtonPassReader::errorString() +{ + return m_error; +} + +QSharedPointer ProtonPassReader::convert(const QString& path) +{ + m_error.clear(); + + QFileInfo fileinfo(path); + if (!fileinfo.exists()) { + m_error = QObject::tr("File does not exist.").arg(path); + return {}; + } + + // Bitwarden uses a json file format + QFile file(fileinfo.absoluteFilePath()); + if (!file.open(QFile::ReadOnly)) { + m_error = QObject::tr("Cannot open file: %1").arg(file.errorString()); + return {}; + } + + QJsonParseError error; + auto json = QJsonDocument::fromJson(file.readAll(), &error).object(); + if (error.error != QJsonParseError::NoError) { + m_error = + QObject::tr("Cannot parse file: %1 at position %2").arg(error.errorString(), QString::number(error.offset)); + return {}; + } + + file.close(); + + if (json.value("encrypted").toBool()) { + m_error = QObject::tr("Encrypted files are not supported."); + return {}; + } + + auto db = QSharedPointer::create(); + db->rootGroup()->setName(QObject::tr("Proton Pass Import")); + + writeVaultToDatabase(json, db); + + return db; +} diff --git a/src/format/ProtonPassReader.h b/src/format/ProtonPassReader.h new file mode 100644 index 0000000000..74764b8900 --- /dev/null +++ b/src/format/ProtonPassReader.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 KeePassXC Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PROTONPASS_READER_H +#define PROTONPASS_READER_H + +#include + +class Database; + +/*! + * Imports a Proton Pass vault in JSON format: https://proton.me/support/pass-export + */ +class ProtonPassReader +{ +public: + explicit ProtonPassReader() = default; + ~ProtonPassReader() = default; + + QSharedPointer convert(const QString& path); + + bool hasError(); + QString errorString(); + +private: + QString m_error; +}; + +#endif // PROTONPASS_READER_H diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index d159352eb7..adb7c6bf9d 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -303,6 +303,9 @@ void DatabaseTabWidget::importFile() Merger merger(db.data(), newDb.data()); merger.setSkipDatabaseCustomData(true); merger.merge(); + // Transfer the root group data + newDb->rootGroup()->setName(db->rootGroup()->name()); + newDb->rootGroup()->setNotes(db->rootGroup()->notes()); // Show the new database auto dbWidget = new DatabaseWidget(newDb, this); addDatabaseTab(dbWidget); diff --git a/src/gui/wizard/ImportWizard.h b/src/gui/wizard/ImportWizard.h index 95bf8b9986..db27e3d5a3 100644 --- a/src/gui/wizard/ImportWizard.h +++ b/src/gui/wizard/ImportWizard.h @@ -48,6 +48,7 @@ class ImportWizard : public QWizard IMPORT_OPVAULT, IMPORT_OPUX, IMPORT_BITWARDEN, + IMPORT_PROTONPASS, IMPORT_KEEPASS1, IMPORT_REMOTE, }; diff --git a/src/gui/wizard/ImportWizardPageReview.cpp b/src/gui/wizard/ImportWizardPageReview.cpp index 55492a67fc..c7ed90fe7f 100644 --- a/src/gui/wizard/ImportWizardPageReview.cpp +++ b/src/gui/wizard/ImportWizardPageReview.cpp @@ -24,6 +24,7 @@ #include "format/KeePass1Reader.h" #include "format/OPUXReader.h" #include "format/OpVaultReader.h" +#include "format/ProtonPassReader.h" #include "gui/csvImport/CsvImportWidget.h" #include "gui/wizard/ImportWizard.h" @@ -75,34 +76,35 @@ void ImportWizardPageReview::initializePage() break; case ImportWizard::IMPORT_OPVAULT: m_db = importOPVault(filename, field("ImportPassword").toString()); - setupDatabasePreview(); break; case ImportWizard::IMPORT_OPUX: m_db = importOPUX(filename); - setupDatabasePreview(); break; case ImportWizard::IMPORT_KEEPASS1: m_db = importKeePass1(filename, field("ImportPassword").toString(), field("ImportKeyFile").toString()); - setupDatabasePreview(); break; case ImportWizard::IMPORT_BITWARDEN: m_db = importBitwarden(filename, field("ImportPassword").toString()); - setupDatabasePreview(); + break; + case ImportWizard::IMPORT_PROTONPASS: + m_db = importProtonPass(filename); break; case ImportWizard::IMPORT_REMOTE: m_db = importRemote(field("DownloadCommand").toString(), field("DownloadInput").toString(), field("ImportPassword").toString(), field("ImportKeyFile").toString()); - setupDatabasePreview(); + break; default: break; } + + setupDatabasePreview(); } bool ImportWizardPageReview::validatePage() { - if (m_csvWidget && field("ImportType").toInt() == ImportWizard::IMPORT_CSV) { + if (isCsvImport()) { m_db = m_csvWidget->buildDatabase(); } return !m_db.isNull(); @@ -124,14 +126,18 @@ void ImportWizardPageReview::setupCsvImport(const QString& filename) }); m_csvWidget->load(filename); - - // Qt does not automatically resize a QScrollWidget in a QWizard... - m_ui->scrollAreaContents->layout()->addWidget(m_csvWidget); - m_ui->scrollArea->setMinimumSize(m_csvWidget->width() + 50, m_csvWidget->height() + 100); } void ImportWizardPageReview::setupDatabasePreview() { + // CSV preview is handled by the import widget + if (isCsvImport()) { + // Qt does not automatically resize a QScrollWidget in a QWizard... + m_ui->scrollAreaContents->layout()->addWidget(m_csvWidget); + m_ui->scrollArea->setMinimumSize(m_csvWidget->width() + 50, m_csvWidget->height() + 100); + return; + } + if (!m_db) { m_ui->scrollArea->setVisible(false); return; @@ -216,6 +222,21 @@ ImportWizardPageReview::importKeePass1(const QString& filename, const QString& p return db; } +QSharedPointer ImportWizardPageReview::importProtonPass(const QString& filename) +{ + ProtonPassReader reader; + auto db = reader.convert(filename); + if (reader.hasError()) { + m_ui->messageWidget->showMessage(reader.errorString(), KMessageWidget::Error, -1); + } + return db; +} + +bool ImportWizardPageReview::isCsvImport() const +{ + return m_csvWidget && field("ImportType").toInt() == ImportWizard::IMPORT_CSV; +} + QSharedPointer ImportWizardPageReview::importRemote(const QString& downloadCommand, const QString& downloadInput, const QString& password, diff --git a/src/gui/wizard/ImportWizardPageReview.h b/src/gui/wizard/ImportWizardPageReview.h index c1df3efff4..17f85a1a5b 100644 --- a/src/gui/wizard/ImportWizardPageReview.h +++ b/src/gui/wizard/ImportWizardPageReview.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2023 KeePassXC Team * * This program is free software: you can redistribute it and/or modify @@ -49,11 +49,13 @@ class ImportWizardPageReview : public QWizardPage QSharedPointer database(); private: + bool isCsvImport() const; void setupCsvImport(const QString& filename); QSharedPointer importOPUX(const QString& filename); QSharedPointer importBitwarden(const QString& filename, const QString& password); QSharedPointer importOPVault(const QString& filename, const QString& password); QSharedPointer importKeePass1(const QString& filename, const QString& password, const QString& keyfile); + QSharedPointer importProtonPass(const QString& filename); QSharedPointer importRemote(const QString& downloadCommand, const QString& downloadInput, const QString& password, diff --git a/src/gui/wizard/ImportWizardPageSelect.cpp b/src/gui/wizard/ImportWizardPageSelect.cpp index e7bdacc9f1..9fe4df7cde 100644 --- a/src/gui/wizard/ImportWizardPageSelect.cpp +++ b/src/gui/wizard/ImportWizardPageSelect.cpp @@ -37,6 +37,7 @@ ImportWizardPageSelect::ImportWizardPageSelect(QWidget* parent) new QListWidgetItem(icons()->icon("onepassword"), tr("1Password Export (.1pux)"), m_ui->importTypeList); new QListWidgetItem(icons()->icon("onepassword"), tr("1Password Vault (.opvault)"), m_ui->importTypeList); new QListWidgetItem(icons()->icon("bitwarden"), tr("Bitwarden (.json)"), m_ui->importTypeList); + new QListWidgetItem(icons()->icon("proton"), tr("Proton Pass (.json)"), m_ui->importTypeList); new QListWidgetItem(icons()->icon("object-locked"), tr("KeePass 1 Database (.kdb)"), m_ui->importTypeList); new QListWidgetItem(icons()->icon("web"), tr("Remote Database (.kdbx)"), m_ui->importTypeList); @@ -44,7 +45,8 @@ ImportWizardPageSelect::ImportWizardPageSelect(QWidget* parent) m_ui->importTypeList->item(1)->setData(Qt::UserRole, ImportWizard::IMPORT_OPUX); m_ui->importTypeList->item(2)->setData(Qt::UserRole, ImportWizard::IMPORT_OPVAULT); m_ui->importTypeList->item(3)->setData(Qt::UserRole, ImportWizard::IMPORT_BITWARDEN); - m_ui->importTypeList->item(4)->setData(Qt::UserRole, ImportWizard::IMPORT_KEEPASS1); + m_ui->importTypeList->item(4)->setData(Qt::UserRole, ImportWizard::IMPORT_PROTONPASS); + m_ui->importTypeList->item(5)->setData(Qt::UserRole, ImportWizard::IMPORT_KEEPASS1); m_ui->importTypeList->item(5)->setData(Qt::UserRole, ImportWizard::IMPORT_REMOTE); connect(m_ui->importTypeList, &QListWidget::currentItemChanged, this, &ImportWizardPageSelect::itemSelected); @@ -132,6 +134,7 @@ void ImportWizardPageSelect::itemSelected(QListWidgetItem* current, QListWidgetI // Unencrypted types case ImportWizard::IMPORT_CSV: case ImportWizard::IMPORT_OPUX: + case ImportWizard::IMPORT_PROTONPASS: setCredentialState(false); setDownloadCommand(false); break; @@ -299,6 +302,8 @@ QString ImportWizardPageSelect::importFileFilter() return QString("%1 (*.1pux)").arg(tr("1Password Export")); case ImportWizard::IMPORT_BITWARDEN: return QString("%1 (*.json)").arg(tr("Bitwarden JSON Export")); + case ImportWizard::IMPORT_PROTONPASS: + return QString("%1 (*.json)").arg(tr("Proton Pass JSON Export")); case ImportWizard::IMPORT_OPVAULT: return QString("%1 (*.opvault)").arg(tr("1Password Vault")); case ImportWizard::IMPORT_KEEPASS1: diff --git a/tests/TestImports.cpp b/tests/TestImports.cpp index eb06599dfd..fecba67fae 100644 --- a/tests/TestImports.cpp +++ b/tests/TestImports.cpp @@ -25,6 +25,7 @@ #include "format/BitwardenReader.h" #include "format/OPUXReader.h" #include "format/OpVaultReader.h" +#include "format/ProtonPassReader.h" #include #include @@ -282,3 +283,58 @@ void TestImports::testBitwardenEncrypted() } QVERIFY(db); } + +void TestImports::testProtonPass() +{ + auto protonPassPath = + QStringLiteral("%1/%2").arg(KEEPASSX_TEST_DATA_DIR, QStringLiteral("/protonpass_export.json")); + + ProtonPassReader reader; + auto db = reader.convert(protonPassPath); + QVERIFY2(!reader.hasError(), qPrintable(reader.errorString())); + QVERIFY(db); + + // Confirm Login fields + auto entry = db->rootGroup()->findEntryByPath("/Personal/Test Login"); + QVERIFY(entry); + QCOMPARE(entry->title(), QStringLiteral("Test Login")); + QCOMPARE(entry->username(), QStringLiteral("Username")); + QCOMPARE(entry->password(), QStringLiteral("Password")); + QCOMPARE(entry->url(), QStringLiteral("https://example.com/")); + QCOMPARE(entry->notes(), QStringLiteral("My login secure note.")); + // Check extra URL's + QCOMPARE(entry->attribute("KP2A_URL_1"), QStringLiteral("https://example2.com/")); + // Check TOTP + QVERIFY(entry->hasTotp()); + // Check attributes + auto attr = entry->attributes(); + QVERIFY(attr->isProtected("hidden field")); + QCOMPARE(attr->value("second 2fa secret"), QStringLiteral("TOTPCODE")); + // NOTE: Proton Pass does not export attachments + // NOTE: Proton Pass does not export expiration dates + + // Confirm Secure Note + entry = db->rootGroup()->findEntryByPath("/Personal/My Secure Note"); + QVERIFY(entry); + QCOMPARE(entry->notes(), QStringLiteral("Secure note contents.")); + + // Confirm Credit Card + entry = db->rootGroup()->findEntryByPath("/Personal/Test Card"); + QVERIFY(entry); + QCOMPARE(entry->username(), QStringLiteral("1234222233334444")); + QCOMPARE(entry->password(), QStringLiteral("333")); + attr = entry->attributes(); + QCOMPARE(attr->value("card_cardholderName"), QStringLiteral("Test name")); + QCOMPARE(attr->value("card_expirationDate"), QStringLiteral("2025-01")); + QCOMPARE(attr->value("card_pin"), QStringLiteral("1234")); + QVERIFY(attr->isProtected("card_pin")); + + // Confirm Expired (deleted) entry + entry = db->rootGroup()->findEntryByPath("/Personal/My Deleted Note"); + QVERIFY(entry); + QTRY_VERIFY(entry->isExpired()); + + // Confirm second group (vault) + entry = db->rootGroup()->findEntryByPath("/Test/Other vault login"); + QVERIFY(entry); +} diff --git a/tests/TestImports.h b/tests/TestImports.h index 2e00de9a6a..fa128d1040 100644 --- a/tests/TestImports.h +++ b/tests/TestImports.h @@ -30,6 +30,7 @@ private slots: void testOPVault(); void testBitwarden(); void testBitwardenEncrypted(); + void testProtonPass(); }; #endif /* TEST_IMPORTS_H */ diff --git a/tests/data/protonpass_export.json b/tests/data/protonpass_export.json new file mode 100644 index 0000000000..ef82352180 --- /dev/null +++ b/tests/data/protonpass_export.json @@ -0,0 +1,173 @@ +{ + "version": "1.21.2", + "userId": "USER_ID", + "encrypted": false, + "vaults": { + "VAULT_A": { + "name": "Personal", + "description": "Personal vault", + "display": { + "color": 0, + "icon": 0 + }, + "items": [ + { + "itemId": "yZENmDjtmZGODNy3Q_CZiPAF_IgINq8w-R-qazrOh-Nt9YJeVF3gu07ovzDS4jhYHoMdOebTw5JkYPGgIL1mwQ==", + "shareId": "SN5uWo4WZF2uT5wIDqtbdpkjuxCbNTOIdf-JQ_DYZcKYKURHiZB5csS1a1p9lklvju9ni42l08IKzwQG0B2ySg==", + "data": { + "metadata": { + "name": "Test Login", + "note": "My login secure note.", + "itemUuid": "e8ee1a0c" + }, + "extraFields": [ + { + "fieldName": "non-hidden field", + "type": "text", + "data": { + "content": "non-hidden field content" + } + }, + { + "fieldName": "hidden field", + "type": "hidden", + "data": { + "content": "hidden field content" + } + }, + { + "fieldName": "second 2fa secret", + "type": "totp", + "data": { + "totpUri": "TOTPCODE" + } + } + ], + "type": "login", + "content": { + "itemEmail": "Email", + "password": "Password", + "urls": [ + "https://example.com/", + "https://example2.com/" + ], + "totpUri": "otpauth://totp/Test%20Login%20-%20Personal%20Vault:Username?issuer=Test%20Login%20-%20Personal%20Vault&secret=TOTPCODE&algorithm=SHA1&digits=6&period=30", + "passkeys": [], + "itemUsername": "Username" + } + }, + "state": 1, + "aliasEmail": null, + "contentFormatVersion": 1, + "createTime": 1689182868, + "modifyTime": 1689182868, + "pinned": true + }, + { + "itemId": "xqq_Bh8RxNMBerkiMvRdH427yswZznjYwps-f6C5D8tmKiPgMxCSPNz1BOd4nRJ309gciDiPhXcCVWOyfJ66ZA==", + "shareId": "SN5uWo4WZF2uT5wIDqtbdpkjuxCbNTOIdf-JQ_DYZcKYKURHiZB5csS1a1p9lklvju9ni42l08IKzwQG0B2ySg==", + "data": { + "metadata": { + "name": "My Secure Note", + "note": "Secure note contents.", + "itemUuid": "ad618070" + }, + "extraFields": [], + "type": "note", + "content": {} + }, + "state": 1, + "aliasEmail": null, + "contentFormatVersion": 1, + "createTime": 1689182908, + "modifyTime": 1689182908, + "pinned": false + }, + { + "itemId": "ZmGzd-HNQYTr6wmfWlSfiStXQLqGic_PYB2Q2T_hmuRM2JIA4pKAPJcmFafxJrDpXxLZ2EPjgD6Noc9a0U6AVQ==", + "shareId": "SN5uWo4WZF2uT5wIDqtbdpkjuxCbNTOIdf-JQ_DYZcKYKURHiZB5csS1a1p9lklvju9ni42l08IKzwQG0B2ySg==", + "data": { + "metadata": { + "name": "Test Card", + "note": "Credit Card Note", + "itemUuid": "d8f45370" + }, + "extraFields": [], + "type": "creditCard", + "content": { + "cardholderName": "Test name", + "cardType": 0, + "number": "1234222233334444", + "verificationNumber": "333", + "expirationDate": "2025-01", + "pin": "1234" + } + }, + "state": 1, + "aliasEmail": null, + "contentFormatVersion": 1, + "createTime": 1691001643, + "modifyTime": 1691001643, + "pinned": true + }, + { + "itemId": "xqq_Bh8RxNMBerkiMvRdH427yswZznjYwps-f6C5D8tmKiPgMxCSPNz1BOd4nRJ309gciDiPhXcCVWOyfJ66ZA==", + "shareId": "SN5uWo4WZF2uT5wIDqtbdpkjuxCbNTOIdf-JQ_DYZcKYKURHiZB5csS1a1p9lklvju9ni42l08IKzwQG0B2ySg==", + "data": { + "metadata": { + "name": "My Deleted Note", + "note": "Secure note contents.", + "itemUuid": "ad618070" + }, + "extraFields": [], + "type": "note", + "content": {} + }, + "state": 2, + "aliasEmail": null, + "contentFormatVersion": 1, + "createTime": 1689182908, + "modifyTime": 1689182908, + "pinned": false + } + ] + }, + "VAULT_B": { + "name": "Test", + "description": "", + "display": { + "color": 4, + "icon": 2 + }, + "items": [ + { + "itemId": "U_J8-eUR15sC-PjUhjVcixDcayhjGuoerUZCr560RlAi0ZjBNkSaSKAytVzZn4E0hiFX1_y4qZbUetl6jO3aJw==", + "shareId": "OJz-4MnPqAuYnyemhctcGDlSLJrzsTnf2FnFSwxh1QP_oth9xyGDc2ZAqCv5FnqkVgTNHT5aPj62zcekNemfNw==", + "data": { + "metadata": { + "name": "Other vault login", + "note": "", + "itemUuid": "f3429d44" + }, + "extraFields": [], + "type": "login", + "content": { + "itemEmail": "other vault username", + "password": "other vault password", + "urls": [], + "totpUri": "JBSWY3DPEHPK3PXP", + "passkeys": [], + "itemUsername": "" + } + }, + "state": 1, + "aliasEmail": null, + "contentFormatVersion": 1, + "createTime": 1689182949, + "modifyTime": 1689182949, + "pinned": false + } + ] + } + } +} \ No newline at end of file