1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-10 05:13:31 +00:00

[PM-5731] feat: remove logging

This commit is contained in:
Andreas Coroiu
2024-01-30 10:01:11 +01:00
parent 5d5d113369
commit d0bb7f0a54

View File

@@ -1,7 +1,6 @@
using Bit.Core.Abstractions; using Bit.Core.Abstractions;
using Bit.Core.Models.View; using Bit.Core.Models.View;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Models.Domain;
using Bit.Core.Utilities.Fido2; using Bit.Core.Utilities.Fido2;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using System.Formats.Cbor; using System.Formats.Cbor;
@@ -14,15 +13,13 @@ namespace Bit.Core.Services
// AAGUID: d548826e-79b4-db40-a3d8-11116f7e8349 // AAGUID: d548826e-79b4-db40-a3d8-11116f7e8349
public static readonly byte[] AAGUID = [ 0xd5, 0x48, 0x82, 0x6e, 0x79, 0xb4, 0xdb, 0x40, 0xa3, 0xd8, 0x11, 0x11, 0x6f, 0x7e, 0x83, 0x49 ]; public static readonly byte[] AAGUID = [ 0xd5, 0x48, 0x82, 0x6e, 0x79, 0xb4, 0xdb, 0x40, 0xa3, 0xd8, 0x11, 0x11, 0x6f, 0x7e, 0x83, 0x49 ];
private INativeLogService _logService;
private ICipherService _cipherService; private ICipherService _cipherService;
private ISyncService _syncService; private ISyncService _syncService;
private ICryptoFunctionService _cryptoFunctionService; private ICryptoFunctionService _cryptoFunctionService;
private IFido2UserInterface _userInterface; private IFido2UserInterface _userInterface;
public Fido2AuthenticatorService(INativeLogService logService, ICipherService cipherService, ISyncService syncService, ICryptoFunctionService cryptoFunctionService, IFido2UserInterface userInterface) public Fido2AuthenticatorService(ICipherService cipherService, ISyncService syncService, ICryptoFunctionService cryptoFunctionService, IFido2UserInterface userInterface)
{ {
_logService = logService;
_cipherService = cipherService; _cipherService = cipherService;
_syncService = syncService; _syncService = syncService;
_cryptoFunctionService = cryptoFunctionService; _cryptoFunctionService = cryptoFunctionService;
@@ -33,10 +30,10 @@ namespace Bit.Core.Services
{ {
if (makeCredentialParams.CredTypesAndPubKeyAlgs.All((p) => p.Algorithm != (int) Fido2AlgorithmIdentifier.ES256)) if (makeCredentialParams.CredTypesAndPubKeyAlgs.All((p) => p.Algorithm != (int) Fido2AlgorithmIdentifier.ES256))
{ {
var requestedAlgorithms = string.Join(", ", makeCredentialParams.CredTypesAndPubKeyAlgs.Select((p) => p.Algorithm).ToArray()); // var requestedAlgorithms = string.Join(", ", makeCredentialParams.CredTypesAndPubKeyAlgs.Select((p) => p.Algorithm).ToArray());
_logService.Warning( // _logService.Warning(
$"[Fido2Authenticator] No compatible algorithms found, RP requested: {requestedAlgorithms}" // $"[Fido2Authenticator] No compatible algorithms found, RP requested: {requestedAlgorithms}"
); // );
throw new NotSupportedError(); throw new NotSupportedError();
} }
@@ -47,9 +44,9 @@ namespace Bit.Core.Services
makeCredentialParams.ExcludeCredentialDescriptorList makeCredentialParams.ExcludeCredentialDescriptorList
); );
if (existingCipherIds.Length > 0) { if (existingCipherIds.Length > 0) {
_logService.Info( // _logService.Info(
"[Fido2Authenticator] Aborting due to excluded credential found in vault." // "[Fido2Authenticator] Aborting due to excluded credential found in vault."
); // );
await _userInterface.InformExcludedCredential(existingCipherIds); await _userInterface.InformExcludedCredential(existingCipherIds);
throw new NotAllowedError(); throw new NotAllowedError();
} }
@@ -64,9 +61,9 @@ namespace Bit.Core.Services
var userVerified = response.UserVerified; var userVerified = response.UserVerified;
string credentialId; string credentialId;
if (cipherId == null) { if (cipherId == null) {
_logService.Info( // _logService.Info(
"[Fido2Authenticator] Aborting because user confirmation was not recieved." // "[Fido2Authenticator] Aborting because user confirmation was not recieved."
); // );
throw new NotAllowedError(); throw new NotAllowedError();
} }
@@ -78,9 +75,9 @@ namespace Bit.Core.Services
var cipher = await encrypted.DecryptAsync(); var cipher = await encrypted.DecryptAsync();
if (!userVerified && (makeCredentialParams.RequireUserVerification || cipher.Reprompt != CipherRepromptType.None)) { if (!userVerified && (makeCredentialParams.RequireUserVerification || cipher.Reprompt != CipherRepromptType.None)) {
_logService.Info( // _logService.Info(
"[Fido2Authenticator] Aborting because user verification was unsuccessful." // "[Fido2Authenticator] Aborting because user verification was unsuccessful."
); // );
throw new NotAllowedError(); throw new NotAllowedError();
} }
@@ -108,10 +105,10 @@ namespace Bit.Core.Services
}; };
} catch (NotAllowedError) { } catch (NotAllowedError) {
throw; throw;
} catch (Exception e) { } catch (Exception) {
_logService.Error( // _logService.Error(
$"[Fido2Authenticator] Unknown error occured during attestation: {e.Message}" // $"[Fido2Authenticator] Unknown error occured during attestation: {e.Message}"
); // );
throw new UnknownError(); throw new UnknownError();
} }
@@ -135,9 +132,9 @@ namespace Bit.Core.Services
} }
if (cipherOptions.Count == 0) { if (cipherOptions.Count == 0) {
_logService.Info( // _logService.Info(
"[Fido2Authenticator] Aborting because no matching credentials were found in the vault." // "[Fido2Authenticator] Aborting because no matching credentials were found in the vault."
); // );
throw new NotAllowedError(); throw new NotAllowedError();
} }
@@ -151,17 +148,17 @@ namespace Bit.Core.Services
var selectedCipher = cipherOptions.FirstOrDefault((c) => c.Id == selectedCipherId); var selectedCipher = cipherOptions.FirstOrDefault((c) => c.Id == selectedCipherId);
if (selectedCipher == null) { if (selectedCipher == null) {
_logService.Info( // _logService.Info(
"[Fido2Authenticator] Aborting because the selected credential could not be found." // "[Fido2Authenticator] Aborting because the selected credential could not be found."
); // );
throw new NotAllowedError(); throw new NotAllowedError();
} }
if (!userVerified && (assertionParams.RequireUserVerification || selectedCipher.Reprompt != CipherRepromptType.None)) { if (!userVerified && (assertionParams.RequireUserVerification || selectedCipher.Reprompt != CipherRepromptType.None)) {
_logService.Info( // _logService.Info(
"[Fido2Authenticator] Aborting because user verification was unsuccessful." // "[Fido2Authenticator] Aborting because user verification was unsuccessful."
); // );
throw new NotAllowedError(); throw new NotAllowedError();
} }
@@ -201,10 +198,10 @@ namespace Bit.Core.Services
AuthenticatorData = authenticatorData, AuthenticatorData = authenticatorData,
Signature = signature Signature = signature
}; };
} catch (Exception e) { } catch (Exception) {
_logService.Error( // _logService.Error(
$"[Fido2Authenticator] Unknown error occured during assertion: {e.Message}" // $"[Fido2Authenticator] Unknown error occured during assertion: {e.Message}"
); // );
throw new UnknownError(); throw new UnknownError();
} }