Refactor: separate GUI sources from core sources

This PR splits the GUI source files from the core source files. The immediate goal is to allow the CLI to require only a minimum number of dynamic libraries. The long term goal is to create an architectural boundary around the core module, in preparation of libkdbx.
This commit is contained in:
louib 2022-09-17 21:45:43 -04:00 committed by Jonathan White
parent 854459068f
commit 166a371050
36 changed files with 173 additions and 163 deletions

View File

@ -16,7 +16,19 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(keepassx_SOURCES
add_feature_info(Auto-Type WITH_XC_AUTOTYPE "Automatic password typing")
add_feature_info(Networking WITH_XC_NETWORKING "Compile KeePassXC with network access code (e.g. for downloading website icons)")
add_feature_info(KeePassXC-Browser WITH_XC_BROWSER "Browser integration with KeePassXC-Browser")
add_feature_info(Passkeys WITH_XC_BROWSER_PASSKEYS "Passkeys support for browser integration")
add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent")
add_feature_info(KeeShare WITH_XC_KEESHARE "Sharing integration with KeeShare")
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response")
add_feature_info(UpdateCheck WITH_XC_UPDATECHECK "Automatic update checking")
if(UNIX AND NOT APPLE)
add_feature_info(FdoSecrets WITH_XC_FDOSECRETS "Implement freedesktop.org Secret Storage Spec server side API.")
endif()
set(core_SOURCES
core/Alloc.cpp
core/AutoTypeAssociations.cpp
core/Base32.cpp
@ -47,7 +59,6 @@ set(keepassx_SOURCES
core/Tools.cpp
core/Totp.cpp
core/Translator.cpp
core/UrlTools.cpp
cli/Utils.cpp
cli/TextStream.cpp
crypto/Crypto.cpp
@ -79,6 +90,18 @@ set(keepassx_SOURCES
format/OpVaultReaderAttachments.cpp
format/OpVaultReaderBandEntry.cpp
format/OpVaultReaderSections.cpp
keys/CompositeKey.cpp
keys/FileKey.cpp
keys/PasswordKey.cpp
keys/ChallengeResponseKey.cpp
streams/HashedBlockStream.cpp
streams/HmacBlockStream.cpp
streams/LayeredStream.cpp
streams/qtiocompressor.cpp
streams/StoreDataStream.cpp
streams/SymmetricCipherStream.cpp)
set(gui_SOURCES
gui/styles/styles.qrc
gui/styles/StateColorPalette.cpp
gui/styles/base/phantomcolor.cpp
@ -124,6 +147,7 @@ set(keepassx_SOURCES
gui/TotpExportSettingsDialog.cpp
gui/DatabaseOpenDialog.cpp
gui/URLEdit.cpp
gui/UrlTools.cpp
gui/WelcomeWidget.cpp
gui/csvImport/CsvImportWidget.cpp
gui/csvImport/CsvParserModel.cpp
@ -180,42 +204,37 @@ set(keepassx_SOURCES
gui/wizard/NewDatabaseWizardPageMetaData.cpp
gui/wizard/NewDatabaseWizardPageEncryption.cpp
gui/wizard/NewDatabaseWizardPageDatabaseKey.cpp
keys/CompositeKey.cpp
keys/FileKey.cpp
keys/PasswordKey.cpp
keys/ChallengeResponseKey.cpp
streams/HashedBlockStream.cpp
streams/HmacBlockStream.cpp
streams/LayeredStream.cpp
streams/qtiocompressor.cpp
streams/StoreDataStream.cpp
streams/SymmetricCipherStream.cpp
quickunlock/QuickUnlockInterface.cpp)
quickunlock/QuickUnlockInterface.cpp
../share/icons/icons.qrc
../share/wizard/wizard.qrc)
if(APPLE)
set(keepassx_SOURCES
${keepassx_SOURCES}
core/MacPasteboard.cpp
list(APPEND gui_SOURCES
gui/osutils/macutils/MacPasteboard.cpp
gui/osutils/macutils/MacUtils.cpp
gui/osutils/macutils/ScreenLockListenerMac.cpp
gui/osutils/macutils/AppKitImpl.mm
gui/osutils/macutils/AppKit.h)
gui/osutils/macutils/AppKit.h
quickunlock/TouchID.mm)
# TODO: Remove -Wno-error once deprecation warnings have been resolved.
set_source_files_properties(quickunlock/TouchID.mm PROPERTY COMPILE_FLAGS "-Wno-old-style-cast")
endif()
if(UNIX AND NOT APPLE)
set(keepassx_SOURCES
${keepassx_SOURCES}
list(APPEND gui_SOURCES
gui/osutils/nixutils/ScreenLockListenerDBus.cpp
gui/osutils/nixutils/NixUtils.cpp)
if("${CMAKE_SYSTEM}" MATCHES "Linux")
set(keepassx_SOURCES
${keepassx_SOURCES}
list(APPEND core_SOURCES
quickunlock/Polkit.cpp
quickunlock/PolkitDbusTypes.cpp)
endif()
if(WITH_XC_X11)
list(APPEND keepassx_SOURCES
list(APPEND gui_SOURCES
gui/osutils/nixutils/X11Funcs.cpp)
endif()
qt5_add_dbus_adaptor(keepassx_SOURCES
qt5_add_dbus_adaptor(gui_SOURCES
gui/org.keepassxc.KeePassXC.MainWindow.xml
gui/MainWindow.h
MainWindow)
@ -225,7 +244,7 @@ if(UNIX AND NOT APPLE)
PROPERTIES
INCLUDE "quickunlock/PolkitDbusTypes.h"
)
qt5_add_dbus_interface(keepassx_SOURCES
qt5_add_dbus_interface(core_SOURCES
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
polkit_dbus
)
@ -235,50 +254,33 @@ if(UNIX AND NOT APPLE)
message(FATAL_ERROR "Could not find libkeyutils")
endif()
endif()
if(WIN32)
set(keepassx_SOURCES
${keepassx_SOURCES}
list(APPEND gui_SOURCES
gui/osutils/winutils/ScreenLockListenerWin.cpp
gui/osutils/winutils/WinUtils.cpp)
gui/osutils/winutils/WinUtils.cpp
../share/windows/icon.rc)
if (MSVC)
list(APPEND keepassx_SOURCES quickunlock/WindowsHello.cpp)
list(APPEND gui_SOURCES quickunlock/WindowsHello.cpp)
endif()
endif()
if(WITH_XC_YUBIKEY)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/DeviceListener.cpp)
list(APPEND gui_SOURCES gui/osutils/DeviceListener.cpp)
if(APPLE)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/macutils/DeviceListenerMac.cpp)
list(APPEND gui_SOURCES gui/osutils/macutils/DeviceListenerMac.cpp)
elseif(UNIX)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/nixutils/DeviceListenerLibUsb.cpp)
list(APPEND gui_SOURCES gui/osutils/nixutils/DeviceListenerLibUsb.cpp)
elseif(WIN32)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/winutils/DeviceListenerWin.cpp)
list(APPEND gui_SOURCES gui/osutils/winutils/DeviceListenerWin.cpp)
endif()
endif()
set(keepassx_SOURCES ${keepassx_SOURCES}
../share/icons/icons.qrc
../share/wizard/wizard.qrc)
set(keepassx_SOURCES_MAINEXE main.cpp)
add_feature_info(Auto-Type WITH_XC_AUTOTYPE "Automatic password typing")
add_feature_info(Networking WITH_XC_NETWORKING "Compile KeePassXC with network access code (e.g. for downloading website icons)")
add_feature_info(KeePassXC-Browser WITH_XC_BROWSER "Browser integration with KeePassXC-Browser")
add_feature_info(Passkeys WITH_XC_BROWSER_PASSKEYS "Passkeys support for browser integration")
add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent")
add_feature_info(KeeShare WITH_XC_KEESHARE "Sharing integration with KeeShare")
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response")
add_feature_info(UpdateCheck WITH_XC_UPDATECHECK "Automatic update checking")
if(UNIX AND NOT APPLE)
add_feature_info(FdoSecrets WITH_XC_FDOSECRETS "Implement freedesktop.org Secret Storage Spec server side API.")
endif()
add_subdirectory(browser)
add_subdirectory(proxy)
if(WITH_XC_BROWSER)
set(keepassxcbrowser_LIB keepassxcbrowser)
set(keepassx_SOURCES ${keepassx_SOURCES}
set(browser_LIB browser)
list(APPEND gui_SOURCES
gui/dbsettings/DatabaseSettingsWidgetBrowser.cpp
gui/entry/EntryURLModel.cpp
gui/reports/ReportsWidgetBrowserStatistics.cpp
@ -286,7 +288,7 @@ if(WITH_XC_BROWSER)
endif()
if(WITH_XC_BROWSER_PASSKEYS)
set(keepassx_SOURCES ${keepassx_SOURCES}
list(APPEND gui_SOURCES
gui/reports/ReportsWidgetPasskeys.cpp
gui/reports/ReportsPagePasskeys.cpp
gui/passkeys/PasskeyExporter.cpp
@ -318,7 +320,6 @@ endif()
add_subdirectory(thirdparty)
set(autotype_SOURCES
core/Tools.cpp
autotype/AutoType.cpp
autotype/AutoTypeAction.cpp
autotype/AutoTypeMatchModel.cpp
@ -327,57 +328,42 @@ set(autotype_SOURCES
autotype/PickcharsDialog.cpp
autotype/WindowSelectComboBox.cpp)
if(WIN32)
set(keepassx_SOURCES_MAINEXE ${keepassx_SOURCES_MAINEXE} ${CMAKE_SOURCE_DIR}/share/windows/icon.rc)
endif()
add_library(autotype STATIC ${autotype_SOURCES})
target_link_libraries(autotype Qt5::Core Qt5::Widgets)
if(WITH_XC_YUBIKEY)
list(APPEND keepassx_SOURCES
list(APPEND core_SOURCES
keys/drivers/YubiKey.h
keys/drivers/YubiKey.cpp
keys/drivers/YubiKeyInterface.cpp
keys/drivers/YubiKeyInterfaceUSB.cpp
keys/drivers/YubiKeyInterfacePCSC.cpp)
else()
list(APPEND keepassx_SOURCES
list(APPEND core_SOURCES
keys/drivers/YubiKey.h
keys/drivers/YubiKeyStub.cpp)
endif()
if(WITH_XC_NETWORKING)
list(APPEND keepassx_SOURCES
core/HibpDownloader.cpp
core/NetworkManager.cpp
list(APPEND gui_SOURCES
networking/HibpDownloader.cpp
networking/NetworkManager.cpp
networking/UpdateChecker.cpp
gui/UpdateCheckDialog.cpp
gui/IconDownloader.cpp
gui/IconDownloaderDialog.cpp
updatecheck/UpdateChecker.cpp)
endif()
if(APPLE)
list(APPEND keepassx_SOURCES quickunlock/TouchID.mm)
# TODO: Remove -Wno-error once deprecation warnings have been resolved.
set_source_files_properties(quickunlock/TouchID.mm PROPERTY COMPILE_FLAGS "-Wno-old-style-cast")
gui/IconDownloaderDialog.cpp)
endif()
configure_file(config-keepassx.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepassx.h)
configure_file(git-info.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/git-info.h)
add_library(autotype STATIC ${autotype_SOURCES})
target_link_libraries(autotype Qt5::Core Qt5::Widgets)
add_library(keepassx_core STATIC ${keepassx_SOURCES})
set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassx_core
autotype
${keepassxcbrowser_LIB}
# Core Library Definition
add_library(keepassxc_core STATIC ${core_SOURCES})
set_target_properties(keepassxc_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassxc_core
${qrcode_LIB}
${fdosecrets_LIB}
Qt5::Core
Qt5::Concurrent
Qt5::Network
Qt5::Widgets
${BOTAN_LIBRARIES}
${PCSC_LIBRARIES}
${ZXCVBN_LIBRARIES}
@ -385,39 +371,45 @@ target_link_libraries(keepassx_core
${MINIZIP_LIBRARIES}
${ARGON2_LIBRARIES}
${KEYUTILS_LIBRARIES}
${thirdparty_LIBRARIES}
)
${thirdparty_LIBRARIES})
if(WITH_XC_SSHAGENT)
target_link_libraries(keepassx_core sshagent)
endif()
if(WITH_XC_KEESHARE)
target_link_libraries(keepassx_core keeshare)
endif()
# GUI Library Definition
add_library(keepassxc_gui STATIC ${gui_SOURCES})
set_target_properties(keepassxc_gui PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassxc_gui
keepassxc_core
Qt5::Network
Qt5::Widgets
autotype
${browser_LIB}
${fdosecrets_LIB}
${keeshare_LIB}
${sshagent_LIB})
if(APPLE)
target_link_libraries(keepassx_core "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication")
target_link_libraries(keepassxc_gui "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication")
if(Qt5MacExtras_FOUND)
target_link_libraries(keepassx_core Qt5::MacExtras)
target_link_libraries(keepassxc_gui Qt5::MacExtras)
endif()
endif()
if(HAIKU)
target_link_libraries(keepassx_core network)
target_link_libraries(keepassxc_gui network)
endif()
if(UNIX AND NOT APPLE)
target_link_libraries(keepassx_core Qt5::DBus ${LIBUSB_LIBRARIES})
target_link_libraries(keepassxc_core Qt5::DBus ${LIBUSB_LIBRARIES})
if(WITH_XC_X11)
target_link_libraries(keepassx_core Qt5::X11Extras X11)
target_link_libraries(keepassxc_gui Qt5::X11Extras X11)
endif()
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endif()
if(WIN32)
target_link_libraries(keepassx_core Wtsapi32.lib Ws2_32.lib)
target_link_libraries(keepassxc_gui Wtsapi32.lib Ws2_32.lib)
if (MSVC)
target_link_libraries(keepassx_core WindowsApp.lib)
target_link_libraries(keepassxc_gui WindowsApp.lib)
endif()
endif()
# Main Executable Defintion
if(WIN32)
include(GenerateProductVersion)
generate_product_version(
@ -430,11 +422,11 @@ if(WIN32)
)
endif()
add_executable(${PROGNAME} WIN32 ${keepassx_SOURCES_MAINEXE} ${WIN32_ProductVersionFiles})
target_link_libraries(${PROGNAME} keepassx_core)
add_executable(${PROGNAME} WIN32 main.cpp ${WIN32_ProductVersionFiles})
target_link_libraries(${PROGNAME} keepassxc_gui)
set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON)
# macOS App Bundle
if(APPLE AND WITH_APP_BUNDLE)
install(FILES ${CMAKE_SOURCE_DIR}/share/macosx/embedded.provisionprofile DESTINATION ${BUNDLE_INSTALL_DIR})
configure_file(${CMAKE_SOURCE_DIR}/share/macosx/Info.plist.cmake ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
@ -463,6 +455,7 @@ install(TARGETS ${PROGNAME}
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime)
# Windows Installer Definition
if(WIN32)
if(${CMAKE_SIZEOF_VOID_P} EQUAL "8")
set(OUTPUT_FILE_POSTFIX "Win64")

View File

@ -1,4 +1,4 @@
set(autotype_test_SOURCES AutoTypeTest.cpp)
add_library(keepassxc-autotype-test MODULE ${autotype_test_SOURCES})
target_link_libraries(keepassxc-autotype-test keepassx_core ${autotype_LIB} Qt5::Core Qt5::Widgets)
target_link_libraries(keepassxc-autotype-test keepassxc_gui ${autotype_LIB} Qt5::Core Qt5::Widgets)

View File

@ -1,7 +1,7 @@
set(autotype_win_SOURCES AutoTypeWindows.cpp)
add_library(keepassxc-autotype-windows MODULE ${autotype_win_SOURCES})
target_link_libraries(keepassxc-autotype-windows keepassx_core ${autotype_LIB} Qt5::Core Qt5::Widgets)
target_link_libraries(keepassxc-autotype-windows keepassxc_gui ${autotype_LIB} Qt5::Core Qt5::Widgets)
install(TARGETS keepassxc-autotype-windows
BUNDLE DESTINATION . COMPONENT Runtime
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)

View File

@ -3,7 +3,7 @@ include_directories(SYSTEM ${X11_X11_INCLUDE_PATH})
set(autotype_XCB_SOURCES AutoTypeXCB.cpp)
add_library(keepassxc-autotype-xcb MODULE ${autotype_XCB_SOURCES})
target_link_libraries(keepassxc-autotype-xcb keepassx_core Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB})
target_link_libraries(keepassxc-autotype-xcb keepassxc_gui Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB})
install(TARGETS keepassxc-autotype-xcb
BUNDLE DESTINATION . COMPONENT Runtime
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)

View File

@ -25,9 +25,9 @@
#include "BrowserMessageBuilder.h"
#include "BrowserSettings.h"
#include "core/Tools.h"
#include "core/UrlTools.h"
#include "gui/MainWindow.h"
#include "gui/MessageBox.h"
#include "gui/UrlTools.h"
#include "gui/osutils/OSUtils.h"
#ifdef WITH_XC_BROWSER_PASSKEYS
#include "BrowserPasskeys.h"

View File

@ -16,7 +16,7 @@
if(WITH_XC_BROWSER)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(keepassxcbrowser_SOURCES
set(browser_SOURCES
BrowserAccessControlDialog.cpp
BrowserAction.cpp
BrowserEntryConfig.cpp
@ -32,7 +32,7 @@ if(WITH_XC_BROWSER)
NativeMessageInstaller.cpp)
if(WITH_XC_BROWSER_PASSKEYS)
list(APPEND keepassxcbrowser_SOURCES
list(APPEND browser_SOURCES
BrowserCbor.cpp
BrowserPasskeys.cpp
BrowserPasskeysClient.cpp
@ -40,6 +40,6 @@ if(WITH_XC_BROWSER)
PasskeyUtils.cpp)
endif()
add_library(keepassxcbrowser STATIC ${keepassxcbrowser_SOURCES})
target_link_libraries(keepassxcbrowser Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${BOTAN_LIBRARIES})
add_library(browser STATIC ${browser_SOURCES})
target_link_libraries(browser Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${BOTAN_LIBRARIES})
endif()

View File

@ -19,7 +19,7 @@
#include "BrowserMessageBuilder.h"
#include "BrowserPasskeys.h"
#include "core/Tools.h"
#include "core/UrlTools.h"
#include "gui/UrlTools.h"
#include <QList>
#include <QUrl>

View File

@ -58,7 +58,7 @@ add_executable(keepassxc-cli keepassxc-cli.cpp)
target_link_libraries(keepassxc-cli
${GPGERROR_LIBRARIES}
cli
keepassx_core)
keepassxc_core)
install(TARGETS keepassxc-cli
BUNDLE DESTINATION . COMPONENT Runtime

View File

@ -802,10 +802,21 @@ void Entry::addHistoryItem(Entry* entry)
{
Q_ASSERT(!entry->parent());
entry->setHistoryOwner(this);
m_history.append(entry);
emitModified();
}
void Entry::setHistoryOwner(Entry* entry)
{
m_historyOwner = entry;
}
Entry* Entry::historyOwner() const
{
return m_historyOwner;
}
void Entry::removeHistoryItems(const QList<Entry*>& historyEntries)
{
if (historyEntries.isEmpty()) {

View File

@ -168,6 +168,8 @@ public:
QList<Entry*> historyItems();
const QList<Entry*>& historyItems() const;
void addHistoryItem(Entry* entry);
void setHistoryOwner(Entry* entry);
Entry* historyOwner() const;
void removeHistoryItems(const QList<Entry*>& historyEntries);
void truncateHistory();
@ -294,6 +296,7 @@ private:
QPointer<AutoTypeAssociations> m_autoTypeAssociations;
QPointer<CustomData> m_customData;
QList<Entry*> m_history; // Items sorted from oldest to newest
QPointer<Entry> m_historyOwner;
QScopedPointer<Entry> m_tmpHistoryItem;
bool m_modifiedSinceBegin;

View File

@ -247,6 +247,20 @@ bool Group::isEmpty() const
return !hasChildren() && m_entries.isEmpty();
}
// TODO: Refactor this when KeeShare is refactored
bool Group::isShared() const
{
auto group = this;
do {
if (group->customData()->contains("KeeShare/Reference")) {
return true;
}
group = group->m_parent;
} while (group);
return false;
}
CustomData* Group::customData()
{
return m_customData;

View File

@ -98,6 +98,7 @@ public:
bool isExpired() const;
bool isRecycled() const;
bool isEmpty() const;
bool isShared() const;
CustomData* customData();
const CustomData* customData() const;
Group::TriState resolveCustomDataTriState(const QString& key, bool checkParent = true) const;

View File

@ -23,10 +23,6 @@
#include "crypto/CryptoHash.h"
#include "crypto/Random.h"
#include "format/KeePass2RandomStream.h"
#ifdef WITH_XC_KEESHARE
#include "keeshare/KeeShare.h"
#include "keeshare/KeeShareSettings.h"
#endif
#include "streams/HmacBlockStream.h"
#include "streams/SymmetricCipherStream.h"
#include "streams/qtiocompressor.h"
@ -232,8 +228,12 @@ KdbxXmlWriter::BinaryIdxMap Kdbx4Writer::writeAttachments(QIODevice* device, Dat
#ifdef WITH_XC_KEESHARE
// Namespace KeeShare attachments so they don't get deduplicated together with attachments
// from other databases. Prevents potential filesize side channels.
if (auto shared = KeeShare::resolveSharedGroup(entry->group())) {
hash.addData(KeeShare::referenceOf(shared).uuid.toByteArray());
auto group = entry->group();
if (!group && entry->historyOwner()) {
group = entry->historyOwner()->group();
}
if (group && group->isShared()) {
hash.addData(group->uuid().toByteArray());
} else {
hash.addData(db->uuid().toByteArray());
}

View File

@ -24,8 +24,6 @@
#include "core/Endian.h"
#include "crypto/CryptoHash.h"
#include "format/KeePass2RandomStream.h"
#include "keeshare/KeeShare.h"
#include "keeshare/KeeShareSettings.h"
#include "streams/qtiocompressor.h"
/**
@ -114,8 +112,12 @@ void KdbxXmlWriter::fillBinaryIdxMap()
#ifdef WITH_XC_KEESHARE
// Namespace KeeShare attachments so they don't get deduplicated together with attachments
// from other databases. Prevents potential filesize side channels.
if (auto shared = KeeShare::resolveSharedGroup(entry->group())) {
hash.addData(KeeShare::referenceOf(shared).uuid.toByteArray());
auto group = entry->group();
if (!group && entry->historyOwner()) {
group = entry->historyOwner()->group();
}
if (group && group->isShared()) {
hash.addData(group->uuid().toByteArray());
} else {
hash.addData(m_db->uuid().toByteArray());
}

View File

@ -22,7 +22,7 @@
#include <QElapsedTimer>
#include <QObject>
#ifdef Q_OS_MACOS
#include "core/MacPasteboard.h"
#include "gui/osutils/macutils/MacPasteboard.h"
#include <QPointer>
#endif

View File

@ -17,8 +17,8 @@
#include "IconDownloader.h"
#include "core/Config.h"
#include "core/NetworkManager.h"
#include "core/UrlTools.h"
#include "gui/UrlTools.h"
#include "networking/NetworkManager.h"
#include <QBuffer>
#include <QHostInfo>

View File

@ -50,7 +50,7 @@
#ifdef WITH_XC_UPDATECHECK
#include "gui/UpdateCheckDialog.h"
#include "updatecheck/UpdateChecker.h"
#include "networking/UpdateChecker.h"
#endif
#ifdef WITH_XC_SSHAGENT

View File

@ -18,9 +18,8 @@
#include "URLEdit.h"
#include "core/Tools.h"
#include "core/UrlTools.h"
#include "gui/Icons.h"
#include "gui/UrlTools.h"
#include "gui/styles/StateColorPalette.h"
URLEdit::URLEdit(QWidget* parent)

View File

@ -22,7 +22,7 @@
#include "config-keepassx.h"
#include "gui/Icons.h"
#include "updatecheck/UpdateChecker.h"
#include "networking/UpdateChecker.h"
UpdateCheckDialog::UpdateCheckDialog(QWidget* parent)
: QDialog(parent)

View File

@ -19,10 +19,12 @@
#define KEEPASSXC_URLTOOLS_H
#include "config-keepassx.h"
#include <QNetworkReply>
#include <QObject>
#include <QUrl>
#include <QVariant>
#if defined(WITH_XC_NETWORKING) || defined(WITH_XC_BROWSER)
#include <QNetworkReply>
#endif
class UrlTools : public QObject
{

View File

@ -20,8 +20,8 @@
#include "browser/BrowserService.h"
#include "core/EntryAttributes.h"
#include "core/UrlTools.h"
#include "gui/Icons.h"
#include "gui/UrlTools.h"
#include "gui/styles/StateColorPalette.h"
EntryURLModel::EntryURLModel(QObject* parent)

View File

@ -24,7 +24,7 @@
#include <QWidget>
#ifdef WITH_XC_NETWORKING
#include "core/HibpDownloader.h"
#include "networking/HibpDownloader.h"
#endif
class Database;

View File

@ -16,7 +16,7 @@
*/
#include "HibpDownloader.h"
#include "core/NetworkManager.h"
#include "NetworkManager.h"
#include <QCryptographicHash>
#include <QNetworkReply>

View File

@ -17,10 +17,10 @@
#include "UpdateChecker.h"
#include "NetworkManager.h"
#include "config-keepassx.h"
#include "core/Clock.h"
#include "core/Config.h"
#include "core/NetworkManager.h"
#include <QJsonArray>
#include <QJsonDocument>

View File

@ -40,5 +40,5 @@ elseif(UNIX AND NOT APPLE)
target_compile_definitions(ykcore PRIVATE _GNU_SOURCE)
elseif(APPLE)
target_sources(ykcore PRIVATE ykcore_osx.c)
target_link_libraries(ykcore PUBLIC "-framework IOKit")
target_link_libraries(ykcore PUBLIC "-framework IOKit -framework Foundation")
endif()

View File

@ -90,7 +90,7 @@ macro(add_unit_test)
endif()
endmacro(add_unit_test)
set(TEST_LIBRARIES keepassx_core Qt5::Test)
set(TEST_LIBRARIES keepassxc_gui Qt5::Test)
set(testsupport_SOURCES
modeltest.cpp
@ -143,7 +143,7 @@ add_unit_test(NAME testkeepass1reader SOURCES TestKeePass1Reader.cpp
LIBS ${TEST_LIBRARIES})
add_unit_test(NAME testimports SOURCES TestImports.cpp
LIBS ${TEST_LIBRARIES})
LIBS ${TEST_LIBRARIES})
if(WITH_XC_NETWORKING)
add_unit_test(NAME testupdatecheck SOURCES TestUpdateCheck.cpp
@ -163,7 +163,7 @@ if(WITH_XC_SSHAGENT)
LIBS sshagent ${TEST_LIBRARIES})
if(NOT WIN32)
add_unit_test(NAME testsshagent SOURCES TestSSHAgent.cpp
LIBS ${TEST_LIBRARIES})
LIBS sshagent ${TEST_LIBRARIES})
endif()
endif()
@ -195,7 +195,7 @@ add_unit_test(NAME testcsvparser SOURCES TestCsvParser.cpp
LIBS ${TEST_LIBRARIES})
add_unit_test(NAME testrandomgenerator SOURCES TestRandomGenerator.cpp
LIBS testsupport ${TEST_LIBRARIES})
LIBS testsupport ${TEST_LIBRARIES})
add_unit_test(NAME testentrysearcher SOURCES TestEntrySearcher.cpp
LIBS ${TEST_LIBRARIES})
@ -225,22 +225,16 @@ add_unit_test(NAME testconfig SOURCES TestConfig.cpp
if(WITH_XC_FDOSECRETS)
add_unit_test(NAME testfdosecrets SOURCES TestFdoSecrets.cpp
LIBS testsupport ${TEST_LIBRARIES})
LIBS testsupport fdosecrets ${TEST_LIBRARIES})
endif()
if(WITH_XC_BROWSER)
add_unit_test(NAME testbrowser SOURCES TestBrowser.cpp
LIBS ${TEST_LIBRARIES})
LIBS browser ${TEST_LIBRARIES})
if(WITH_XC_BROWSER_PASSKEYS)
# Prevent duplicate linking with macOS
if(APPLE)
add_unit_test(NAME testpasskeys SOURCES TestPasskeys.cpp
LIBS ${TEST_LIBRARIES})
else()
add_unit_test(NAME testpasskeys SOURCES TestPasskeys.cpp
LIBS keepassxcbrowser ${TEST_LIBRARIES})
endif()
add_unit_test(NAME testpasskeys SOURCES TestPasskeys.cpp
LIBS browser ${TEST_LIBRARIES})
endif()
endif()

View File

@ -24,10 +24,6 @@
#include "format/KeePass2.h"
#include "format/KeePass2Reader.h"
#include "format/KeePass2Writer.h"
#ifdef WITH_XC_KEESHARE
#include "keeshare/KeeShare.h"
#include "keeshare/KeeShareSettings.h"
#endif
#include "keys/FileKey.h"
#include "keys/PasswordKey.h"
#include "mock/MockChallengeResponseKey.h"
@ -441,13 +437,8 @@ void TestKdbx4Format::testAttachmentIndexStability()
group2->setUuid(QUuid::createUuid());
QVERIFY(!group2->uuid().isNull());
group2->setParent(group1);
#ifdef WITH_XC_KEESHARE
KeeShareSettings::Reference ref;
ref.type = KeeShareSettings::SynchronizeWith;
ref.path = "123";
KeeShare::setReferenceTo(group2, ref);
QVERIFY(KeeShare::isShared(group2));
#endif
group2->customData()->set("KeeShare/Reference", "value doesn't matter");
QVERIFY(group2->isShared());
auto attachment1 = QByteArray("qwerty");
auto attachment2 = QByteArray("asdf");
@ -510,9 +501,9 @@ void TestKdbx4Format::testAttachmentIndexStability()
QCOMPARE(a2->value("a"), attachment1);
QCOMPARE(a2->value("b"), attachment2);
#ifdef WITH_XC_KEESHARE
QVERIFY(KeeShare::isShared(db2->rootGroup()->findEntryByUuid(uuid3)->group()));
#endif
auto sharedGroup = db2->rootGroup()->findEntryByUuid(uuid3)->group();
QVERIFY(sharedGroup->isShared());
auto a3 = db2->rootGroup()->findEntryByUuid(uuid3)->attachments();
QCOMPARE(a3->keys().size(), 4);
QCOMPARE(a3->values().size(), 3);

View File

@ -17,7 +17,7 @@
#include "TestUpdateCheck.h"
#include "crypto/Crypto.h"
#include "updatecheck/UpdateChecker.h"
#include "networking/UpdateChecker.h"
#include <QTest>

View File

@ -18,7 +18,7 @@
#ifndef KEEPASSXC_TESTURLTOOLS_H
#define KEEPASSXC_TESTURLTOOLS_H
#include "core/UrlTools.h"
#include "gui/UrlTools.h"
#include <QObject>
#include <QPointer>