Sensitive class final

Marks a declaration as holding a secret that must never reach a log, a console, a string interpolation or an exception message.

The sensitive_exposure rule reports a reference to an annotated field, getter, parameter, local variable or top-level variable when it is built into a string, converted with toString(), passed to a logging sink such as print, or put into an exception message.

class Session {
  @Sensitive()
  final String token;

  // Reported: the token would end up in the log.
  void debug() => print('token: $token');
}

Redact the value explicitly instead, for example by logging only its length or a masked prefix.

Constructors

Sensitive([String? reason])
Creates a Sensitive annotation.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
reason → String?
Why the value is secret, or null when no reason was given.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited