mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
fix(logs): makes encryption logs more useful
errors should use warning level not so useful logs should not be info loevel or should not exists Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
parent
84740fca81
commit
5248ac1117
@ -1956,6 +1956,11 @@ std::pair<QByteArray, PKey> ClientSideEncryption::generateCSR(const AccountPtr &
|
||||
});
|
||||
|
||||
ret = X509_REQ_set_version(x509_req, nVersion);
|
||||
if (ret != 1) {
|
||||
const auto errorCode = ERR_get_error();
|
||||
qCWarning(lcCse()) << "Error setting the version on the certificate signing request" << nVersion << ret << ERR_lib_error_string(errorCode) << ERR_reason_error_string(errorCode);
|
||||
return {result, std::move(keyPair)};
|
||||
}
|
||||
|
||||
// 3. set subject of x509 req
|
||||
auto x509_name = X509_REQ_get_subject_name(x509_req);
|
||||
|
||||
@ -57,7 +57,6 @@ FolderMetadata::FolderMetadata(AccountPtr account, const QString &remoteFolderRo
|
||||
_isRootEncryptedFolder(folderType == FolderType::Root)
|
||||
{
|
||||
Q_ASSERT(!_remoteFolderRoot.isEmpty());
|
||||
qCInfo(lcCseMetadata()) << "Setting up an Empty Metadata";
|
||||
initEmptyMetadata();
|
||||
}
|
||||
|
||||
@ -81,7 +80,7 @@ FolderMetadata::FolderMetadata(AccountPtr account,
|
||||
setupVersionFromExistingMetadata(metadata);
|
||||
|
||||
const auto doc = QJsonDocument::fromJson(metadata);
|
||||
qCInfo(lcCseMetadata()) << doc.toJson(QJsonDocument::Compact);
|
||||
qCDebug(lcCseMetadata()) << doc.toJson(QJsonDocument::Compact);
|
||||
if (!_isRootEncryptedFolder
|
||||
&& !rootEncryptedFolderInfo.keysSet()
|
||||
&& !rootEncryptedFolderInfo.path.isEmpty()) {
|
||||
@ -94,12 +93,11 @@ FolderMetadata::FolderMetadata(AccountPtr account,
|
||||
void FolderMetadata::initMetadata()
|
||||
{
|
||||
if (_initialMetadata.isEmpty()) {
|
||||
qCInfo(lcCseMetadata()) << "Setting up empty metadata";
|
||||
initEmptyMetadata();
|
||||
return;
|
||||
}
|
||||
|
||||
qCInfo(lcCseMetadata()) << "Setting up existing metadata";
|
||||
qCDebug(lcCseMetadata()) << "Setting up existing metadata";
|
||||
setupExistingMetadata(_initialMetadata);
|
||||
|
||||
if (metadataKeyForDecryption().isEmpty() || metadataKeyForEncryption().isEmpty()) {
|
||||
@ -173,7 +171,7 @@ void FolderMetadata::setupExistingMetadata(const QByteArray &metadata)
|
||||
}
|
||||
|
||||
if (_initialSignature.isEmpty()) {
|
||||
qCDebug(lcCseMetadata()) << "Signature is empty";
|
||||
qCWarning(lcCseMetadata()) << "Signature is empty";
|
||||
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
|
||||
return;
|
||||
}
|
||||
@ -340,8 +338,7 @@ void FolderMetadata::setupExistingMetadataLegacy(const QByteArray &metadata)
|
||||
const auto decryptedFileObj = decryptedFileDoc.object();
|
||||
|
||||
if (decryptedFileObj["filename"].toString().isEmpty()) {
|
||||
qCDebug(lcCseMetadata) << "decrypted metadata" << decryptedFileDoc.toJson(QJsonDocument::Indented);
|
||||
qCWarning(lcCseMetadata) << "skipping encrypted file" << file.encryptedFilename << "metadata has an empty file name";
|
||||
qCWarning(lcCseMetadata) << "decrypted metadata" << decryptedFileDoc.toJson(QJsonDocument::Compact) << "skipping encrypted file" << file.encryptedFilename << "metadata has an empty file name";
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -360,14 +357,16 @@ void FolderMetadata::setupExistingMetadataLegacy(const QByteArray &metadata)
|
||||
}
|
||||
|
||||
if (!checkMetadataKeyChecksum(metadataKey, metadataKeyChecksum) && _existingMetadataVersion >= MetadataVersion::Version1_2) {
|
||||
qCInfo(lcCseMetadata) << "checksum comparison failed"
|
||||
<< "server value" << metadataKeyChecksum << "client value" << computeMetadataKeyChecksum(metadataKey);
|
||||
if (!_account->shouldSkipE2eeMetadataChecksumValidation()) {
|
||||
qCWarning(lcCseMetadata) << "Failed to validate checksum for legacy metadata!";
|
||||
qCWarning(lcCseMetadata) << "Failed to validate checksum for legacy metadata!"
|
||||
<< "checksum comparison failed"
|
||||
<< "server value" << metadataKeyChecksum << "client value" << computeMetadataKeyChecksum(metadataKey);
|
||||
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
|
||||
return;
|
||||
} else {
|
||||
qCWarning(lcCseMetadata) << "Failed to validate checksum for legacy metadata!"
|
||||
<< "shouldSkipE2eeMetadataChecksumValidation is set. Allowing invalid checksum until next sync.";
|
||||
}
|
||||
qCWarning(lcCseMetadata) << "shouldSkipE2eeMetadataChecksumValidation is set. Allowing invalid checksum until next sync.";
|
||||
}
|
||||
_isMetadataValid = true;
|
||||
}
|
||||
@ -546,7 +545,6 @@ void FolderMetadata::initEmptyMetadata()
|
||||
if (_account->capabilities().clientSideEncryptionVersion() < 2.0) {
|
||||
return initEmptyMetadataLegacy();
|
||||
}
|
||||
qCDebug(lcCseMetadata()) << "Setting up empty metadata v2";
|
||||
|
||||
const auto certificateType = _account->e2e()->useTokenBasedEncryption() ?
|
||||
FolderMetadata::CertificateType::HardwareCertificate : FolderMetadata::CertificateType::SoftwareNextcloudCertificate;
|
||||
@ -566,7 +564,6 @@ void FolderMetadata::initEmptyMetadata()
|
||||
|
||||
void FolderMetadata::initEmptyMetadataLegacy()
|
||||
{
|
||||
qCDebug(lcCseMetadata) << "Settint up legacy empty metadata";
|
||||
_metadataKeyForEncryption = EncryptionHelper::generateRandom(metadataKeySize);
|
||||
_metadataKeyForDecryption = _metadataKeyForEncryption;
|
||||
QString publicKey = _account->e2e()->getPublicKey().toPem().toBase64();
|
||||
@ -581,7 +578,7 @@ QByteArray FolderMetadata::encryptedMetadata()
|
||||
{
|
||||
Q_ASSERT(_isMetadataValid);
|
||||
if (!_isMetadataValid) {
|
||||
qCCritical(lcCseMetadata()) << "Could not encrypt non-initialized metadata!";
|
||||
qCWarning(lcCseMetadata()) << "Could not encrypt non-initialized metadata!";
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -589,8 +586,6 @@ QByteArray FolderMetadata::encryptedMetadata()
|
||||
return encryptedMetadataLegacy();
|
||||
}
|
||||
|
||||
qCDebug(lcCseMetadata()) << "Encrypting metadata for latest version"
|
||||
<< latestSupportedMetadataVersion();
|
||||
if (_isRootEncryptedFolder && _folderUsers.isEmpty() && _existingMetadataVersion < MetadataVersion::Version2_0) {
|
||||
// migrated from legacy version, create metadata key and setup folderUsrs array
|
||||
createNewMetadataKeyForEncryption();
|
||||
@ -629,7 +624,7 @@ QByteArray FolderMetadata::encryptedMetadata()
|
||||
const auto isChecksumsArrayValid = (!_isRootEncryptedFolder && keyChecksums.isEmpty()) || (_isRootEncryptedFolder && !keyChecksums.isEmpty());
|
||||
Q_ASSERT(isChecksumsArrayValid);
|
||||
if (!isChecksumsArrayValid) {
|
||||
qCDebug(lcCseMetadata) << "Empty keyChecksums while shouldn't be empty!";
|
||||
qCWarning(lcCseMetadata) << "Empty keyChecksums while shouldn't be empty!";
|
||||
return {};
|
||||
}
|
||||
if (!keyChecksums.isEmpty()) {
|
||||
@ -664,7 +659,7 @@ QByteArray FolderMetadata::encryptedMetadata()
|
||||
const auto isFolderUsersArrayValid = (!_isRootEncryptedFolder && folderUsers.isEmpty()) || (_isRootEncryptedFolder && !folderUsers.isEmpty());
|
||||
Q_ASSERT(isFolderUsersArrayValid);
|
||||
if (!isFolderUsersArrayValid) {
|
||||
qCCritical(lcCseMetadata) << "Empty folderUsers while shouldn't be empty!";
|
||||
qCWarning(lcCseMetadata) << "Empty folderUsers while shouldn't be empty!";
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -692,8 +687,6 @@ QByteArray FolderMetadata::encryptedMetadata()
|
||||
|
||||
QByteArray FolderMetadata::encryptedMetadataLegacy()
|
||||
{
|
||||
qCDebug(lcCseMetadata) << "Generating metadata";
|
||||
|
||||
if (_metadataKeyForEncryption.isEmpty()) {
|
||||
qCWarning(lcCseMetadata) << "Metadata generation failed! Empty metadata key!";
|
||||
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
|
||||
@ -893,7 +886,7 @@ QByteArray FolderMetadata::prepareMetadataForSignature(const QJsonDocument &full
|
||||
void FolderMetadata::addEncryptedFile(const EncryptedFile &f) {
|
||||
Q_ASSERT(_isMetadataValid);
|
||||
if (!_isMetadataValid) {
|
||||
qCCritical(lcCseMetadata()) << "Could not add encrypted file to non-initialized metadata!";
|
||||
qCWarning(lcCseMetadata()) << "Could not add encrypted file to non-initialized metadata!";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -973,7 +966,7 @@ bool FolderMetadata::moveFromFileDropToFiles()
|
||||
return false;
|
||||
}
|
||||
if (parsedEncryptedFile.mimetype.isEmpty()) {
|
||||
qCDebug(lcCseMetadata()) << "Could parse filedrop metadata. mimetype is empty for file" << parsedEncryptedFile.originalFilename;
|
||||
qCWarning(lcCseMetadata()) << "Could parse filedrop metadata. mimetype is empty for file" << parsedEncryptedFile.originalFilename;
|
||||
_account->reportClientStatus(OCC::ClientStatusReportingStatus::E2EeError_GeneralError);
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user