Skip to content

Commit

Permalink
Added error reporting for E2EE issues.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Dec 11, 2023
1 parent 17f47ce commit 7fb3a29
Show file tree
Hide file tree
Showing 23 changed files with 837 additions and 548 deletions.
2 changes: 1 addition & 1 deletion src/gui/tray/NCBusyIndicator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ BusyIndicator {

RotationAnimator {
target: contentImage
running: false
running: root.running
onRunningChanged: contentImage.rotation = 0
from: 0
to: 360
Expand Down
7 changes: 6 additions & 1 deletion src/libsync/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ set(libsync_SRCS
clientproxy.cpp
clientstatusreporting.h
clientstatusreporting.cpp
clientstatusreportingcommon.h
clientstatusreportingcommon.cpp
clientstatusreportingdatabase.h
clientstatusreportingdatabase.cpp
clientstatusreportingnetwork.h
clientstatusreportingnetwork.cpp
clientstatusreportingrecord.h
clientstatusreportingrecord.cpp
cookiejar.h
cookiejar.cpp
discovery.h
Expand Down
10 changes: 4 additions & 6 deletions src/libsync/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,17 @@ void Account::setPushNotificationsReconnectInterval(int interval)

void Account::trySetupClientStatusReporting()
{
if (_capabilities.isClientStatusReportingEnabled()) {
if (!_clientStatusReporting) {
_clientStatusReporting.reset(new ClientStatusReporting(this));
}
if (!_capabilities.isClientStatusReportingEnabled()) {
_clientStatusReporting.reset();
return;
}

if (!_clientStatusReporting) {
_clientStatusReporting.reset();
_clientStatusReporting = std::make_unique<ClientStatusReporting>(this);
}
}

void Account::reportClientStatus(const ClientStatusReporting::Status status)
void Account::reportClientStatus(const ClientStatusReportingStatus status) const
{
if (_clientStatusReporting) {
_clientStatusReporting->reportClientStatus(status);
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/account.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class OWNCLOUDSYNC_EXPORT Account : public QObject

void trySetupClientStatusReporting();

void reportClientStatus(const ClientStatusReporting::Status status);
void reportClientStatus(const ClientStatusReportingStatus status) const;

[[nodiscard]] std::shared_ptr<UserStatusConnector> userStatusConnector() const;

Expand Down Expand Up @@ -444,7 +444,7 @@ private slots:

PushNotifications *_pushNotifications = nullptr;

QScopedPointer<ClientStatusReporting> _clientStatusReporting;
std::unique_ptr<ClientStatusReporting> _clientStatusReporting;

std::shared_ptr<UserStatusConnector> _userStatusConnector;

Expand Down
9 changes: 9 additions & 0 deletions src/libsync/clientsideencryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,7 @@ bool ClientSideEncryption::sensitiveDataRemaining() const
void ClientSideEncryption::failedToInitialize(const AccountPtr &account)
{
forgetSensitiveData(account);
account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
Q_EMIT initializationFinished();
}

Expand Down Expand Up @@ -1775,6 +1776,7 @@ void FolderMetadata::setupExistingMetadata(const QByteArray& metadata)

if (metadataKeys.isEmpty()) {
qCDebug(lcCse()) << "Could not migrate. No metadata keys found!";
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
return;
}

Expand All @@ -1787,6 +1789,7 @@ void FolderMetadata::setupExistingMetadata(const QByteArray& metadata)

if (_metadataKey.isEmpty()) {
qCDebug(lcCse()) << "Could not setup existing metadata with missing metadataKeys!";
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
return;
}

Expand Down Expand Up @@ -1861,6 +1864,7 @@ void FolderMetadata::setupExistingMetadata(const QByteArray& metadata)
} else {
_metadataKey.clear();
_files.clear();
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
return;
}
}
Expand Down Expand Up @@ -1899,6 +1903,7 @@ QByteArray FolderMetadata::decryptData(const QByteArray &data) const
if (decryptResult.isEmpty())
{
qCDebug(lcCse()) << "ERROR. Could not decrypt the metadata key";
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
return {};
}
return QByteArray::fromBase64(decryptResult);
Expand All @@ -1916,6 +1921,7 @@ QByteArray FolderMetadata::decryptDataUsingKey(const QByteArray &data,
if (decryptResult.isEmpty())
{
qCDebug(lcCse()) << "ERROR. Could not decrypt";
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
return {};
}

Expand Down Expand Up @@ -1979,6 +1985,7 @@ QByteArray FolderMetadata::encryptedMetadata() const {

if (_metadataKey.isEmpty()) {
qCDebug(lcCse) << "Metadata generation failed! Empty metadata key!";
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
return {};
}
const auto version = _account->capabilities().clientSideEncryptionVersion();
Expand All @@ -2000,6 +2007,7 @@ QByteArray FolderMetadata::encryptedMetadata() const {

QString encryptedEncrypted = encryptJsonObject(encryptedDoc.toJson(QJsonDocument::Compact), _metadataKey);
if (encryptedEncrypted.isEmpty()) {
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
qCDebug(lcCse) << "Metadata generation failed!";
}
QJsonObject file;
Expand Down Expand Up @@ -2087,6 +2095,7 @@ bool FolderMetadata::moveFromFileDropToFiles()

if (decryptedKey.isEmpty() || decryptedAuthenticationTag.isEmpty() || decryptedInitializationVector.isEmpty()) {
qCDebug(lcCseMetadata) << "failed to decrypt filedrop entry" << it.key();
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
continue;
}

Expand Down
Loading

0 comments on commit 7fb3a29

Please sign in to comment.