From d5afd95af72c79641d44ef0bdf9a2249e18011ee Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 7 Sep 2022 15:43:23 +0200 Subject: [PATCH 01/28] Sentry WIP --- CMakeLists.txt | 12 ++++++++++++ src/cmake/macos.cmake | 5 +++++ src/loghandler.cpp | 26 +++++++++++++++++++++++++- src/main.cpp | 9 +++++++++ src/mozillavpn.cpp | 2 ++ 5 files changed, 53 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96655ddce4..29bd3587e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,3 +137,15 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") add_subdirectory(macos/loginitem) add_subdirectory(macos/pkg) endif() + +include(ExternalProject) +set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external) +ExternalProject_Add(sentry + GIT_REPOSITORY https://github.com/getsentry/sentry-native/ + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} -DSENTRY_BUILD_SHARED_LIBS=false +) + +target_include_directories(mozillavpn PUBLIC ${EXTERNAL_INSTALL_LOCATION}/include) +target_link_directories( mozillavpn PUBLIC ${EXTERNAL_INSTALL_LOCATION}/lib) +target_link_libraries(mozillavpn PUBLIC libsentry.a) +add_dependencies(mozillavpn sentry) \ No newline at end of file diff --git a/src/cmake/macos.cmake b/src/cmake/macos.cmake index 913cd40dbd..eb1fe4d04b 100644 --- a/src/cmake/macos.cmake +++ b/src/cmake/macos.cmake @@ -127,6 +127,11 @@ osx_bundle_files(mozillavpn DESTINATION Resources/utils ) +osx_bundle_files(mozillavpn + FILES ${CMAKE_BINARY_DIR}/external/bin/crashpad_handler + DESTINATION MacOS +) + # Install the native messaging extensions into the bundle. add_dependencies(mozillavpn mozillavpnnp) osx_bundle_files(mozillavpn FILES diff --git a/src/loghandler.cpp b/src/loghandler.cpp index ab4acf819a..111e6e36fe 100644 --- a/src/loghandler.cpp +++ b/src/loghandler.cpp @@ -16,6 +16,8 @@ #include #include +#include + #ifdef MVPN_ANDROID # include #endif @@ -193,7 +195,7 @@ void LogHandler::addLog(const Log& log, const MutexLocker& proofOfLock) { QTextStream out(stderr); prettyOutput(out, log); } - + QByteArray buffer; { QTextStream out(&buffer); @@ -202,6 +204,28 @@ void LogHandler::addLog(const Log& log, const MutexLocker& proofOfLock) { emit logEntryAdded(buffer); + sentry_value_t crumb = sentry_value_new_breadcrumb("Logger", buffer.constData()); + sentry_value_set_by_key(crumb, "category", log.m_fromQT ? sentry_value_new_string("QT"): sentry_value_new_string("CLIENT")); + switch (log.m_logLevel) + { + case LogLevel::Debug: + sentry_value_set_by_key(crumb, "level", sentry_value_new_string("Debug")); + break; + case LogLevel::Error: + sentry_value_set_by_key(crumb, "level", sentry_value_new_string("Error")); + break; + case LogLevel::Info: + sentry_value_set_by_key(crumb, "level", sentry_value_new_string("Info")); + break; + case LogLevel::Warning: + sentry_value_set_by_key(crumb, "level", sentry_value_new_string("Warning")); + break; + default: + sentry_value_set_by_key(crumb, "level", sentry_value_new_string("Unknown")); + break; + } + sentry_add_breadcrumb(crumb); + #if defined(MVPN_ANDROID) && defined(MVPN_DEBUG) const char* str = buffer.constData(); if (str) { diff --git a/src/main.cpp b/src/main.cpp index 40ea4155f6..6898e5c886 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,9 @@ #include "commandlineparser.h" #include "leakdetector.h" +#include "sentry.h" + +#include Q_DECL_EXPORT int main(int argc, char* argv[]) { #ifdef MVPN_DEBUG @@ -11,6 +14,12 @@ Q_DECL_EXPORT int main(int argc, char* argv[]) { Q_UNUSED(leakDetector); #endif + sentry_options_t *options = sentry_options_new(); + sentry_options_set_dsn(options, "https://6a476c1b57a34773a75c60036236a01d@o1396220.ingest.sentry.io/6719480"); + sentry_options_set_release(options, "my-project-name@2.3.12"); + //sentry_options_set_debug(options, 1); + sentry_init(options); + CommandLineParser clp; return clp.parse(argc, argv); } diff --git a/src/mozillavpn.cpp b/src/mozillavpn.cpp index d9fdff8d21..a176748c41 100644 --- a/src/mozillavpn.cpp +++ b/src/mozillavpn.cpp @@ -45,6 +45,8 @@ #include "urlopener.h" #include "websocket/websockethandler.h" +#include "sentry.h" + #ifdef MVPN_IOS # include "platforms/ios/iosdatamigration.h" # include "platforms/ios/iosutils.h" From c248adb971eaa714901d4a3fd3d2439a58054062 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 14 Sep 2022 13:39:56 +0200 Subject: [PATCH 02/28] Make it a proper integration --- .gitignore | 2 + CMakeLists.txt | 12 ----- src/CMakeLists.txt | 1 + src/cmake/macos.cmake | 4 -- src/cmake/sentry.cmake | 73 +++++++++++++++++++++++++ src/cmake/windows.cmake | 8 +-- src/commands/commandcrashreporter.cpp | 6 +-- src/commands/commandui.cpp | 4 -- src/main.cpp | 6 +-- src/mozillavpn.cpp | 7 +++ src/sentry/dummy_sentryadapter.cpp | 31 +++++++++++ src/sentry/sentryadapter.cpp | 77 +++++++++++++++++++++++++++ src/sentry/sentryadapter.h | 33 ++++++++++++ 13 files changed, 234 insertions(+), 30 deletions(-) create mode 100644 src/cmake/sentry.cmake create mode 100644 src/sentry/dummy_sentryadapter.cpp create mode 100644 src/sentry/sentryadapter.cpp create mode 100644 src/sentry/sentryadapter.h diff --git a/.gitignore b/.gitignore index f4aa485127..afc8236697 100644 --- a/.gitignore +++ b/.gitignore @@ -104,6 +104,8 @@ vscode-cpptools/* *.xcodeproj/ MozillaVPN.vcxproj* *.autosave +# Visual Studio stuff. +CMakeSettings.json # Qt Creator CMakeLists.txt.user diff --git a/CMakeLists.txt b/CMakeLists.txt index 29bd3587e0..96655ddce4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,15 +137,3 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") add_subdirectory(macos/loginitem) add_subdirectory(macos/pkg) endif() - -include(ExternalProject) -set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external) -ExternalProject_Add(sentry - GIT_REPOSITORY https://github.com/getsentry/sentry-native/ - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} -DSENTRY_BUILD_SHARED_LIBS=false -) - -target_include_directories(mozillavpn PUBLIC ${EXTERNAL_INSTALL_LOCATION}/include) -target_link_directories( mozillavpn PUBLIC ${EXTERNAL_INSTALL_LOCATION}/lib) -target_link_libraries(mozillavpn PUBLIC libsentry.a) -add_dependencies(mozillavpn sentry) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d947e21ea1..be4f00d50c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,6 +32,7 @@ target_link_libraries(mozillavpn PUBLIC ${CMAKE_DL_LIBS}) target_link_libraries(mozillavpn PRIVATE glean lottie nebula translations) include(cmake/sources.cmake) +include(cmake/sentry.cmake) if(${BUILD_DUMMY}) set(MVPN_PLATFORM_NAME "dummy") diff --git a/src/cmake/macos.cmake b/src/cmake/macos.cmake index eb1fe4d04b..c1e9251b0c 100644 --- a/src/cmake/macos.cmake +++ b/src/cmake/macos.cmake @@ -127,10 +127,6 @@ osx_bundle_files(mozillavpn DESTINATION Resources/utils ) -osx_bundle_files(mozillavpn - FILES ${CMAKE_BINARY_DIR}/external/bin/crashpad_handler - DESTINATION MacOS -) # Install the native messaging extensions into the bundle. add_dependencies(mozillavpn mozillavpnnp) diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake new file mode 100644 index 0000000000..72bf8146cd --- /dev/null +++ b/src/cmake/sentry.cmake @@ -0,0 +1,73 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + + +# This CMAKE File will Integrate Sentry into MVPN + + +# Defines which OS builds can include sentry. Check src/cmake Lists for all values of MVPN_PLATFORM_NAME +set(SENTRY_SUPPORTED_OS windows macos) +set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external) +include(ExternalProject) + + + +LIST(FIND SENTRY_SUPPORTED_OS MVPN_PLATFORM_NAME IS_SUPPORTED) + +if( IS_SUPPORTED==-1 ) + # Sentry is not supported on this Plattform, let's + # only include a dummy client :) + target_sources(mozillavpn PRIVATE + sentry/moc_sentryadapter.cpp + sentry/sentryadapter.h + ) + +else() + # Sentry support is given + target_sources(mozillavpn PRIVATE + sentry/sentryadapter.cpp + sentry/sentryadapter.h + ) + + # Configure Linking and Compile + if(APPLE) + # Compile Static for apple and link to libsentry.a + target_link_libraries(mozillavpn PUBLIC libsentry.a) + SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=false) + osx_bundle_files(mozillavpn + FILES ${CMAKE_BINARY_DIR}/external/bin/crashpad_handler + DESTINATION MacOS + ) + endif() + if(WIN32) + # Compile a dll for windows, as some breakpad imports will fail otherwise >:c + target_link_libraries(mozillavpn PUBLIC sentry.lib) + SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=true) + install(FILES ${EXTERNAL_INSTALL_LOCATION}/bin/sentry.dll DESTINATION .) + install(FILES ${EXTERNAL_INSTALL_LOCATION}/bin/crashpad_handler DESTINATION .) + + endif() + + include(ExternalProject) + ExternalProject_Add(sentry + GIT_REPOSITORY https://github.com/getsentry/sentry-native/ + GIT_TAG 0.5.0 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} ${SENTRY_ARGS} + ) + + target_include_directories(mozillavpn PUBLIC ${EXTERNAL_INSTALL_LOCATION}/include) + target_link_directories( mozillavpn PUBLIC ${EXTERNAL_INSTALL_LOCATION}/lib) + add_dependencies(mozillavpn sentry) +endif() + + + #target_compile_definitions(mozillavpn PRIVATE SENTRY_BUILD_STATIC) + + #target_link_libraries(mozillavpn PUBLIC crashpad_compat.lib) + #target_link_libraries(mozillavpn PUBLIC crashpad_getopt.lib) + #target_link_libraries(mozillavpn PUBLIC crashpad_handler_lib.lib) + #target_link_libraries(mozillavpn PUBLIC crashpad_minidump.lib) + #target_link_libraries(mozillavpn PUBLIC crashpad_snapshot.lib) + #target_link_libraries(mozillavpn PUBLIC crashpad_util.lib) + #target_link_libraries(mozillavpn PUBLIC crashpad_zlib.lib) \ No newline at end of file diff --git a/src/cmake/windows.cmake b/src/cmake/windows.cmake index 35f9dbf293..0275229994 100644 --- a/src/cmake/windows.cmake +++ b/src/cmake/windows.cmake @@ -12,10 +12,10 @@ set_target_properties(mozillavpn PROPERTIES # Todo: This will force the generation of a .pdb # ignoring buildmode. we need to fix the relwithdebug target # and then we can remove this :) -target_compile_options(mozillavpn - PRIVATE - $<$:/ZI> -) +#target_compile_options(mozillavpn +# PRIVATE +# $<$:/ZI>> +#) # Generate the Windows version resource file. configure_file(../windows/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc) diff --git a/src/commands/commandcrashreporter.cpp b/src/commands/commandcrashreporter.cpp index a48f89f370..e52745db50 100644 --- a/src/commands/commandcrashreporter.cpp +++ b/src/commands/commandcrashreporter.cpp @@ -6,7 +6,6 @@ #include "commandlineparser.h" #include "leakdetector.h" -#include CommandCrashReporter::CommandCrashReporter(QObject* parent) : Command(parent, "crashreporter", "Starts the crash reporter.") { @@ -19,8 +18,9 @@ CommandCrashReporter::~CommandCrashReporter() { int CommandCrashReporter::run(QStringList& tokens) { Q_UNUSED(tokens); - return CrashReporterApp::main(CommandLineParser::argc(), - CommandLineParser::argv()); + // TODO: This is currently not used, find out if we can + // integrate this into the crash flow + return 0; } static Command::RegistrationProxy s_commandCrashReporter; diff --git a/src/commands/commandui.cpp b/src/commands/commandui.cpp index b9391116f6..39ef3d85c6 100644 --- a/src/commands/commandui.cpp +++ b/src/commands/commandui.cpp @@ -65,7 +65,6 @@ #endif #ifdef MVPN_WINDOWS -# include "crashreporter/crashclient.h" # include "eventlistener.h" # include "platforms/windows/windowsstartatbootwatcher.h" # include "platforms/windows/windowsappimageprovider.h" @@ -179,9 +178,6 @@ int CommandUI::run(QStringList& tokens) { std::cerr.clear(); } # endif - - CrashClient::instance().start(CommandLineParser::argc(), - CommandLineParser::argv()); #endif #ifdef MVPN_DEBUG diff --git a/src/main.cpp b/src/main.cpp index 6898e5c886..6ecd820127 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,9 +4,9 @@ #include "commandlineparser.h" #include "leakdetector.h" -#include "sentry.h" +#include "constants.h" -#include +#include Q_DECL_EXPORT int main(int argc, char* argv[]) { #ifdef MVPN_DEBUG @@ -16,7 +16,7 @@ Q_DECL_EXPORT int main(int argc, char* argv[]) { sentry_options_t *options = sentry_options_new(); sentry_options_set_dsn(options, "https://6a476c1b57a34773a75c60036236a01d@o1396220.ingest.sentry.io/6719480"); - sentry_options_set_release(options, "my-project-name@2.3.12"); + sentry_options_set_release(options, Constants::versionString().toLocal8Bit().constData()); //sentry_options_set_debug(options, 1); sentry_init(options); diff --git a/src/mozillavpn.cpp b/src/mozillavpn.cpp index a176748c41..e7d7aa9d32 100644 --- a/src/mozillavpn.cpp +++ b/src/mozillavpn.cpp @@ -39,6 +39,7 @@ #include "tasks/sendfeedback/tasksendfeedback.h" #include "tasks/servers/taskservers.h" #include "taskscheduler.h" +#include "sentry/sentryadapter.h" #include "telemetry/gleansample.h" #include "update/updater.h" #include "update/versionapi.h" @@ -996,6 +997,7 @@ void MozillaVPN::mainWindowLoaded() { m_gleanTimer.start(Constants::gleanTimeoutMsec()); m_gleanTimer.setSingleShot(false); #endif + SentryAdapter::instance()->init(); } void MozillaVPN::telemetryPolicyCompleted() { @@ -1605,6 +1607,11 @@ void MozillaVPN::exitForUnrecoverableError(const QString& reason) { void MozillaVPN::crashTest() { logger.debug() << "Crashing Application"; + int x =0; + Controller* garbage = (Controller*)x; + garbage->activate(); + + char* text = new char[100]; delete[] text; delete[] text; diff --git a/src/sentry/dummy_sentryadapter.cpp b/src/sentry/dummy_sentryadapter.cpp new file mode 100644 index 0000000000..e41fa08fef --- /dev/null +++ b/src/sentry/dummy_sentryadapter.cpp @@ -0,0 +1,31 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "sentryadapter.h" + +#include + +namespace { +SentryAdapter* s_instance = nullptr; + +} // namespace +SentryAdapter::SentryAdapter() {} + +SentryAdapter::~SentryAdapter() {} + +SentryAdapter* SentryAdapter::instance() { + if (s_instance == nullptr) { + s_instance = new SentryAdapter(); + } + return s_instance; +} + +void SentryAdapter::init() {} + +void SentryAdapter::report(const QString& category, const QString& message, + bool attachStackTrace) { + Q_UNUSED(category); + Q_UNUSED(message); + Q_UNUSED(attachStackTrace); +} \ No newline at end of file diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp new file mode 100644 index 0000000000..351aba0336 --- /dev/null +++ b/src/sentry/sentryadapter.cpp @@ -0,0 +1,77 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "sentryadapter.h" + +#include + +#include "constants.h" +#include "loghandler.h" +#include "logger.h" +#include "settingsholder.h" +#include "mozillavpn.h" + + + +namespace { +SentryAdapter* s_instance = nullptr; +Logger logger(LOG_MAIN, "Sentry"); + +} // namespace + +SentryAdapter* SentryAdapter::instance() { + if (s_instance == nullptr) { + s_instance = new SentryAdapter(); + } + return s_instance; +} +SentryAdapter::SentryAdapter(){} +SentryAdapter::~SentryAdapter(){} + +void SentryAdapter::init() { + // Telemetry is disabled - so we should probably not send stuff + /*#if (!SettingsHolder::instance()->gleanEnabled()) { + return; + } + if (!Constants::inProduction()) { + // Let's for now restrict this to non Production + return; + }*/ + // Okay so Lets INIT + auto vpn = MozillaVPN::instance(); + auto log = LogHandler::instance(); + + connect(vpn, &MozillaVPN::aboutToQuit, this, &SentryAdapter::onBeforeShutdown); + connect(log, &LogHandler::logEntryAdded, this, &SentryAdapter::onLoglineAdded); + logger.info() << "Sentry initialised"; + + sentry_options_t *options = sentry_options_new(); + sentry_options_set_dsn(options, "https://6a476c1b57a34773a75c60036236a01d@o1396220.ingest.sentry.io/6719480"); + sentry_options_set_release(options, Constants::versionString().toLocal8Bit().constData()); + //sentry_options_set_debug(options, 1); + sentry_init(options); +} + +void SentryAdapter::report(const QString& errorType, const QString& message, + bool attachStackTrace) { + sentry_value_t event = sentry_value_new_event(); + sentry_value_t exc = sentry_value_new_exception(errorType.toLocal8Bit(), message.toLocal8Bit()); + + if(attachStackTrace){ + sentry_value_set_stacktrace(exc, NULL, 0); + } + sentry_event_add_exception(event, exc); + sentry_capture_event(event); +} + +void SentryAdapter::onBeforeShutdown() { + // Flush everything, + sentry_close(); +} + +void SentryAdapter::onLoglineAdded(const QByteArray& line) { + // Todo: we could certainly catch this more early and format the data ? + //sentry_value_t crumb = sentry_value_new_breadcrumb("Logger", line.constData()); + //sentry_add_breadcrumb(crumb); +} \ No newline at end of file diff --git a/src/sentry/sentryadapter.h b/src/sentry/sentryadapter.h new file mode 100644 index 0000000000..e3ee6c5be5 --- /dev/null +++ b/src/sentry/sentryadapter.h @@ -0,0 +1,33 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef SENTRYADAPTER_H +#define SENTRYADAPTER_H + +#include +#include + +class SentryAdapter : public QObject { + Q_OBJECT + Q_DISABLE_COPY_MOVE(SentryAdapter) + + public: + SentryAdapter(); + ~SentryAdapter(); + static SentryAdapter* instance(); + + // Inits Sentry. + // In case Telemetry is disabled this is a no-op. + void init(); + + // Reports an Error - can attach extra data and a stack trace if needed. + void report(const QString& category, const QString& message, + bool attachStackTrace = false); + + // Called when a Line is added, will add this as a breadcrumb + Q_SLOT void onLoglineAdded(const QByteArray& line); + // Called before shutdown, will flush pending events. + Q_SLOT void onBeforeShutdown(); +}; +#endif // SENTRYADAPTER_H From 5d118dc7371d963bd521c7b0ce02027bbbcced2c Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 14 Sep 2022 13:59:54 +0200 Subject: [PATCH 03/28] Fix fallback for unsupported plattforms --- src/cmake/sentry.cmake | 4 ++-- src/loghandler.cpp | 23 ----------------------- src/main.cpp | 7 ------- src/mozillavpn.cpp | 7 +------ src/sentry/dummy_sentryadapter.cpp | 15 +++++++++++++-- 5 files changed, 16 insertions(+), 40 deletions(-) diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index 72bf8146cd..7d5ace9ff2 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -15,11 +15,11 @@ include(ExternalProject) LIST(FIND SENTRY_SUPPORTED_OS MVPN_PLATFORM_NAME IS_SUPPORTED) -if( IS_SUPPORTED==-1 ) +if( IS_SUPPORTED EQUAL -1 ) # Sentry is not supported on this Plattform, let's # only include a dummy client :) target_sources(mozillavpn PRIVATE - sentry/moc_sentryadapter.cpp + sentry/dummy_sentryadapter.cpp sentry/sentryadapter.h ) diff --git a/src/loghandler.cpp b/src/loghandler.cpp index 111e6e36fe..ce1b3ba983 100644 --- a/src/loghandler.cpp +++ b/src/loghandler.cpp @@ -16,8 +16,6 @@ #include #include -#include - #ifdef MVPN_ANDROID # include #endif @@ -204,27 +202,6 @@ void LogHandler::addLog(const Log& log, const MutexLocker& proofOfLock) { emit logEntryAdded(buffer); - sentry_value_t crumb = sentry_value_new_breadcrumb("Logger", buffer.constData()); - sentry_value_set_by_key(crumb, "category", log.m_fromQT ? sentry_value_new_string("QT"): sentry_value_new_string("CLIENT")); - switch (log.m_logLevel) - { - case LogLevel::Debug: - sentry_value_set_by_key(crumb, "level", sentry_value_new_string("Debug")); - break; - case LogLevel::Error: - sentry_value_set_by_key(crumb, "level", sentry_value_new_string("Error")); - break; - case LogLevel::Info: - sentry_value_set_by_key(crumb, "level", sentry_value_new_string("Info")); - break; - case LogLevel::Warning: - sentry_value_set_by_key(crumb, "level", sentry_value_new_string("Warning")); - break; - default: - sentry_value_set_by_key(crumb, "level", sentry_value_new_string("Unknown")); - break; - } - sentry_add_breadcrumb(crumb); #if defined(MVPN_ANDROID) && defined(MVPN_DEBUG) const char* str = buffer.constData(); diff --git a/src/main.cpp b/src/main.cpp index 6ecd820127..6adcb6d66d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,9 +4,7 @@ #include "commandlineparser.h" #include "leakdetector.h" -#include "constants.h" -#include Q_DECL_EXPORT int main(int argc, char* argv[]) { #ifdef MVPN_DEBUG @@ -14,11 +12,6 @@ Q_DECL_EXPORT int main(int argc, char* argv[]) { Q_UNUSED(leakDetector); #endif - sentry_options_t *options = sentry_options_new(); - sentry_options_set_dsn(options, "https://6a476c1b57a34773a75c60036236a01d@o1396220.ingest.sentry.io/6719480"); - sentry_options_set_release(options, Constants::versionString().toLocal8Bit().constData()); - //sentry_options_set_debug(options, 1); - sentry_init(options); CommandLineParser clp; return clp.parse(argc, argv); diff --git a/src/mozillavpn.cpp b/src/mozillavpn.cpp index e7d7aa9d32..ded2fe068f 100644 --- a/src/mozillavpn.cpp +++ b/src/mozillavpn.cpp @@ -46,7 +46,7 @@ #include "urlopener.h" #include "websocket/websockethandler.h" -#include "sentry.h" + #ifdef MVPN_IOS # include "platforms/ios/iosdatamigration.h" @@ -1607,11 +1607,6 @@ void MozillaVPN::exitForUnrecoverableError(const QString& reason) { void MozillaVPN::crashTest() { logger.debug() << "Crashing Application"; - int x =0; - Controller* garbage = (Controller*)x; - garbage->activate(); - - char* text = new char[100]; delete[] text; delete[] text; diff --git a/src/sentry/dummy_sentryadapter.cpp b/src/sentry/dummy_sentryadapter.cpp index e41fa08fef..fb8e14a36d 100644 --- a/src/sentry/dummy_sentryadapter.cpp +++ b/src/sentry/dummy_sentryadapter.cpp @@ -4,10 +4,13 @@ #include "sentryadapter.h" +#include "logger.h" + #include namespace { SentryAdapter* s_instance = nullptr; +Logger logger(LOG_MAIN, "Sentry"); } // namespace SentryAdapter::SentryAdapter() {} @@ -21,11 +24,19 @@ SentryAdapter* SentryAdapter::instance() { return s_instance; } -void SentryAdapter::init() {} +void SentryAdapter::init() { + logger.debug() << "Using Dummy Sentry"; +} void SentryAdapter::report(const QString& category, const QString& message, bool attachStackTrace) { Q_UNUSED(category); Q_UNUSED(message); Q_UNUSED(attachStackTrace); -} \ No newline at end of file +} + +void SentryAdapter::onBeforeShutdown() {} + +void SentryAdapter::onLoglineAdded(const QByteArray& line) { + Q_UNUSED(line); +} \ No newline at end of file From dd2f9d8736fcc74faf0d4c1bc5e5d16872e7c59c Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 14 Sep 2022 19:57:46 +0200 Subject: [PATCH 04/28] Proper windows support --- src/CMakeLists.txt | 3 +- src/cmake/sentry.cmake | 14 +++++--- src/constants.h | 5 +++ src/mozillavpn.cpp | 7 ++++ src/sentry/sentryadapter.cpp | 62 +++++++++++++++++++++++++++++------- src/sentry/sentryadapter.h | 13 +++++++- 6 files changed, 85 insertions(+), 19 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be4f00d50c..a96f84e559 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,7 +59,8 @@ if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") target_link_libraries(mozillavpn PRIVATE crashreporter vpnglean -ldl) if (WIN32) target_link_libraries(mozillavpn PRIVATE ntdll) + set_target_properties(mozillavpn PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE") endif() endif() -qt_finalize_target(mozillavpn) \ No newline at end of file +qt_finalize_target(mozillavpn) diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index 7d5ace9ff2..704daba5db 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -7,7 +7,7 @@ # Defines which OS builds can include sentry. Check src/cmake Lists for all values of MVPN_PLATFORM_NAME -set(SENTRY_SUPPORTED_OS windows macos) +set(SENTRY_SUPPORTED_OS "windows" "macos") set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external) include(ExternalProject) @@ -15,7 +15,7 @@ include(ExternalProject) LIST(FIND SENTRY_SUPPORTED_OS MVPN_PLATFORM_NAME IS_SUPPORTED) -if( IS_SUPPORTED EQUAL -1 ) +if( $IS_SUPPORTED EQUAL -1 ) # Sentry is not supported on this Plattform, let's # only include a dummy client :) target_sources(mozillavpn PRIVATE @@ -24,6 +24,7 @@ if( IS_SUPPORTED EQUAL -1 ) ) else() + target_compile_definitions(mozillavpn PRIVATE SENTRY_ENABLED) # Sentry support is given target_sources(mozillavpn PRIVATE sentry/sentryadapter.cpp @@ -42,10 +43,13 @@ else() endif() if(WIN32) # Compile a dll for windows, as some breakpad imports will fail otherwise >:c + SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=false -D SENTRY_BACKEND=breakpad) + # Link against static sentry + breakpad + the stack unwind utils target_link_libraries(mozillavpn PUBLIC sentry.lib) - SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=true) - install(FILES ${EXTERNAL_INSTALL_LOCATION}/bin/sentry.dll DESTINATION .) - install(FILES ${EXTERNAL_INSTALL_LOCATION}/bin/crashpad_handler DESTINATION .) + target_link_libraries(mozillavpn PUBLIC breakpad_client.lib) + target_link_libraries(mozillavpn PUBLIC dbghelp.lib) + # Make sure the sentry header does not try to dll-link it :) + target_compile_definitions(mozillavpn PRIVATE SENTRY_BUILD_STATIC) endif() diff --git a/src/constants.h b/src/constants.h index 0f9eba9fc6..959fbc49d7 100644 --- a/src/constants.h +++ b/src/constants.h @@ -85,6 +85,11 @@ CONSTEXPR(uint32_t, controllerPeriodicStateRecorderMsec, 10800000, 60000, 0) #define PRODBETAEXPR(type, functionName, prod, beta) \ inline type functionName() { return inProduction() ? prod : beta; } +// TODO: Get a mozilla one - this is bastis project :) +constexpr const char* SENTRY_DER = + "https://6a476c1b57a34773a75c60036236a01d@o1396220.ingest.sentry.io/" + "6719480"; + constexpr const char* API_PRODUCTION_URL = "https://vpn.mozilla.org"; constexpr const char* API_STAGING_URL = "https://stage-vpn.guardian.nonprod.cloudops.mozgcp.net"; diff --git a/src/mozillavpn.cpp b/src/mozillavpn.cpp index ded2fe068f..0c16b69b78 100644 --- a/src/mozillavpn.cpp +++ b/src/mozillavpn.cpp @@ -1607,6 +1607,13 @@ void MozillaVPN::exitForUnrecoverableError(const QString& reason) { void MozillaVPN::crashTest() { logger.debug() << "Crashing Application"; + + unsigned char* test = NULL; + test[1000] = 'a'; //<< here it should crash + + // Interestingly this does not cause a "Signal" but a VC runtime exception + // and more interestingly, neither breakpad nor crashpad are catchting this on + // windows... char* text = new char[100]; delete[] text; delete[] text; diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp index 351aba0336..eb089e4ab7 100644 --- a/src/sentry/sentryadapter.cpp +++ b/src/sentry/sentryadapter.cpp @@ -4,6 +4,11 @@ #include "sentryadapter.h" +#ifdef MVPN_WINDOWS +// We need to define this otherwise the header will try to link to a dll spec :) + +#endif +#define SENTRY_BUILD_STATIC 1 #include #include "constants.h" @@ -12,7 +17,7 @@ #include "settingsholder.h" #include "mozillavpn.h" - +#include namespace { SentryAdapter* s_instance = nullptr; @@ -30,14 +35,10 @@ SentryAdapter::SentryAdapter(){} SentryAdapter::~SentryAdapter(){} void SentryAdapter::init() { - // Telemetry is disabled - so we should probably not send stuff - /*#if (!SettingsHolder::instance()->gleanEnabled()) { + if (Constants::inProduction()) { + // If we're not in Production let's just not enable this :) return; } - if (!Constants::inProduction()) { - // Let's for now restrict this to non Production - return; - }*/ // Okay so Lets INIT auto vpn = MozillaVPN::instance(); auto log = LogHandler::instance(); @@ -47,9 +48,22 @@ void SentryAdapter::init() { logger.info() << "Sentry initialised"; sentry_options_t *options = sentry_options_new(); - sentry_options_set_dsn(options, "https://6a476c1b57a34773a75c60036236a01d@o1396220.ingest.sentry.io/6719480"); + // The handler is a Crashpad-specific background process + auto appDatas = + QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation); + auto appLocal = appDatas.first() + "\\sentry"; + // sentry_options_set_handler_path(options, "C:/Program Files/Mozilla/Mozilla + // VPN/crashpad_handler.exe"); + sentry_options_set_dsn(options, Constants::SENTRY_DER); + sentry_options_set_environment( + options, Constants::inProduction() ? "production" : "stage"); sentry_options_set_release(options, Constants::versionString().toLocal8Bit().constData()); - //sentry_options_set_debug(options, 1); + sentry_options_set_database_path(options, appLocal.toLocal8Bit().constData()); + sentry_options_set_on_crash(options, &SentryAdapter::onCrash, NULL); + + // Leaving this for convinence, be warned, it's spammy to stdout. + // sentry_options_set_debug(options, 1); + sentry_init(options); } @@ -71,7 +85,31 @@ void SentryAdapter::onBeforeShutdown() { } void SentryAdapter::onLoglineAdded(const QByteArray& line) { - // Todo: we could certainly catch this more early and format the data ? - //sentry_value_t crumb = sentry_value_new_breadcrumb("Logger", line.constData()); - //sentry_add_breadcrumb(crumb); + // Todo: we could certainly catch this more early and format the data ? + sentry_value_t crumb = + sentry_value_new_breadcrumb("Logger", line.constData()); + sentry_add_breadcrumb(crumb); +} + +sentry_value_t SentryAdapter::onCrash( + const sentry_ucontext_t* + uctx, // provides the user-space context of the crash + sentry_value_t event, // used the same way as in `before_send` + void* closure // user-data that you can provide at configuration time +) { + logger.info() << "Sentry ON CRASH"; + // Do contextual clean-up before the crash is sent to sentry's backend + // infrastructure + bool shouldSend = true; + // Todo: We can use this callback to make sure + // we only send data with user consent. + // We could: + // -> Maybe start a new Process for the Crash-Report UI ask for consent + // -> Check if a setting "upload crashes" is present. + // If we should not send it, we can discard the crash data here :) + if (shouldSend) { + return event; + } + sentry_value_decref(event); + return sentry_value_new_null(); } \ No newline at end of file diff --git a/src/sentry/sentryadapter.h b/src/sentry/sentryadapter.h index e3ee6c5be5..af3ac9e42e 100644 --- a/src/sentry/sentryadapter.h +++ b/src/sentry/sentryadapter.h @@ -8,6 +8,10 @@ #include #include +#ifdef SENTRY_ENABLED +# include +#endif + class SentryAdapter : public QObject { Q_OBJECT Q_DISABLE_COPY_MOVE(SentryAdapter) @@ -28,6 +32,13 @@ class SentryAdapter : public QObject { // Called when a Line is added, will add this as a breadcrumb Q_SLOT void onLoglineAdded(const QByteArray& line); // Called before shutdown, will flush pending events. - Q_SLOT void onBeforeShutdown(); + Q_SLOT void onBeforeShutdown(); +#ifdef SENTRY_ENABLED + // Only define Sentry related callbacks if we have the typedefs :) + // Called before Sentry will send a crash report + static sentry_value_t onCrash(const sentry_ucontext_t* uctx, + sentry_value_t event, void* closure); + +#endif }; #endif // SENTRYADAPTER_H From d8fbfb96adbba58c9b755e5a0f783c18a11bb0db Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 14 Sep 2022 20:05:41 +0200 Subject: [PATCH 05/28] Cleanups --- src/cmake/macos.cmake | 1 - src/cmake/sentry.cmake | 10 ---------- src/cmake/windows.cmake | 8 ++++---- src/commands/commandcrashreporter.cpp | 6 +++--- src/loghandler.cpp | 3 +-- src/main.cpp | 1 - src/mozillavpn.cpp | 2 -- src/sentry/dummy_sentryadapter.cpp | 4 +--- src/sentry/sentryadapter.cpp | 7 +------ 9 files changed, 10 insertions(+), 32 deletions(-) diff --git a/src/cmake/macos.cmake b/src/cmake/macos.cmake index c1e9251b0c..913cd40dbd 100644 --- a/src/cmake/macos.cmake +++ b/src/cmake/macos.cmake @@ -127,7 +127,6 @@ osx_bundle_files(mozillavpn DESTINATION Resources/utils ) - # Install the native messaging extensions into the bundle. add_dependencies(mozillavpn mozillavpnnp) osx_bundle_files(mozillavpn FILES diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index 704daba5db..80a1cdd510 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -65,13 +65,3 @@ else() add_dependencies(mozillavpn sentry) endif() - - #target_compile_definitions(mozillavpn PRIVATE SENTRY_BUILD_STATIC) - - #target_link_libraries(mozillavpn PUBLIC crashpad_compat.lib) - #target_link_libraries(mozillavpn PUBLIC crashpad_getopt.lib) - #target_link_libraries(mozillavpn PUBLIC crashpad_handler_lib.lib) - #target_link_libraries(mozillavpn PUBLIC crashpad_minidump.lib) - #target_link_libraries(mozillavpn PUBLIC crashpad_snapshot.lib) - #target_link_libraries(mozillavpn PUBLIC crashpad_util.lib) - #target_link_libraries(mozillavpn PUBLIC crashpad_zlib.lib) \ No newline at end of file diff --git a/src/cmake/windows.cmake b/src/cmake/windows.cmake index 0275229994..e29d91678e 100644 --- a/src/cmake/windows.cmake +++ b/src/cmake/windows.cmake @@ -12,10 +12,10 @@ set_target_properties(mozillavpn PROPERTIES # Todo: This will force the generation of a .pdb # ignoring buildmode. we need to fix the relwithdebug target # and then we can remove this :) -#target_compile_options(mozillavpn -# PRIVATE -# $<$:/ZI>> -#) +target_compile_options(mozillavpn + PRIVATE + $<$:/ZI>> +) # Generate the Windows version resource file. configure_file(../windows/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc) diff --git a/src/commands/commandcrashreporter.cpp b/src/commands/commandcrashreporter.cpp index e52745db50..a48f89f370 100644 --- a/src/commands/commandcrashreporter.cpp +++ b/src/commands/commandcrashreporter.cpp @@ -6,6 +6,7 @@ #include "commandlineparser.h" #include "leakdetector.h" +#include CommandCrashReporter::CommandCrashReporter(QObject* parent) : Command(parent, "crashreporter", "Starts the crash reporter.") { @@ -18,9 +19,8 @@ CommandCrashReporter::~CommandCrashReporter() { int CommandCrashReporter::run(QStringList& tokens) { Q_UNUSED(tokens); - // TODO: This is currently not used, find out if we can - // integrate this into the crash flow - return 0; + return CrashReporterApp::main(CommandLineParser::argc(), + CommandLineParser::argv()); } static Command::RegistrationProxy s_commandCrashReporter; diff --git a/src/loghandler.cpp b/src/loghandler.cpp index ce1b3ba983..ab4acf819a 100644 --- a/src/loghandler.cpp +++ b/src/loghandler.cpp @@ -193,7 +193,7 @@ void LogHandler::addLog(const Log& log, const MutexLocker& proofOfLock) { QTextStream out(stderr); prettyOutput(out, log); } - + QByteArray buffer; { QTextStream out(&buffer); @@ -202,7 +202,6 @@ void LogHandler::addLog(const Log& log, const MutexLocker& proofOfLock) { emit logEntryAdded(buffer); - #if defined(MVPN_ANDROID) && defined(MVPN_DEBUG) const char* str = buffer.constData(); if (str) { diff --git a/src/main.cpp b/src/main.cpp index 6adcb6d66d..8f4c7cce86 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,7 +12,6 @@ Q_DECL_EXPORT int main(int argc, char* argv[]) { Q_UNUSED(leakDetector); #endif - CommandLineParser clp; return clp.parse(argc, argv); } diff --git a/src/mozillavpn.cpp b/src/mozillavpn.cpp index 0c16b69b78..2b08df9ee4 100644 --- a/src/mozillavpn.cpp +++ b/src/mozillavpn.cpp @@ -46,8 +46,6 @@ #include "urlopener.h" #include "websocket/websockethandler.h" - - #ifdef MVPN_IOS # include "platforms/ios/iosdatamigration.h" # include "platforms/ios/iosutils.h" diff --git a/src/sentry/dummy_sentryadapter.cpp b/src/sentry/dummy_sentryadapter.cpp index fb8e14a36d..277f49e3d1 100644 --- a/src/sentry/dummy_sentryadapter.cpp +++ b/src/sentry/dummy_sentryadapter.cpp @@ -37,6 +37,4 @@ void SentryAdapter::report(const QString& category, const QString& message, void SentryAdapter::onBeforeShutdown() {} -void SentryAdapter::onLoglineAdded(const QByteArray& line) { - Q_UNUSED(line); -} \ No newline at end of file +void SentryAdapter::onLoglineAdded(const QByteArray& line) { Q_UNUSED(line); } diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp index eb089e4ab7..d7d8132cba 100644 --- a/src/sentry/sentryadapter.cpp +++ b/src/sentry/sentryadapter.cpp @@ -4,11 +4,6 @@ #include "sentryadapter.h" -#ifdef MVPN_WINDOWS -// We need to define this otherwise the header will try to link to a dll spec :) - -#endif -#define SENTRY_BUILD_STATIC 1 #include #include "constants.h" @@ -112,4 +107,4 @@ sentry_value_t SentryAdapter::onCrash( } sentry_value_decref(event); return sentry_value_new_null(); -} \ No newline at end of file +} From 39b6523dc49e1db4f04d082ac4bc77495eca6faf Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 14 Sep 2022 20:07:20 +0200 Subject: [PATCH 06/28] dummy version for qmake variants --- src/qmake/sources.pri | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qmake/sources.pri b/src/qmake/sources.pri index 0388f5ee7a..ae9297c11a 100644 --- a/src/qmake/sources.pri +++ b/src/qmake/sources.pri @@ -135,6 +135,7 @@ SOURCES += \ serveri18n.cpp \ serverlatency.cpp \ settingsholder.cpp \ + sentry/dummy_sentryadapter.cpp \ signature.cpp \ simplenetworkmanager.cpp \ statusicon.cpp \ @@ -308,6 +309,7 @@ HEADERS += \ serveri18n.h \ serverlatency.h \ settingsholder.h \ + sentry/sentryadapter.h \ signature.h \ simplenetworkmanager.h \ statusicon.h \ From 7d00bf66812375ab5e3307193f3cc82f7695db9f Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 14 Sep 2022 20:09:22 +0200 Subject: [PATCH 07/28] add license --- LICENSE.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LICENSE.md b/LICENSE.md index 4257567750..a1f00498d8 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -56,6 +56,11 @@ the terms of the MIT Public License (*MIT*), a copy of which is available [available here](https://opensource.org/licenses/MIT) and a copy is provided below. +The project relies on [sentry-native](https://github.com/getsentry/sentry-native), under +the terms of the MIT Public License (*MIT*), a copy of which is available +[available here](https://opensource.org/licenses/MIT) and a copy is provided +below. + Finally, this project uses EC25519 and CHACHA-POLY implementations from [HACL\*](https://hacl-star.github.io/), available under the terms of the MIT Public License (*MIT*) and copyright (c) 2016-2020 INRIA, CMU, and Microsoft From 2493b1f8109d8d7cc0d2d5db4e72bb202af59b5a Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 14 Sep 2022 20:14:58 +0200 Subject: [PATCH 08/28] cleanup --- src/sentry/sentryadapter.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp index d7d8132cba..c7b624b4f6 100644 --- a/src/sentry/sentryadapter.cpp +++ b/src/sentry/sentryadapter.cpp @@ -47,8 +47,6 @@ void SentryAdapter::init() { auto appDatas = QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation); auto appLocal = appDatas.first() + "\\sentry"; - // sentry_options_set_handler_path(options, "C:/Program Files/Mozilla/Mozilla - // VPN/crashpad_handler.exe"); sentry_options_set_dsn(options, Constants::SENTRY_DER); sentry_options_set_environment( options, Constants::inProduction() ? "production" : "stage"); From 0e7fe2d8c1a0a12dfd41e52a300daba49b030228 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 14 Sep 2022 20:16:58 +0200 Subject: [PATCH 09/28] cleanup --- src/cmake/sentry.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index 80a1cdd510..a8a2795256 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -42,7 +42,6 @@ else() ) endif() if(WIN32) - # Compile a dll for windows, as some breakpad imports will fail otherwise >:c SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=false -D SENTRY_BACKEND=breakpad) # Link against static sentry + breakpad + the stack unwind utils target_link_libraries(mozillavpn PUBLIC sentry.lib) From dfae022cd39effbdb75e9f1217b3e6ce603ee694 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Thu, 15 Sep 2022 17:19:00 +0200 Subject: [PATCH 10/28] Address feedback --- src/cmake/sentry.cmake | 31 ++++++------ src/qmake/sources.pri | 4 +- ...ntryadapter.cpp => dummysentryadapter.cpp} | 22 ++++----- src/sentry/sentryadapter.cpp | 49 +++++++++++-------- src/sentry/sentryadapter.h | 6 ++- 5 files changed, 61 insertions(+), 51 deletions(-) rename src/sentry/{dummy_sentryadapter.cpp => dummysentryadapter.cpp} (65%) diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index a8a2795256..3af6cc84c6 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -7,28 +7,21 @@ # Defines which OS builds can include sentry. Check src/cmake Lists for all values of MVPN_PLATFORM_NAME -set(SENTRY_SUPPORTED_OS "windows" "macos") +set(SENTRY_SUPPORTED_OS "Windows" "Darwin") set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external) include(ExternalProject) -LIST(FIND SENTRY_SUPPORTED_OS MVPN_PLATFORM_NAME IS_SUPPORTED) +LIST(FIND SENTRY_SUPPORTED_OS ${CMAKE_SYSTEM_NAME} _SUPPORTED) -if( $IS_SUPPORTED EQUAL -1 ) - # Sentry is not supported on this Plattform, let's - # only include a dummy client :) - target_sources(mozillavpn PRIVATE - sentry/dummy_sentryadapter.cpp - sentry/sentryadapter.h - ) - -else() +if( ${_SUPPORTED} GREATER -1 ) + message("Building sentry for ${CMAKE_SYSTEM_NAME}") target_compile_definitions(mozillavpn PRIVATE SENTRY_ENABLED) # Sentry support is given target_sources(mozillavpn PRIVATE - sentry/sentryadapter.cpp - sentry/sentryadapter.h + sentry/sentryadapter.cpp + sentry/sentryadapter.h ) # Configure Linking and Compile @@ -62,5 +55,13 @@ else() target_include_directories(mozillavpn PUBLIC ${EXTERNAL_INSTALL_LOCATION}/include) target_link_directories( mozillavpn PUBLIC ${EXTERNAL_INSTALL_LOCATION}/lib) add_dependencies(mozillavpn sentry) -endif() - +else() + message("Sentry supported OS -> ${SENTRY_SUPPORTED_OS}") + message("Skipping building sentry for ${CMAKE_SYSTEM_NAME}") + # Sentry is not supported on this Plattform, let's + # only include a dummy client :) + target_sources(mozillavpn PRIVATE + sentry/dummysentryadapter.cpp + sentry/sentryadapter.h + ) +endif() \ No newline at end of file diff --git a/src/qmake/sources.pri b/src/qmake/sources.pri index ae9297c11a..7728b2f1a5 100644 --- a/src/qmake/sources.pri +++ b/src/qmake/sources.pri @@ -132,10 +132,10 @@ SOURCES += \ rfc/rfc4193.cpp \ rfc/rfc4291.cpp \ rfc/rfc5735.cpp \ + sentry/dummysentryadapter.cpp \ serveri18n.cpp \ serverlatency.cpp \ settingsholder.cpp \ - sentry/dummy_sentryadapter.cpp \ signature.cpp \ simplenetworkmanager.cpp \ statusicon.cpp \ @@ -306,10 +306,10 @@ HEADERS += \ rfc/rfc4193.h \ rfc/rfc4291.h \ rfc/rfc5735.h \ + sentry/sentryadapter.h \ serveri18n.h \ serverlatency.h \ settingsholder.h \ - sentry/sentryadapter.h \ signature.h \ simplenetworkmanager.h \ statusicon.h \ diff --git a/src/sentry/dummy_sentryadapter.cpp b/src/sentry/dummysentryadapter.cpp similarity index 65% rename from src/sentry/dummy_sentryadapter.cpp rename to src/sentry/dummysentryadapter.cpp index 277f49e3d1..86e25cd99c 100644 --- a/src/sentry/dummy_sentryadapter.cpp +++ b/src/sentry/dummysentryadapter.cpp @@ -4,6 +4,7 @@ #include "sentryadapter.h" +#include "leakdetector.h" #include "logger.h" #include @@ -13,20 +14,17 @@ SentryAdapter* s_instance = nullptr; Logger logger(LOG_MAIN, "Sentry"); } // namespace -SentryAdapter::SentryAdapter() {} - -SentryAdapter::~SentryAdapter() {} - -SentryAdapter* SentryAdapter::instance() { - if (s_instance == nullptr) { - s_instance = new SentryAdapter(); - } - return s_instance; +SentryAdapter::SentryAdapter() { MVPN_COUNT_CTOR(SentryAdapter); } +SentryAdapter::~SentryAdapter() { MVPN_COUNT_DTOR(SentryAdapter); } + +SentryAdapter* SentryAdapter::instance() { + if (s_instance == nullptr) { + s_instance = new SentryAdapter(); + } + return s_instance; } -void SentryAdapter::init() { - logger.debug() << "Using Dummy Sentry"; -} +void SentryAdapter::init() { logger.debug() << "Using Dummy Sentry"; } void SentryAdapter::report(const QString& category, const QString& message, bool attachStackTrace) { diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp index c7b624b4f6..dc10b308df 100644 --- a/src/sentry/sentryadapter.cpp +++ b/src/sentry/sentryadapter.cpp @@ -6,14 +6,15 @@ #include +#include + #include "constants.h" +#include "leakdetector.h" #include "loghandler.h" #include "logger.h" #include "settingsholder.h" #include "mozillavpn.h" -#include - namespace { SentryAdapter* s_instance = nullptr; Logger logger(LOG_MAIN, "Sentry"); @@ -26,8 +27,8 @@ SentryAdapter* SentryAdapter::instance() { } return s_instance; } -SentryAdapter::SentryAdapter(){} -SentryAdapter::~SentryAdapter(){} +SentryAdapter::SentryAdapter() { MVPN_COUNT_CTOR(SentryAdapter); } +SentryAdapter::~SentryAdapter() { MVPN_COUNT_DTOR(SentryAdapter); } void SentryAdapter::init() { if (Constants::inProduction()) { @@ -37,35 +38,43 @@ void SentryAdapter::init() { // Okay so Lets INIT auto vpn = MozillaVPN::instance(); auto log = LogHandler::instance(); - - connect(vpn, &MozillaVPN::aboutToQuit, this, &SentryAdapter::onBeforeShutdown); - connect(log, &LogHandler::logEntryAdded, this, &SentryAdapter::onLoglineAdded); - logger.info() << "Sentry initialised"; - sentry_options_t *options = sentry_options_new(); - // The handler is a Crashpad-specific background process - auto appDatas = - QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation); - auto appLocal = appDatas.first() + "\\sentry"; + QDir dataDir( + QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)); + QString sentryFolder = dataDir.absoluteFilePath("sentry"); + + connect(vpn, &MozillaVPN::aboutToQuit, this, + &SentryAdapter::onBeforeShutdown); + connect(log, &LogHandler::logEntryAdded, this, + &SentryAdapter::onLoglineAdded); + + sentry_options_t* options = sentry_options_new(); sentry_options_set_dsn(options, Constants::SENTRY_DER); sentry_options_set_environment( options, Constants::inProduction() ? "production" : "stage"); - sentry_options_set_release(options, Constants::versionString().toLocal8Bit().constData()); - sentry_options_set_database_path(options, appLocal.toLocal8Bit().constData()); + sentry_options_set_release( + options, Constants::versionString().toLocal8Bit().constData()); + sentry_options_set_database_path(options, + sentryFolder.toLocal8Bit().constData()); sentry_options_set_on_crash(options, &SentryAdapter::onCrash, NULL); // Leaving this for convinence, be warned, it's spammy to stdout. // sentry_options_set_debug(options, 1); - sentry_init(options); + if (sentry_init(options) == -1) { + logger.error() << "Sentry failed to init!"; + return; + }; + logger.info() << "Sentry initialised"; } void SentryAdapter::report(const QString& errorType, const QString& message, bool attachStackTrace) { sentry_value_t event = sentry_value_new_event(); - sentry_value_t exc = sentry_value_new_exception(errorType.toLocal8Bit(), message.toLocal8Bit()); + sentry_value_t exc = sentry_value_new_exception(errorType.toLocal8Bit(), + message.toLocal8Bit()); - if(attachStackTrace){ + if (attachStackTrace) { sentry_value_set_stacktrace(exc, NULL, 0); } sentry_event_add_exception(event, exc); @@ -73,8 +82,8 @@ void SentryAdapter::report(const QString& errorType, const QString& message, } void SentryAdapter::onBeforeShutdown() { - // Flush everything, - sentry_close(); + // Flush everything, + sentry_close(); } void SentryAdapter::onLoglineAdded(const QByteArray& line) { diff --git a/src/sentry/sentryadapter.h b/src/sentry/sentryadapter.h index af3ac9e42e..9ad7aeee26 100644 --- a/src/sentry/sentryadapter.h +++ b/src/sentry/sentryadapter.h @@ -12,12 +12,11 @@ # include #endif -class SentryAdapter : public QObject { +class SentryAdapter final : public QObject { Q_OBJECT Q_DISABLE_COPY_MOVE(SentryAdapter) public: - SentryAdapter(); ~SentryAdapter(); static SentryAdapter* instance(); @@ -40,5 +39,8 @@ class SentryAdapter : public QObject { sentry_value_t event, void* closure); #endif + + private: + SentryAdapter(); }; #endif // SENTRYADAPTER_H From 3ca44c310c6f11fd0dcb90b593f7dad59cdb191c Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Thu, 15 Sep 2022 18:01:54 +0200 Subject: [PATCH 11/28] add mit license --- LICENSE.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/LICENSE.md b/LICENSE.md index a1f00498d8..f0b35884dd 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1442,3 +1442,28 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + +The MIT License (MIT) - sentry-native +================================= + +Copyright (c) 2019 Sentry (https://sentry.io) and individual contributors. +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From d6c0a951bde3df645de68c9634f0ce7f8d3b3d46 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Tue, 20 Sep 2022 13:33:21 +0200 Subject: [PATCH 12/28] Fix Lib importing ? --- src/cmake/sentry.cmake | 2 +- taskcluster/scripts/fetch/enter_dev_shell.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index 3af6cc84c6..adfa4e0b86 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -35,7 +35,7 @@ if( ${_SUPPORTED} GREATER -1 ) ) endif() if(WIN32) - SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=false -D SENTRY_BACKEND=breakpad) + SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=false -D SENTRY_BACKEND=breakpad -DCMAKE_BUILD_TYPE=Release) # Link against static sentry + breakpad + the stack unwind utils target_link_libraries(mozillavpn PUBLIC sentry.lib) target_link_libraries(mozillavpn PUBLIC breakpad_client.lib) diff --git a/taskcluster/scripts/fetch/enter_dev_shell.ps1 b/taskcluster/scripts/fetch/enter_dev_shell.ps1 index 242b00ec4d..39e4fd4cf3 100644 --- a/taskcluster/scripts/fetch/enter_dev_shell.ps1 +++ b/taskcluster/scripts/fetch/enter_dev_shell.ps1 @@ -28,8 +28,8 @@ ForEach-Object -InputObject $INCLUDE_ADDS { } $LIB_ADDS = ` - "$W10_SDK_PATH\lib\$W10_SDK_VERSION\ucrt\x64;" ,` - "$W10_SDK_PATH\lib\$W10_SDK_VERSION\um\x64;" ,` + "$W10_SDK_PATH\Lib\$W10_SDK_VERSION\ucrt\x64;" ,` + "$W10_SDK_PATH\Lib\$W10_SDK_VERSION\um\x64;" ,` "$VS_STUDIO_LOCATION\VC\Tools\MSVC\$MSVC_VERSION\ATLMFC\lib\x64;" ,` "$VS_STUDIO_LOCATION\VC\Tools\MSVC\$MSVC_VERSION\lib\x64;" ,` "$VS_STUDIO_LOCATION\DIA SDK\lib\amd64;" From 31a86e6524d8266596efec9c1ea1615286ad5146 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Tue, 20 Sep 2022 13:57:24 +0200 Subject: [PATCH 13/28] Check init state before reporting stuff --- src/sentry/sentryadapter.cpp | 7 +++++++ src/sentry/sentryadapter.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp index dc10b308df..f4ecce3c3b 100644 --- a/src/sentry/sentryadapter.cpp +++ b/src/sentry/sentryadapter.cpp @@ -65,11 +65,15 @@ void SentryAdapter::init() { logger.error() << "Sentry failed to init!"; return; }; + m_initialized = true; logger.info() << "Sentry initialised"; } void SentryAdapter::report(const QString& errorType, const QString& message, bool attachStackTrace) { + if (!m_initialized) { + return; + } sentry_value_t event = sentry_value_new_event(); sentry_value_t exc = sentry_value_new_exception(errorType.toLocal8Bit(), message.toLocal8Bit()); @@ -87,6 +91,9 @@ void SentryAdapter::onBeforeShutdown() { } void SentryAdapter::onLoglineAdded(const QByteArray& line) { + if (!m_initialized) { + return; + } // Todo: we could certainly catch this more early and format the data ? sentry_value_t crumb = sentry_value_new_breadcrumb("Logger", line.constData()); diff --git a/src/sentry/sentryadapter.h b/src/sentry/sentryadapter.h index 9ad7aeee26..42fc4fae40 100644 --- a/src/sentry/sentryadapter.h +++ b/src/sentry/sentryadapter.h @@ -41,6 +41,7 @@ class SentryAdapter final : public QObject { #endif private: + m_initialized = false; SentryAdapter(); }; #endif // SENTRYADAPTER_H From a1ab039cdadcc199a1db4cfc01769662813343d3 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Mon, 14 Nov 2022 17:37:47 +0100 Subject: [PATCH 14/28] add subdir --- .gitmodules | 3 +++ 3rdparty/sentry | 1 + src/cmake/macos.cmake | 16 ++++++++-------- src/cmake/sentry.cmake | 3 +++ src/sentry/sentryadapter.h | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) create mode 160000 3rdparty/sentry diff --git a/.gitmodules b/.gitmodules index e153814d57..f0ef8848b9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -29,3 +29,6 @@ path = 3rdparty/glean url = https://github.com/mozilla/glean.git branch = main +[submodule "3rdparty/sentry"] + path = 3rdparty/sentry + url = https://github.com/getsentry/sentry-native/ diff --git a/3rdparty/sentry b/3rdparty/sentry new file mode 160000 index 0000000000..87e67ad783 --- /dev/null +++ b/3rdparty/sentry @@ -0,0 +1 @@ +Subproject commit 87e67ad783a7ec4476b0eb4742bd40fe5a1e2435 diff --git a/src/cmake/macos.cmake b/src/cmake/macos.cmake index 913cd40dbd..c1ed6d15fc 100644 --- a/src/cmake/macos.cmake +++ b/src/cmake/macos.cmake @@ -90,14 +90,14 @@ include(cmake/golang.cmake) include(cmake/signature.cmake) # Enable Balrog for update support. -add_definitions(-DMVPN_BALROG) -add_go_library(balrog ../balrog/balrog-api.go - CGO_CFLAGS -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}) -target_link_libraries(mozillavpn PRIVATE balrog) -target_sources(mozillavpn PRIVATE - update/balrog.cpp - update/balrog.h -) +# add_definitions(-DMVPN_BALROG) +# add_go_library(balrog ../balrog/balrog-api.go +# CGO_CFLAGS -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}) +# target_link_libraries(mozillavpn PRIVATE balrog) +# target_sources(mozillavpn PRIVATE +# update/balrog.cpp +# update/balrog.h +# ) # Perform codesigning. execute_process( diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index adfa4e0b86..9c9e6a0c77 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -26,8 +26,10 @@ if( ${_SUPPORTED} GREATER -1 ) # Configure Linking and Compile if(APPLE) + include(cmake/osxtools.cmake) # Compile Static for apple and link to libsentry.a target_link_libraries(mozillavpn PUBLIC libsentry.a) + # Force compiling for all architectures so i can sleep at night. SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=false) osx_bundle_files(mozillavpn FILES ${CMAKE_BINARY_DIR}/external/bin/crashpad_handler @@ -47,6 +49,7 @@ if( ${_SUPPORTED} GREATER -1 ) include(ExternalProject) ExternalProject_Add(sentry + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}../../3rdparty/sentry GIT_REPOSITORY https://github.com/getsentry/sentry-native/ GIT_TAG 0.5.0 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} ${SENTRY_ARGS} diff --git a/src/sentry/sentryadapter.h b/src/sentry/sentryadapter.h index 42fc4fae40..52e3c000f4 100644 --- a/src/sentry/sentryadapter.h +++ b/src/sentry/sentryadapter.h @@ -41,7 +41,7 @@ class SentryAdapter final : public QObject { #endif private: - m_initialized = false; + bool m_initialized = false; SentryAdapter(); }; #endif // SENTRYADAPTER_H From 138ff485d00b3420c4a1413f2b16826c855d39f7 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 16 Nov 2022 14:30:42 +0100 Subject: [PATCH 15/28] Fix OSX build woes --- src/cmake/sentry.cmake | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index 9c9e6a0c77..e762c73dd8 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -27,24 +27,26 @@ if( ${_SUPPORTED} GREATER -1 ) # Configure Linking and Compile if(APPLE) include(cmake/osxtools.cmake) + # Let sentry.h know we are using a static build + target_compile_definitions(mozillavpn PRIVATE SENTRY_BUILD_STATIC) + # Let mozilla-vpn know we need to provide the upload client + target_compile_definitions(mozillavpn PRIVATE SENTRY_NONE_TRANSPORT) # Compile Static for apple and link to libsentry.a target_link_libraries(mozillavpn PUBLIC libsentry.a) - # Force compiling for all architectures so i can sleep at night. - SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=false) - osx_bundle_files(mozillavpn - FILES ${CMAKE_BINARY_DIR}/external/bin/crashpad_handler - DESTINATION MacOS - ) + target_link_libraries(mozillavpn PUBLIC breakpad_client.a) + # We are using breakpad as a backend - in process stackwalking is never the best option ... however! + # this is super easy to link against and we do not need another binary shipped with the client. + SET(SENTRY_ARGS -DSENTRY_BACKEND=breakpad -DSENTRY_BUILD_SHARED_LIBS=false -DSENTRY_TRANSPORT=none) endif() if(WIN32) - SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=false -D SENTRY_BACKEND=breakpad -DCMAKE_BUILD_TYPE=Release) + # Let sentry.h know we are using a static build + target_compile_definitions(mozillavpn PRIVATE SENTRY_BUILD_STATIC) # Link against static sentry + breakpad + the stack unwind utils target_link_libraries(mozillavpn PUBLIC sentry.lib) target_link_libraries(mozillavpn PUBLIC breakpad_client.lib) target_link_libraries(mozillavpn PUBLIC dbghelp.lib) - # Make sure the sentry header does not try to dll-link it :) - target_compile_definitions(mozillavpn PRIVATE SENTRY_BUILD_STATIC) - + # Windows will use the winhttp transport btw + SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=false -DSENTRY_BACKEND=breakpad -DCMAKE_BUILD_TYPE=Release) endif() include(ExternalProject) From 60d5e100fdd0dd45b1290925ca757d3dced99abe Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 16 Nov 2022 18:01:17 +0100 Subject: [PATCH 16/28] Add android support to the supported list --- src/cmake/sentry.cmake | 35 ++++++++++++++++++++++++++---- src/constants.h | 3 +++ src/networkrequest.cpp | 13 +++++++++++ src/networkrequest.h | 5 +++++ src/sentry/sentryadapter.cpp | 35 ++++++++++++++++++++++++++++++ src/sentry/sentryadapter.h | 5 +++++ src/tasks/sentry/tasksentry.cpp | 38 +++++++++++++++++++++++++++++++++ src/tasks/sentry/tasksentry.h | 27 +++++++++++++++++++++++ 8 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 src/tasks/sentry/tasksentry.cpp create mode 100644 src/tasks/sentry/tasksentry.h diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index e762c73dd8..d116bc7e36 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -7,7 +7,7 @@ # Defines which OS builds can include sentry. Check src/cmake Lists for all values of MVPN_PLATFORM_NAME -set(SENTRY_SUPPORTED_OS "Windows" "Darwin") +set(SENTRY_SUPPORTED_OS "Windows" "Darwin" "Android") set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external) include(ExternalProject) @@ -20,8 +20,8 @@ if( ${_SUPPORTED} GREATER -1 ) target_compile_definitions(mozillavpn PRIVATE SENTRY_ENABLED) # Sentry support is given target_sources(mozillavpn PRIVATE - sentry/sentryadapter.cpp - sentry/sentryadapter.h + sentry/sentryadapter.cpp + sentry/sentryadapter.h ) # Configure Linking and Compile @@ -49,6 +49,26 @@ if( ${_SUPPORTED} GREATER -1 ) SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=false -DSENTRY_BACKEND=breakpad -DCMAKE_BUILD_TYPE=Release) endif() + if(ANDROID) + # Let sentry.h know we are using a static build + #target_compile_definitions(mozillavpn PRIVATE SENTRY_BUILD_STATIC) + # Let mozilla-vpn know we need to provide the upload client + target_compile_definitions(mozillavpn PRIVATE SENTRY_NONE_TRANSPORT) + # Due to ndk + + target_link_libraries(mozillavpn PUBLIC libsentry.a) + target_link_libraries(mozillavpn PUBLIC libunwindstack.a) + # We can only use inproc as crash backend. + SET(SENTRY_ARGS -DSENTRY_BUILD_SHARED_LIBS=false + -DANDROID_PLATFORM=21 + -DCMAKE_SYSTEM_NAME=Android + -DANDROID_ABI=${ANDROID_ABI} + -DCMAKE_ANDROID_NDK=${ANDROID_NDK_ROOT} + -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake + -DSENTRY_BACKEND=inproc + ) + endif() + include(ExternalProject) ExternalProject_Add(sentry SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}../../3rdparty/sentry @@ -69,4 +89,11 @@ else() sentry/dummysentryadapter.cpp sentry/sentryadapter.h ) -endif() \ No newline at end of file +endif() + + +# Add Sources that will be required anyway +target_sources(mozillavpn PRIVATE + tasks/sentry/tasksentry.cpp + tasks/sentry/tasksentry.h +) \ No newline at end of file diff --git a/src/constants.h b/src/constants.h index 959fbc49d7..fb97e03546 100644 --- a/src/constants.h +++ b/src/constants.h @@ -89,6 +89,9 @@ CONSTEXPR(uint32_t, controllerPeriodicStateRecorderMsec, 10800000, 60000, 0) constexpr const char* SENTRY_DER = "https://6a476c1b57a34773a75c60036236a01d@o1396220.ingest.sentry.io/" "6719480"; +constexpr const char* SENTRY_ENVELOPE_INGESTION = + "https://o1396220.ingest.sentry.io/api/6719480/envelope/"; + constexpr const char* API_PRODUCTION_URL = "https://vpn.mozilla.org"; constexpr const char* API_STAGING_URL = diff --git a/src/networkrequest.cpp b/src/networkrequest.cpp index cf49d7d484..bc8303c10d 100644 --- a/src/networkrequest.cpp +++ b/src/networkrequest.cpp @@ -831,6 +831,19 @@ NetworkRequest* NetworkRequest::createForFxaSessionDestroy( return r; } +// static +NetworkRequest* NetworkRequest::createForSentry(Task* parent, + const QByteArray& envelope) { + NetworkRequest* r = new NetworkRequest(parent, 200, false); + QUrl url(Constants::SENTRY_ENVELOPE_INGESTION); + r->m_request.setUrl(url); + r->m_request.setHeader(QNetworkRequest::ContentTypeHeader, + "application/x-sentry-envelope"); + r->m_request.setRawHeader("dsn", Constants::SENTRY_DER); + r->postRequest(envelope); + return r; +} + NetworkRequest* NetworkRequest::createForProducts(Task* parent) { Q_ASSERT(parent); diff --git a/src/networkrequest.h b/src/networkrequest.h index 3c4f295c16..0e991eb7c3 100644 --- a/src/networkrequest.h +++ b/src/networkrequest.h @@ -137,6 +137,11 @@ class NetworkRequest final : public QObject { static NetworkRequest* createForFxaSessionDestroy( Task* parent, const QByteArray& sessionToken); + + static NetworkRequest* createForSentry(Task* parent, + const QByteArray& envelope); + + static NetworkRequest* createForProducts(Task* parent); diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp index f4ecce3c3b..c8b8b248e7 100644 --- a/src/sentry/sentryadapter.cpp +++ b/src/sentry/sentryadapter.cpp @@ -13,11 +13,14 @@ #include "loghandler.h" #include "logger.h" #include "settingsholder.h" +#include "tasks/sentry/tasksentry.h" +#include "taskscheduler.h" #include "mozillavpn.h" namespace { SentryAdapter* s_instance = nullptr; Logger logger(LOG_MAIN, "Sentry"); +void* transport_state = 0; } // namespace @@ -58,6 +61,13 @@ void SentryAdapter::init() { sentryFolder.toLocal8Bit().constData()); sentry_options_set_on_crash(options, &SentryAdapter::onCrash, NULL); +#ifdef SENTRY_NONE_TRANSPORT + sentry_transport_t* transport = + sentry_transport_new(&SentryAdapter::transportEnvelope); + sentry_transport_set_state(transport, transport_state); + sentry_options_set_transport(options, transport); +#endif + // Leaving this for convinence, be warned, it's spammy to stdout. // sentry_options_set_debug(options, 1); @@ -122,3 +132,28 @@ sentry_value_t SentryAdapter::onCrash( sentry_value_decref(event); return sentry_value_new_null(); } + +// static +void SentryAdapter::transportEnvelope(sentry_envelope_t* envelope, + void* state) { + /* + * Send the event here. If the transport requires state, such as an HTTP + * client object or request queue, it can be specified in the `state` + * parameter when configuring the transport. It will be passed as second + * argument to this function. + * The transport takes ownership of the `envelope`, and must free it once it + * is done. + */ + Q_UNUSED(state); + size_t sentry_buf_size = 0; + char* sentry_buf = sentry_envelope_serialize(envelope, &sentry_buf_size); + + // Qt Will copy this. + auto qt_owned_buffer = QByteArray(sentry_buf, sentry_buf_size); + // We can now free the stuff. + sentry_envelope_free(envelope); + sentry_free(sentry_buf); + + auto t = new TaskSentry(qt_owned_buffer); + TaskScheduler::scheduleTask(t); +} \ No newline at end of file diff --git a/src/sentry/sentryadapter.h b/src/sentry/sentryadapter.h index 52e3c000f4..43ba5abd63 100644 --- a/src/sentry/sentryadapter.h +++ b/src/sentry/sentryadapter.h @@ -38,6 +38,11 @@ class SentryAdapter final : public QObject { static sentry_value_t onCrash(const sentry_ucontext_t* uctx, sentry_value_t event, void* closure); + // Will be used if NONE_TRANSPORT is enabled + // in that case this will be called if the client has a + // report to send to Sentry. + static void transportEnvelope(sentry_envelope_t* envelope, void* state); + #endif private: diff --git a/src/tasks/sentry/tasksentry.cpp b/src/tasks/sentry/tasksentry.cpp new file mode 100644 index 0000000000..3445dcaa44 --- /dev/null +++ b/src/tasks/sentry/tasksentry.cpp @@ -0,0 +1,38 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "tasksentry.h" +#include "errorhandler.h" +#include "leakdetector.h" +#include "logger.h" +#include "mozillavpn.h" +#include "networkrequest.h" + +namespace { +Logger logger(LOG_MAIN, "TaskSentry"); +} + +TaskSentry::TaskSentry(const QByteArray& envelope) : Task("TaskSentry") { + MVPN_COUNT_CTOR(TaskSentry); + m_envelope = envelope; +} + +TaskSentry::~TaskSentry() { MVPN_COUNT_DTOR(TaskSentry); } + +void TaskSentry::run() { + NetworkRequest* request = NetworkRequest::createForSentry(this, m_envelope); + + connect(request, &NetworkRequest::requestFailed, this, + [this](QNetworkReply::NetworkError error, const QByteArray&) { + Q_UNUSED(error); + logger.error() << "Failed to send envelope"; + emit completed(); + }); + connect(request, &NetworkRequest::requestCompleted, this, + [this](const QByteArray& data) { + Q_UNUSED(data); + logger.debug() << "Sentry sent events"; + emit completed(); + }); +} \ No newline at end of file diff --git a/src/tasks/sentry/tasksentry.h b/src/tasks/sentry/tasksentry.h new file mode 100644 index 0000000000..cdaeebbfc3 --- /dev/null +++ b/src/tasks/sentry/tasksentry.h @@ -0,0 +1,27 @@ + +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef TASKSENTRY_H +#define TASKSENTRY_H + +#include "task.h" + +#include +#include + +class TaskSentry final : public Task { + Q_DISABLE_COPY_MOVE(TaskSentry) + + public: + TaskSentry(const QByteArray& envelope); + ~TaskSentry(); + + void run() override; + + private: + QByteArray m_envelope; +}; + +#endif // TASKSENTRY_H \ No newline at end of file From d3d5126ba8c41069f5837cf2f1880fbea3e19581 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 16 Nov 2022 18:02:59 +0100 Subject: [PATCH 17/28] Remove unused variable --- src/sentry/sentryadapter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp index c8b8b248e7..1f25018e63 100644 --- a/src/sentry/sentryadapter.cpp +++ b/src/sentry/sentryadapter.cpp @@ -20,7 +20,6 @@ namespace { SentryAdapter* s_instance = nullptr; Logger logger(LOG_MAIN, "Sentry"); -void* transport_state = 0; } // namespace @@ -64,7 +63,7 @@ void SentryAdapter::init() { #ifdef SENTRY_NONE_TRANSPORT sentry_transport_t* transport = sentry_transport_new(&SentryAdapter::transportEnvelope); - sentry_transport_set_state(transport, transport_state); + sentry_transport_set_state(transport, nullptr); sentry_options_set_transport(options, transport); #endif From b279b6216eec65d44eceda7d6576f08e6050f477 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 16 Nov 2022 18:07:00 +0100 Subject: [PATCH 18/28] Pr cleanups --- src/cmake/macos.cmake | 16 ++++++++-------- src/cmake/sentry.cmake | 3 --- src/cmake/windows.cmake | 2 +- src/main.cpp | 1 - src/networkrequest.h | 2 -- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/cmake/macos.cmake b/src/cmake/macos.cmake index c1ed6d15fc..913cd40dbd 100644 --- a/src/cmake/macos.cmake +++ b/src/cmake/macos.cmake @@ -90,14 +90,14 @@ include(cmake/golang.cmake) include(cmake/signature.cmake) # Enable Balrog for update support. -# add_definitions(-DMVPN_BALROG) -# add_go_library(balrog ../balrog/balrog-api.go -# CGO_CFLAGS -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}) -# target_link_libraries(mozillavpn PRIVATE balrog) -# target_sources(mozillavpn PRIVATE -# update/balrog.cpp -# update/balrog.h -# ) +add_definitions(-DMVPN_BALROG) +add_go_library(balrog ../balrog/balrog-api.go + CGO_CFLAGS -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}) +target_link_libraries(mozillavpn PRIVATE balrog) +target_sources(mozillavpn PRIVATE + update/balrog.cpp + update/balrog.h +) # Perform codesigning. execute_process( diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index d116bc7e36..6e829bb49c 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -50,11 +50,8 @@ if( ${_SUPPORTED} GREATER -1 ) endif() if(ANDROID) - # Let sentry.h know we are using a static build - #target_compile_definitions(mozillavpn PRIVATE SENTRY_BUILD_STATIC) # Let mozilla-vpn know we need to provide the upload client target_compile_definitions(mozillavpn PRIVATE SENTRY_NONE_TRANSPORT) - # Due to ndk target_link_libraries(mozillavpn PUBLIC libsentry.a) target_link_libraries(mozillavpn PUBLIC libunwindstack.a) diff --git a/src/cmake/windows.cmake b/src/cmake/windows.cmake index e29d91678e..35f9dbf293 100644 --- a/src/cmake/windows.cmake +++ b/src/cmake/windows.cmake @@ -14,7 +14,7 @@ set_target_properties(mozillavpn PROPERTIES # and then we can remove this :) target_compile_options(mozillavpn PRIVATE - $<$:/ZI>> + $<$:/ZI> ) # Generate the Windows version resource file. diff --git a/src/main.cpp b/src/main.cpp index 8f4c7cce86..40ea4155f6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,6 @@ #include "commandlineparser.h" #include "leakdetector.h" - Q_DECL_EXPORT int main(int argc, char* argv[]) { #ifdef MVPN_DEBUG LeakDetector leakDetector; diff --git a/src/networkrequest.h b/src/networkrequest.h index 0e991eb7c3..21f6aff4b7 100644 --- a/src/networkrequest.h +++ b/src/networkrequest.h @@ -141,8 +141,6 @@ class NetworkRequest final : public QObject { static NetworkRequest* createForSentry(Task* parent, const QByteArray& envelope); - - static NetworkRequest* createForProducts(Task* parent); #ifdef MVPN_IOS From 5d480e2e4975b24e07d32f4d5ef4095282bff142 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 16 Nov 2022 19:04:20 +0100 Subject: [PATCH 19/28] Remove: dummysentry --- src/cmake/sentry.cmake | 10 ++------ src/mozillavpn.cpp | 7 +++++- src/sentry/dummysentryadapter.cpp | 38 ------------------------------- src/sentry/sentryadapter.h | 7 ++---- 4 files changed, 10 insertions(+), 52 deletions(-) delete mode 100644 src/sentry/dummysentryadapter.cpp diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index 6e829bb49c..488d7d37ef 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -78,17 +78,11 @@ if( ${_SUPPORTED} GREATER -1 ) target_link_directories( mozillavpn PUBLIC ${EXTERNAL_INSTALL_LOCATION}/lib) add_dependencies(mozillavpn sentry) else() + # Sentry is not supported on this Plattform. message("Sentry supported OS -> ${SENTRY_SUPPORTED_OS}") - message("Skipping building sentry for ${CMAKE_SYSTEM_NAME}") - # Sentry is not supported on this Plattform, let's - # only include a dummy client :) - target_sources(mozillavpn PRIVATE - sentry/dummysentryadapter.cpp - sentry/sentryadapter.h - ) + message("Cannot build sentry for ${CMAKE_SYSTEM_NAME}") endif() - # Add Sources that will be required anyway target_sources(mozillavpn PRIVATE tasks/sentry/tasksentry.cpp diff --git a/src/mozillavpn.cpp b/src/mozillavpn.cpp index 2b08df9ee4..d6d2de9df0 100644 --- a/src/mozillavpn.cpp +++ b/src/mozillavpn.cpp @@ -39,13 +39,16 @@ #include "tasks/sendfeedback/tasksendfeedback.h" #include "tasks/servers/taskservers.h" #include "taskscheduler.h" -#include "sentry/sentryadapter.h" #include "telemetry/gleansample.h" #include "update/updater.h" #include "update/versionapi.h" #include "urlopener.h" #include "websocket/websockethandler.h" +#ifdef SENTRY_ENABLED + #include "sentry/sentryadapter.h" +#endif + #ifdef MVPN_IOS # include "platforms/ios/iosdatamigration.h" # include "platforms/ios/iosutils.h" @@ -995,7 +998,9 @@ void MozillaVPN::mainWindowLoaded() { m_gleanTimer.start(Constants::gleanTimeoutMsec()); m_gleanTimer.setSingleShot(false); #endif +#ifdef SENTRY_ENABLED SentryAdapter::instance()->init(); +#endif } void MozillaVPN::telemetryPolicyCompleted() { diff --git a/src/sentry/dummysentryadapter.cpp b/src/sentry/dummysentryadapter.cpp deleted file mode 100644 index 86e25cd99c..0000000000 --- a/src/sentry/dummysentryadapter.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "sentryadapter.h" - -#include "leakdetector.h" -#include "logger.h" - -#include - -namespace { -SentryAdapter* s_instance = nullptr; -Logger logger(LOG_MAIN, "Sentry"); - -} // namespace -SentryAdapter::SentryAdapter() { MVPN_COUNT_CTOR(SentryAdapter); } -SentryAdapter::~SentryAdapter() { MVPN_COUNT_DTOR(SentryAdapter); } - -SentryAdapter* SentryAdapter::instance() { - if (s_instance == nullptr) { - s_instance = new SentryAdapter(); - } - return s_instance; -} - -void SentryAdapter::init() { logger.debug() << "Using Dummy Sentry"; } - -void SentryAdapter::report(const QString& category, const QString& message, - bool attachStackTrace) { - Q_UNUSED(category); - Q_UNUSED(message); - Q_UNUSED(attachStackTrace); -} - -void SentryAdapter::onBeforeShutdown() {} - -void SentryAdapter::onLoglineAdded(const QByteArray& line) { Q_UNUSED(line); } diff --git a/src/sentry/sentryadapter.h b/src/sentry/sentryadapter.h index 43ba5abd63..e5fcf6be76 100644 --- a/src/sentry/sentryadapter.h +++ b/src/sentry/sentryadapter.h @@ -8,9 +8,7 @@ #include #include -#ifdef SENTRY_ENABLED -# include -#endif +#include class SentryAdapter final : public QObject { Q_OBJECT @@ -32,7 +30,7 @@ class SentryAdapter final : public QObject { Q_SLOT void onLoglineAdded(const QByteArray& line); // Called before shutdown, will flush pending events. Q_SLOT void onBeforeShutdown(); -#ifdef SENTRY_ENABLED + // Only define Sentry related callbacks if we have the typedefs :) // Called before Sentry will send a crash report static sentry_value_t onCrash(const sentry_ucontext_t* uctx, @@ -43,7 +41,6 @@ class SentryAdapter final : public QObject { // report to send to Sentry. static void transportEnvelope(sentry_envelope_t* envelope, void* state); -#endif private: bool m_initialized = false; From 60e95cec2992cf4a5ed8b725275cbca42e264a8c Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Thu, 17 Nov 2022 13:55:03 +0100 Subject: [PATCH 20/28] Review feedback things --- src/constants.h | 1 - src/featureslist.h | 8 +++++ src/qmake/sources.pri | 2 -- src/sentry/sentryadapter.cpp | 38 +++++++------------- src/sentry/sentryadapter.h | 70 ++++++++++++++++++++++++++++++------ 5 files changed, 80 insertions(+), 39 deletions(-) diff --git a/src/constants.h b/src/constants.h index fb97e03546..3db20c8220 100644 --- a/src/constants.h +++ b/src/constants.h @@ -92,7 +92,6 @@ constexpr const char* SENTRY_DER = constexpr const char* SENTRY_ENVELOPE_INGESTION = "https://o1396220.ingest.sentry.io/api/6719480/envelope/"; - constexpr const char* API_PRODUCTION_URL = "https://vpn.mozilla.org"; constexpr const char* API_STAGING_URL = "https://stage-vpn.guardian.nonprod.cloudops.mozgcp.net"; diff --git a/src/featureslist.h b/src/featureslist.h index 7786f27d86..645a5427e1 100644 --- a/src/featureslist.h +++ b/src/featureslist.h @@ -240,3 +240,11 @@ FEATURE_SIMPLE(gleanRust, // Feature ID FeatureCallback_true, // Can be flipped off QStringList(), // feature dependencies FeatureCallback_false) + +FEATURE_SIMPLE(sentry, // Feature ID + "Sentry Crash Report SDK", // Feature name + "2.13.0", // released + FeatureCallback_false, // Can be flipped on + FeatureCallback_false, // Can be flipped off + QStringList(), // feature dependencies + FeatureCallback_inStaging) diff --git a/src/qmake/sources.pri b/src/qmake/sources.pri index 7728b2f1a5..0388f5ee7a 100644 --- a/src/qmake/sources.pri +++ b/src/qmake/sources.pri @@ -132,7 +132,6 @@ SOURCES += \ rfc/rfc4193.cpp \ rfc/rfc4291.cpp \ rfc/rfc5735.cpp \ - sentry/dummysentryadapter.cpp \ serveri18n.cpp \ serverlatency.cpp \ settingsholder.cpp \ @@ -306,7 +305,6 @@ HEADERS += \ rfc/rfc4193.h \ rfc/rfc4291.h \ rfc/rfc5735.h \ - sentry/sentryadapter.h \ serveri18n.h \ serverlatency.h \ settingsholder.h \ diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp index 1f25018e63..423e042946 100644 --- a/src/sentry/sentryadapter.cpp +++ b/src/sentry/sentryadapter.cpp @@ -9,6 +9,7 @@ #include #include "constants.h" +#include "models/feature.h" #include "leakdetector.h" #include "loghandler.h" #include "logger.h" @@ -33,11 +34,9 @@ SentryAdapter::SentryAdapter() { MVPN_COUNT_CTOR(SentryAdapter); } SentryAdapter::~SentryAdapter() { MVPN_COUNT_DTOR(SentryAdapter); } void SentryAdapter::init() { - if (Constants::inProduction()) { - // If we're not in Production let's just not enable this :) + if (!Feature::get(Feature::Feature_sentry)->isSupported()) { return; } - // Okay so Lets INIT auto vpn = MozillaVPN::instance(); auto log = LogHandler::instance(); @@ -67,7 +66,8 @@ void SentryAdapter::init() { sentry_options_set_transport(options, transport); #endif - // Leaving this for convinence, be warned, it's spammy to stdout. + // Uncomment the following line for debugging purposes. + // Be warned, it's spammy to stdout. // sentry_options_set_debug(options, 1); if (sentry_init(options) == -1) { @@ -75,7 +75,7 @@ void SentryAdapter::init() { return; }; m_initialized = true; - logger.info() << "Sentry initialised"; + logger.info() << "Sentry initialized"; } void SentryAdapter::report(const QString& errorType, const QString& message, @@ -94,35 +94,31 @@ void SentryAdapter::report(const QString& errorType, const QString& message, sentry_capture_event(event); } -void SentryAdapter::onBeforeShutdown() { - // Flush everything, - sentry_close(); -} +void SentryAdapter::onBeforeShutdown() { sentry_close(); } void SentryAdapter::onLoglineAdded(const QByteArray& line) { if (!m_initialized) { return; } // Todo: we could certainly catch this more early and format the data ? + // (VPN-3276) sentry_value_t crumb = sentry_value_new_breadcrumb("Logger", line.constData()); sentry_add_breadcrumb(crumb); } -sentry_value_t SentryAdapter::onCrash( - const sentry_ucontext_t* - uctx, // provides the user-space context of the crash - sentry_value_t event, // used the same way as in `before_send` - void* closure // user-data that you can provide at configuration time -) { +sentry_value_t SentryAdapter::onCrash(const sentry_ucontext_t* uctx, + sentry_value_t event, void* closure) { logger.info() << "Sentry ON CRASH"; // Do contextual clean-up before the crash is sent to sentry's backend // infrastructure bool shouldSend = true; // Todo: We can use this callback to make sure // we only send data with user consent. + // Tracked in: VPN-3158 // We could: // -> Maybe start a new Process for the Crash-Report UI ask for consent + // (VPN-2823) // -> Check if a setting "upload crashes" is present. // If we should not send it, we can discard the crash data here :) if (shouldSend) { @@ -135,24 +131,16 @@ sentry_value_t SentryAdapter::onCrash( // static void SentryAdapter::transportEnvelope(sentry_envelope_t* envelope, void* state) { - /* - * Send the event here. If the transport requires state, such as an HTTP - * client object or request queue, it can be specified in the `state` - * parameter when configuring the transport. It will be passed as second - * argument to this function. - * The transport takes ownership of the `envelope`, and must free it once it - * is done. - */ Q_UNUSED(state); size_t sentry_buf_size = 0; char* sentry_buf = sentry_envelope_serialize(envelope, &sentry_buf_size); // Qt Will copy this. auto qt_owned_buffer = QByteArray(sentry_buf, sentry_buf_size); - // We can now free the stuff. + // We can now free the envelope. sentry_envelope_free(envelope); sentry_free(sentry_buf); auto t = new TaskSentry(qt_owned_buffer); TaskScheduler::scheduleTask(t); -} \ No newline at end of file +} diff --git a/src/sentry/sentryadapter.h b/src/sentry/sentryadapter.h index e5fcf6be76..b976358f60 100644 --- a/src/sentry/sentryadapter.h +++ b/src/sentry/sentryadapter.h @@ -18,30 +18,78 @@ class SentryAdapter final : public QObject { ~SentryAdapter(); static SentryAdapter* instance(); - // Inits Sentry. - // In case Telemetry is disabled this is a no-op. + /** + * @brief Inits Sentry. + * + * This is a no-op if the client is in production mode. + */ void init(); - // Reports an Error - can attach extra data and a stack trace if needed. + /** + * @brief Sends an "Issue" report to Sentry + * + * @param category - "Category" of the error, any String is valid. + * @param message - Additional message content. + * @param attachStackTrace - If true a stacktrace for later debugging will be + * attached. + */ void report(const QString& category, const QString& message, bool attachStackTrace = false); - // Called when a Line is added, will add this as a breadcrumb + /** + * @brief Event Slot for when a log-line is added. + * + * The logline will be added as a Sentry-Breadrumb, so that + * the next "report" or crash will have the last few + * loglines available + * + * @param line - UTF-8 encoded bytes of the logline. + */ Q_SLOT void onLoglineAdded(const QByteArray& line); - // Called before shutdown, will flush pending events. + + /** + * @brief Event Slot for when the client is about to Shut down + * + * This will call sentry to wrap up - this might cause new network requests + * or drisk writes. + * After calling this, any call to sentry is UB. + */ Q_SLOT void onBeforeShutdown(); - // Only define Sentry related callbacks if we have the typedefs :) - // Called before Sentry will send a crash report + /** + * @brief Callback for when sentry's backend recieved a crash. + * + * In this function we can decide to either send, discard the crash + * and additonally "scrub" the minidump of data, if wanted. + * + * @param uctx provides the user-space context of the crash + * @param event used the same way as in `before_send` + * @param closure user-data that you can provide at configuration time + * (we'dont.) + * @return either the @param event or null_sentry_value , if the crash event + * should not be recorded. + */ static sentry_value_t onCrash(const sentry_ucontext_t* uctx, sentry_value_t event, void* closure); - // Will be used if NONE_TRANSPORT is enabled - // in that case this will be called if the client has a - // report to send to Sentry. + /** + * @brief Send's a Sentry Event "envelope" to the Sentry endpoint. + * + * Will be used if NONE_TRANSPORT is enabled in cmake. + * Will create a Task in the TaskSheudler to send that. + * + * @param envelope Envelope to be sent to sentry. + * The transport takes ownership of the `envelope`, and must free it once it + * is done. + * @param state + * If the transport requires state, such as an HTTP + * client object or request queue, it can be specified in the `state` + * parameter when configuring the transport. It will be passed as second + * argument to this function. We are not using that. + * + */ static void transportEnvelope(sentry_envelope_t* envelope, void* state); - private: bool m_initialized = false; SentryAdapter(); From 46dd85943f5dbaaf229db2287514e284c73b7d56 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Thu, 17 Nov 2022 14:58:12 +0100 Subject: [PATCH 21/28] WIP: Fix submodules? --- .github/workflows/functional_tests.yaml | 9 ++------ .github/workflows/linters.yaml | 9 ++------ .github/workflows/test_unit.yaml | 28 ++++++------------------- .github/workflows/wasm.yaml | 9 ++------ src/featureslist.h | 6 +++--- src/mozillavpn.cpp | 2 +- src/networkrequest.h | 4 ++-- 7 files changed, 18 insertions(+), 49 deletions(-) diff --git a/.github/workflows/functional_tests.yaml b/.github/workflows/functional_tests.yaml index b7035b9ed7..4d0f270fb7 100644 --- a/.github/workflows/functional_tests.yaml +++ b/.github/workflows/functional_tests.yaml @@ -23,13 +23,8 @@ jobs: steps: - name: Clone repository uses: actions/checkout@v3 - - - name: Checkout submodules - shell: bash - run: | - auth_header="$(git config --local --get http.https://github.com/.extraheader)" - git submodule sync --recursive - git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + with: + submodules: 'true' - name: Install dependecies if: steps.cache-build.outputs.cache-hit != 'true' run: | diff --git a/.github/workflows/linters.yaml b/.github/workflows/linters.yaml index 7a71a4a7cc..efccc49c81 100644 --- a/.github/workflows/linters.yaml +++ b/.github/workflows/linters.yaml @@ -22,13 +22,8 @@ jobs: - name: Clone repository uses: actions/checkout@v3 - - - name: Checkout submodules - shell: bash - run: | - auth_header="$(git config --local --get http.https://github.com/.extraheader)" - git submodule sync --recursive - git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + with: + submodules: 'true' - name: Set up Python 3 uses: actions/setup-python@v3 diff --git a/.github/workflows/test_unit.yaml b/.github/workflows/test_unit.yaml index b2715135cd..6beef21176 100644 --- a/.github/workflows/test_unit.yaml +++ b/.github/workflows/test_unit.yaml @@ -23,6 +23,8 @@ jobs: steps: - name: Clone repository uses: actions/checkout@v3 + with: + submodules: 'true' - name: Install dependences run: | @@ -32,13 +34,6 @@ jobs: python3 -m pip install aqtinstall aqt install-qt --outputdir /opt linux desktop $QTVERSION gcc_64 -m all - - name: Checkout submodules - shell: bash - run: | - auth_header="$(git config --local --get http.https://github.com/.extraheader)" - git submodule sync --recursive - git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 - - name: Cache grcov id: cache-grcov uses: actions/cache@v3 @@ -96,14 +91,8 @@ jobs: steps: - name: Clone repository uses: actions/checkout@v3 - - - name: Checkout submodules - shell: bash - run: | - auth_header="$(git config --local --get http.https://github.com/.extraheader)" - git submodule sync --recursive - git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 - + with: + submodules: 'true' - name: Install python dependencies shell: bash run: | @@ -177,13 +166,8 @@ jobs: steps: - name: Clone repository uses: actions/checkout@v3 - - - name: Checkout submodules - shell: bash - run: | - auth_header="$(git config --local --get http.https://github.com/.extraheader)" - git submodule sync --recursive - git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + with: + submodules: 'true' - name: Install Qt shell: bash diff --git a/.github/workflows/wasm.yaml b/.github/workflows/wasm.yaml index dd228296eb..d6f4237890 100644 --- a/.github/workflows/wasm.yaml +++ b/.github/workflows/wasm.yaml @@ -26,13 +26,8 @@ jobs: steps: - name: Clone repository uses: actions/checkout@v3 - - - name: Checkout submodules - shell: bash - run: | - auth_header="$(git config --local --get http.https://github.com/.extraheader)" - git submodule sync --recursive - git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + with: + submodules: 'true' - name: Install Qt shell: bash diff --git a/src/featureslist.h b/src/featureslist.h index 645a5427e1..d70bd5c3f5 100644 --- a/src/featureslist.h +++ b/src/featureslist.h @@ -243,8 +243,8 @@ FEATURE_SIMPLE(gleanRust, // Feature ID FEATURE_SIMPLE(sentry, // Feature ID "Sentry Crash Report SDK", // Feature name - "2.13.0", // released - FeatureCallback_false, // Can be flipped on - FeatureCallback_false, // Can be flipped off + "2.12.0", // released + FeatureCallback_true, // Can be flipped on + FeatureCallback_true, // Can be flipped off QStringList(), // feature dependencies FeatureCallback_inStaging) diff --git a/src/mozillavpn.cpp b/src/mozillavpn.cpp index d6d2de9df0..d2bdece29f 100644 --- a/src/mozillavpn.cpp +++ b/src/mozillavpn.cpp @@ -46,7 +46,7 @@ #include "websocket/websockethandler.h" #ifdef SENTRY_ENABLED - #include "sentry/sentryadapter.h" +# include "sentry/sentryadapter.h" #endif #ifdef MVPN_IOS diff --git a/src/networkrequest.h b/src/networkrequest.h index 21f6aff4b7..011c851cd2 100644 --- a/src/networkrequest.h +++ b/src/networkrequest.h @@ -137,9 +137,9 @@ class NetworkRequest final : public QObject { static NetworkRequest* createForFxaSessionDestroy( Task* parent, const QByteArray& sessionToken); - + static NetworkRequest* createForSentry(Task* parent, - const QByteArray& envelope); + const QByteArray& envelope); static NetworkRequest* createForProducts(Task* parent); From 2c87cb0ba6f940aef690c4ba72c4f19a97875880 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Tue, 22 Nov 2022 16:06:52 +0100 Subject: [PATCH 22/28] Load Sentry config from Cmake Arguments --- scripts/android/cmake.sh | 4 ++++ src/constants.h | 14 ++++++++------ src/networkrequest.cpp | 2 +- src/sentry/sentryadapter.cpp | 7 ++++++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/scripts/android/cmake.sh b/scripts/android/cmake.sh index 08aede711d..b0fb4dd48b 100755 --- a/scripts/android/cmake.sh +++ b/scripts/android/cmake.sh @@ -145,6 +145,8 @@ if [[ "$RELEASE" ]]; then -DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \ -DCMAKE_BUILD_TYPE=Release \ -DADJUST_TOKEN=$ADJUST_SDK_TOKEN \ + -DSENTRY_DSN=$SENTRY_DSN \ + -DSENTRY_ENVELOPE_ENDPOINT=$SENTRY_ENVELOPE_ENDPOINT \ -S . -B .tmp/ else printn Y "Use debug config \n" @@ -154,6 +156,8 @@ else -DANDROID_NDK_ROOT=$ANDROID_NDK_ROOT \ -DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \ -DCMAKE_BUILD_TYPE=Debug \ + -DSENTRY_DSN=$SENTRY_DSN \ + -DSENTRY_ENVELOPE_ENDPOINT=$SENTRY_ENVELOPE_ENDPOINT \ -S . -B .tmp/ fi diff --git a/src/constants.h b/src/constants.h index 3db20c8220..84e8ebf2bc 100644 --- a/src/constants.h +++ b/src/constants.h @@ -85,12 +85,14 @@ CONSTEXPR(uint32_t, controllerPeriodicStateRecorderMsec, 10800000, 60000, 0) #define PRODBETAEXPR(type, functionName, prod, beta) \ inline type functionName() { return inProduction() ? prod : beta; } -// TODO: Get a mozilla one - this is bastis project :) -constexpr const char* SENTRY_DER = - "https://6a476c1b57a34773a75c60036236a01d@o1396220.ingest.sentry.io/" - "6719480"; -constexpr const char* SENTRY_ENVELOPE_INGESTION = - "https://o1396220.ingest.sentry.io/api/6719480/envelope/"; +#ifdef SENTRY_ENABLED + constexpr const char* SENTRY_DSN_ENDPOINT = SENTRY_DSN; + constexpr const char* SENTRY_ENVELOPE_INGESTION = SENTRY_ENVELOPE_ENDPOINT; +#else + constexpr const char* SENTRY_DSN_ENDPOINT = ""; + constexpr const char* SENTRY_ENVELOPE_INGESTION = ""; +#endif + constexpr const char* API_PRODUCTION_URL = "https://vpn.mozilla.org"; constexpr const char* API_STAGING_URL = diff --git a/src/networkrequest.cpp b/src/networkrequest.cpp index bc8303c10d..07cb2ea5ea 100644 --- a/src/networkrequest.cpp +++ b/src/networkrequest.cpp @@ -839,7 +839,7 @@ NetworkRequest* NetworkRequest::createForSentry(Task* parent, r->m_request.setUrl(url); r->m_request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-sentry-envelope"); - r->m_request.setRawHeader("dsn", Constants::SENTRY_DER); + r->m_request.setRawHeader("dsn", Constants::SENTRY_DSN_ENDPOINT); r->postRequest(envelope); return r; } diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp index 423e042946..60002ccc79 100644 --- a/src/sentry/sentryadapter.cpp +++ b/src/sentry/sentryadapter.cpp @@ -37,6 +37,11 @@ void SentryAdapter::init() { if (!Feature::get(Feature::Feature_sentry)->isSupported()) { return; } + if ( QString(Constants::SENTRY_DSN_ENDPOINT).isEmpty() || QString(Constants::SENTRY_ENVELOPE_INGESTION).isEmpty() ){ + logger.error() << "Sentry failed to init, no sentry config present"; + return; + } + auto vpn = MozillaVPN::instance(); auto log = LogHandler::instance(); @@ -50,7 +55,7 @@ void SentryAdapter::init() { &SentryAdapter::onLoglineAdded); sentry_options_t* options = sentry_options_new(); - sentry_options_set_dsn(options, Constants::SENTRY_DER); + sentry_options_set_dsn(options, Constants::SENTRY_DSN_ENDPOINT); sentry_options_set_environment( options, Constants::inProduction() ? "production" : "stage"); sentry_options_set_release( From 25b3023286f2a927696c54ca1607ca8e75b910bd Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Tue, 22 Nov 2022 18:42:21 +0100 Subject: [PATCH 23/28] Remove android 32 bit support --- src/cmake/sentry.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index 488d7d37ef..cc811976f0 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -15,6 +15,14 @@ include(ExternalProject) LIST(FIND SENTRY_SUPPORTED_OS ${CMAKE_SYSTEM_NAME} _SUPPORTED) +## Remove support for android 32bit. +## It's currently broken. see: VPN-3332 +if( CMAKE_ANDROID_ARCH STREQUAL "x86" ) + set( _SUPPORTED -1) +elseif( CMAKE_ANDROID_ARCH STREQUAL "arm" ) + set( _SUPPORTED -1) +endif() + if( ${_SUPPORTED} GREATER -1 ) message("Building sentry for ${CMAKE_SYSTEM_NAME}") target_compile_definitions(mozillavpn PRIVATE SENTRY_ENABLED) From 1bfe91ac44205f6f0c55f252a581e5341ffd74dc Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Tue, 22 Nov 2022 18:46:31 +0100 Subject: [PATCH 24/28] assert stuff exists during release builds --- src/cmake/sentry.cmake | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index cc811976f0..518ae35878 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -15,6 +15,26 @@ include(ExternalProject) LIST(FIND SENTRY_SUPPORTED_OS ${CMAKE_SYSTEM_NAME} _SUPPORTED) +## _SUPPORTED Now is either -1 if the OS is not in the +## Let's make sure +if( ${_SUPPORTED} GREATER -1 + AND ${CMAKE_BUILD_TYPE} STREQUAL "Release") + if(NOT SENTRY_DSN ) + message( FATAL_ERROR "SENTRY_DSN cannot be empty for release builds") + endif() + if(NOT SENTRY_ENVELOPE_ENDPOINT) + message( FATAL_ERROR "SENTRY_ENVELOPE_ENDPOINT cannot be empty for release builds") + endif() +else() + # If we're not in release mode + # and one of them is not defined, force disable it. + if(NOT SENTRY_DSN OR NOT SENTRY_ENVELOPE_ENDPOINT) + message( "Disabling Sentry, as params are not given") + set( _SUPPORTED -1) + endif() +endif() + + ## Remove support for android 32bit. ## It's currently broken. see: VPN-3332 if( CMAKE_ANDROID_ARCH STREQUAL "x86" ) @@ -23,8 +43,13 @@ elseif( CMAKE_ANDROID_ARCH STREQUAL "arm" ) set( _SUPPORTED -1) endif() + + if( ${_SUPPORTED} GREATER -1 ) + message("Building sentry for ${CMAKE_SYSTEM_NAME}") + target_compile_definitions(mozillavpn PRIVATE SENTRY_ENVELOPE_ENDPOINT="${SENTRY_ENVELOPE_ENDPOINT}") + target_compile_definitions(mozillavpn PRIVATE SENTRY_DSN="${SENTRY_DSN}") target_compile_definitions(mozillavpn PRIVATE SENTRY_ENABLED) # Sentry support is given target_sources(mozillavpn PRIVATE @@ -44,7 +69,7 @@ if( ${_SUPPORTED} GREATER -1 ) target_link_libraries(mozillavpn PUBLIC breakpad_client.a) # We are using breakpad as a backend - in process stackwalking is never the best option ... however! # this is super easy to link against and we do not need another binary shipped with the client. - SET(SENTRY_ARGS -DSENTRY_BACKEND=breakpad -DSENTRY_BUILD_SHARED_LIBS=false -DSENTRY_TRANSPORT=none) + SET(SENTRY_ARGS -DSENTRY_BACKEND=breakpad -DSENTRY_BUILD_SHARED_LIBS=false -DSENTRY_TRANSPORT=none -DSENTRY_BUILD_TESTS=off -DSENTRY_BUILD_EXAMPLES=off) endif() if(WIN32) # Let sentry.h know we are using a static build From 891a0f96aebaca61dfda5ec50b06dec55f03125d Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Tue, 22 Nov 2022 19:18:05 +0100 Subject: [PATCH 25/28] just disable sentry if the key's are not given --- src/cmake/sentry.cmake | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/cmake/sentry.cmake b/src/cmake/sentry.cmake index 518ae35878..4d59c2bffe 100644 --- a/src/cmake/sentry.cmake +++ b/src/cmake/sentry.cmake @@ -15,26 +15,13 @@ include(ExternalProject) LIST(FIND SENTRY_SUPPORTED_OS ${CMAKE_SYSTEM_NAME} _SUPPORTED) -## _SUPPORTED Now is either -1 if the OS is not in the -## Let's make sure -if( ${_SUPPORTED} GREATER -1 - AND ${CMAKE_BUILD_TYPE} STREQUAL "Release") - if(NOT SENTRY_DSN ) - message( FATAL_ERROR "SENTRY_DSN cannot be empty for release builds") - endif() - if(NOT SENTRY_ENVELOPE_ENDPOINT) - message( FATAL_ERROR "SENTRY_ENVELOPE_ENDPOINT cannot be empty for release builds") - endif() -else() - # If we're not in release mode - # and one of them is not defined, force disable it. - if(NOT SENTRY_DSN OR NOT SENTRY_ENVELOPE_ENDPOINT) - message( "Disabling Sentry, as params are not given") - set( _SUPPORTED -1) - endif() +if(NOT SENTRY_DSN OR NOT SENTRY_ENVELOPE_ENDPOINT) +message( "Disabling Sentry, as params are not given") +set( _SUPPORTED -1) endif() + ## Remove support for android 32bit. ## It's currently broken. see: VPN-3332 if( CMAKE_ANDROID_ARCH STREQUAL "x86" ) @@ -43,10 +30,7 @@ elseif( CMAKE_ANDROID_ARCH STREQUAL "arm" ) set( _SUPPORTED -1) endif() - - if( ${_SUPPORTED} GREATER -1 ) - message("Building sentry for ${CMAKE_SYSTEM_NAME}") target_compile_definitions(mozillavpn PRIVATE SENTRY_ENVELOPE_ENDPOINT="${SENTRY_ENVELOPE_ENDPOINT}") target_compile_definitions(mozillavpn PRIVATE SENTRY_DSN="${SENTRY_DSN}") From 9b52e6381f81f41de3d906aa3f962de479689ac8 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Tue, 22 Nov 2022 19:21:52 +0100 Subject: [PATCH 26/28] linting --- src/constants.h | 11 +++++------ src/sentry/sentryadapter.cpp | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/constants.h b/src/constants.h index 84e8ebf2bc..98c95fd4c2 100644 --- a/src/constants.h +++ b/src/constants.h @@ -86,14 +86,13 @@ CONSTEXPR(uint32_t, controllerPeriodicStateRecorderMsec, 10800000, 60000, 0) inline type functionName() { return inProduction() ? prod : beta; } #ifdef SENTRY_ENABLED - constexpr const char* SENTRY_DSN_ENDPOINT = SENTRY_DSN; - constexpr const char* SENTRY_ENVELOPE_INGESTION = SENTRY_ENVELOPE_ENDPOINT; -#else - constexpr const char* SENTRY_DSN_ENDPOINT = ""; - constexpr const char* SENTRY_ENVELOPE_INGESTION = ""; +constexpr const char* SENTRY_DSN_ENDPOINT = SENTRY_DSN; +constexpr const char* SENTRY_ENVELOPE_INGESTION = SENTRY_ENVELOPE_ENDPOINT; +#else +constexpr const char* SENTRY_DSN_ENDPOINT = ""; +constexpr const char* SENTRY_ENVELOPE_INGESTION = ""; #endif - constexpr const char* API_PRODUCTION_URL = "https://vpn.mozilla.org"; constexpr const char* API_STAGING_URL = "https://stage-vpn.guardian.nonprod.cloudops.mozgcp.net"; diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp index 60002ccc79..226989a89c 100644 --- a/src/sentry/sentryadapter.cpp +++ b/src/sentry/sentryadapter.cpp @@ -37,7 +37,8 @@ void SentryAdapter::init() { if (!Feature::get(Feature::Feature_sentry)->isSupported()) { return; } - if ( QString(Constants::SENTRY_DSN_ENDPOINT).isEmpty() || QString(Constants::SENTRY_ENVELOPE_INGESTION).isEmpty() ){ + if (QString(Constants::SENTRY_DSN_ENDPOINT).isEmpty() || + QString(Constants::SENTRY_ENVELOPE_INGESTION).isEmpty()) { logger.error() << "Sentry failed to init, no sentry config present"; return; } From c4ff6a2fc16190de15eb34fa2aa9a36685b80a1b Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Tue, 22 Nov 2022 20:44:12 +0100 Subject: [PATCH 27/28] Fix addons --- .github/workflows/gh_pages.yaml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/gh_pages.yaml b/.github/workflows/gh_pages.yaml index d005d59ce7..6373bb3ae5 100644 --- a/.github/workflows/gh_pages.yaml +++ b/.github/workflows/gh_pages.yaml @@ -81,13 +81,8 @@ jobs: steps: - name: Clone repository uses: actions/checkout@v3 - - - name: Checkout submodules - shell: bash - run: | - auth_header="$(git config --local --get http.https://github.com/.extraheader)" - git submodule sync --recursive - git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + with: + submodules: 'true' - name: Install Qt shell: bash From 21664dbd86b12d7058959458743d142b6523fe4c Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 23 Nov 2022 14:08:54 +0100 Subject: [PATCH 28/28] remove console fix for windows --- src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a96f84e559..8295383c2d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,7 +59,6 @@ if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") target_link_libraries(mozillavpn PRIVATE crashreporter vpnglean -ldl) if (WIN32) target_link_libraries(mozillavpn PRIVATE ntdll) - set_target_properties(mozillavpn PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE") endif() endif()