feat(meta): Remove log redaction
This commit is contained in:
		
							parent
							
								
									b354ca8d0a
								
							
						
					
					
						commit
						29f0419154
					
				@ -152,7 +152,7 @@ class XmppConnection {
 | 
				
			|||||||
  /// True if we are authenticated. False if not.
 | 
					  /// True if we are authenticated. False if not.
 | 
				
			||||||
  bool _isAuthenticated = false;
 | 
					  bool _isAuthenticated = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Timer for the connecting timeout
 | 
					  /// Timer for the connecting timeout.
 | 
				
			||||||
  Timer? _connectingTimeoutTimer;
 | 
					  Timer? _connectingTimeoutTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Completers for certain actions
 | 
					  /// Completers for certain actions
 | 
				
			||||||
@ -467,10 +467,10 @@ class XmppConnection {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Sends an [XMLNode] without any further processing to the server.
 | 
					  /// Sends an [XMLNode] without any further processing to the server.
 | 
				
			||||||
  void sendRawXML(XMLNode node, {String? redact}) {
 | 
					  void sendRawXML(XMLNode node) {
 | 
				
			||||||
    final string = node.toXml();
 | 
					    final string = node.toXml();
 | 
				
			||||||
    _log.finest('==> $string');
 | 
					    _log.finest('==> $string');
 | 
				
			||||||
    _socket.write(string, redact: redact);
 | 
					    _socket.write(string);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Sends [raw] to the server.
 | 
					  /// Sends [raw] to the server.
 | 
				
			||||||
 | 
				
			|||||||
@ -43,7 +43,7 @@ class NegotiatorAttributes {
 | 
				
			|||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Sends the nonza nonza and optionally redacts it in logs if redact is not null.
 | 
					  /// Sends the nonza nonza and optionally redacts it in logs if redact is not null.
 | 
				
			||||||
  final void Function(XMLNode nonza, {String? redact}) sendNonza;
 | 
					  final void Function(XMLNode nonza) sendNonza;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Returns the connection settings.
 | 
					  /// Returns the connection settings.
 | 
				
			||||||
  final ConnectionSettings Function() getConnectionSettings;
 | 
					  final ConnectionSettings Function() getConnectionSettings;
 | 
				
			||||||
 | 
				
			|||||||
@ -50,7 +50,6 @@ class SaslPlainNegotiator extends Sasl2AuthenticationNegotiator {
 | 
				
			|||||||
      final data = await getRawStep('');
 | 
					      final data = await getRawStep('');
 | 
				
			||||||
      attributes.sendNonza(
 | 
					      attributes.sendNonza(
 | 
				
			||||||
        SaslPlainAuthNonza(data),
 | 
					        SaslPlainAuthNonza(data),
 | 
				
			||||||
        redact: SaslPlainAuthNonza('******').toXml(),
 | 
					 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      _authSent = true;
 | 
					      _authSent = true;
 | 
				
			||||||
      return const Result(NegotiatorState.ready);
 | 
					      return const Result(NegotiatorState.ready);
 | 
				
			||||||
 | 
				
			|||||||
@ -259,7 +259,6 @@ class SaslScramNegotiator extends Sasl2AuthenticationNegotiator {
 | 
				
			|||||||
            body: await getRawStep(''),
 | 
					            body: await getRawStep(''),
 | 
				
			||||||
            type: hashType,
 | 
					            type: hashType,
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
          redact: SaslScramAuthNonza(body: '******', type: hashType).toXml(),
 | 
					 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        return const Result(NegotiatorState.ready);
 | 
					        return const Result(NegotiatorState.ready);
 | 
				
			||||||
      case ScramState.initialMessageSent:
 | 
					      case ScramState.initialMessageSent:
 | 
				
			||||||
@ -275,7 +274,6 @@ class SaslScramNegotiator extends Sasl2AuthenticationNegotiator {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        attributes.sendNonza(
 | 
					        attributes.sendNonza(
 | 
				
			||||||
          SaslScramResponseNonza(body: await getRawStep(nonza.innerText())),
 | 
					          SaslScramResponseNonza(body: await getRawStep(nonza.innerText())),
 | 
				
			||||||
          redact: SaslScramResponseNonza(body: '******').toXml(),
 | 
					 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        return const Result(NegotiatorState.ready);
 | 
					        return const Result(NegotiatorState.ready);
 | 
				
			||||||
      case ScramState.challengeResponseSent:
 | 
					      case ScramState.challengeResponseSent:
 | 
				
			||||||
 | 
				
			|||||||
@ -232,11 +232,11 @@ class Sasl2Negotiator extends XmppFeatureNegotiatorBase {
 | 
				
			|||||||
            'mechanism': _currentSaslNegotiator!.mechanismName,
 | 
					            'mechanism': _currentSaslNegotiator!.mechanismName,
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
          children: [
 | 
					          children: [
 | 
				
			||||||
            if (userAgent != null) userAgent!.toXml(),
 | 
					 | 
				
			||||||
            XMLNode(
 | 
					            XMLNode(
 | 
				
			||||||
              tag: 'initial-response',
 | 
					              tag: 'initial-response',
 | 
				
			||||||
              text: await _currentSaslNegotiator!.getRawStep(''),
 | 
					              text: await _currentSaslNegotiator!.getRawStep(''),
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
 | 
					            if (userAgent != null) userAgent!.toXml(),
 | 
				
			||||||
            ...children,
 | 
					            ...children,
 | 
				
			||||||
          ],
 | 
					          ],
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
				
			|||||||
@ -30,9 +30,8 @@ abstract class BaseSocketWrapper {
 | 
				
			|||||||
  /// reused by calling [this.connect] again.
 | 
					  /// reused by calling [this.connect] again.
 | 
				
			||||||
  void close();
 | 
					  void close();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Write [data] into the socket. If [redact] is not null, then [redact] will be
 | 
					  /// Write [data] into the socket.
 | 
				
			||||||
  /// logged instead of [data].
 | 
					  void write(String data);
 | 
				
			||||||
  void write(String data, {String? redact});
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// This must connect to [host]:[port] and initialize the streams accordingly.
 | 
					  /// This must connect to [host]:[port] and initialize the streams accordingly.
 | 
				
			||||||
  /// [domain] is the domain that TLS should be validated against, in case the Socket
 | 
					  /// [domain] is the domain that TLS should be validated against, in case the Socket
 | 
				
			||||||
 | 
				
			|||||||
@ -18,9 +18,10 @@ Future<void> _runTest(String domain) async {
 | 
				
			|||||||
    TestingReconnectionPolicy(),
 | 
					    TestingReconnectionPolicy(),
 | 
				
			||||||
    AlwaysConnectedConnectivityManager(),
 | 
					    AlwaysConnectedConnectivityManager(),
 | 
				
			||||||
    socket,
 | 
					    socket,
 | 
				
			||||||
  )..registerFeatureNegotiators([
 | 
					  );
 | 
				
			||||||
      StartTlsNegotiator(),
 | 
					  await connection.registerFeatureNegotiators([
 | 
				
			||||||
    ]);
 | 
					    StartTlsNegotiator(),
 | 
				
			||||||
 | 
					  ]);
 | 
				
			||||||
  await connection.registerManagers([
 | 
					  await connection.registerManagers([
 | 
				
			||||||
    DiscoManager([]),
 | 
					    DiscoManager([]),
 | 
				
			||||||
    RosterManager(TestingRosterStateManager('', [])),
 | 
					    RosterManager(TestingRosterStateManager('', [])),
 | 
				
			||||||
 | 
				
			|||||||
@ -19,9 +19,10 @@ void main() {
 | 
				
			|||||||
        TestingSleepReconnectionPolicy(10),
 | 
					        TestingSleepReconnectionPolicy(10),
 | 
				
			||||||
        AlwaysConnectedConnectivityManager(),
 | 
					        AlwaysConnectedConnectivityManager(),
 | 
				
			||||||
        TCPSocketWrapper(),
 | 
					        TCPSocketWrapper(),
 | 
				
			||||||
      )..registerFeatureNegotiators([
 | 
					      );
 | 
				
			||||||
          StartTlsNegotiator(),
 | 
					      await connection.registerFeatureNegotiators([
 | 
				
			||||||
        ]);
 | 
					        StartTlsNegotiator(),
 | 
				
			||||||
 | 
					      ]);
 | 
				
			||||||
      await connection.registerManagers([
 | 
					      await connection.registerManagers([
 | 
				
			||||||
        DiscoManager([]),
 | 
					        DiscoManager([]),
 | 
				
			||||||
        RosterManager(TestingRosterStateManager('', [])),
 | 
					        RosterManager(TestingRosterStateManager('', [])),
 | 
				
			||||||
@ -68,9 +69,10 @@ void main() {
 | 
				
			|||||||
        TestingReconnectionPolicy(),
 | 
					        TestingReconnectionPolicy(),
 | 
				
			||||||
        AlwaysConnectedConnectivityManager(),
 | 
					        AlwaysConnectedConnectivityManager(),
 | 
				
			||||||
        TCPSocketWrapper(),
 | 
					        TCPSocketWrapper(),
 | 
				
			||||||
      )..registerFeatureNegotiators([
 | 
					      );
 | 
				
			||||||
          StartTlsNegotiator(),
 | 
					      await connection.registerFeatureNegotiators([
 | 
				
			||||||
        ]);
 | 
					        StartTlsNegotiator(),
 | 
				
			||||||
 | 
					      ]);
 | 
				
			||||||
      await connection.registerManagers([
 | 
					      await connection.registerManagers([
 | 
				
			||||||
        DiscoManager([]),
 | 
					        DiscoManager([]),
 | 
				
			||||||
        RosterManager(TestingRosterStateManager('', [])),
 | 
					        RosterManager(TestingRosterStateManager('', [])),
 | 
				
			||||||
 | 
				
			|||||||
@ -289,17 +289,13 @@ class TCPSocketWrapper extends BaseSocketWrapper {
 | 
				
			|||||||
      _eventStream.stream.asBroadcastStream();
 | 
					      _eventStream.stream.asBroadcastStream();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  void write(String data, {String? redact}) {
 | 
					  void write(String data) {
 | 
				
			||||||
    if (_socket == null) {
 | 
					    if (_socket == null) {
 | 
				
			||||||
      _log.severe('Failed to write to socket as _socket is null');
 | 
					      _log.severe('Failed to write to socket as _socket is null');
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (redact != null) {
 | 
					    _log.finest('==> $data');
 | 
				
			||||||
      _log.finest('**> $redact');
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      _log.finest('==> $data');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      _socket!.write(data);
 | 
					      _socket!.write(data);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user