SecurityResult class
The outcome produced by a single SecurityLayer or by the SecurityEngine after running the full pipeline.
This is intentionally a plain, immutable data class so it is cheap to create, easy to log, and trivial to serialize if needed later.
Constructors
-
SecurityResult({required bool allowed, required double riskScore, required List<
String> flags, required String message, required SecurityVerdict verdict, String? layerName}) -
Creates a result. Prefer the allow, block, or flag factories
for consistent verdict/allowed pairing.
const
-
SecurityResult.allow({double riskScore = 0.0, List<
String> flags = const [], String message = 'OK', String? layerName}) -
Convenience constructor for a fully allowed result.
factory
-
SecurityResult.block({double riskScore = 1.0, List<
String> flags = const [], required String message, String? layerName}) -
Convenience constructor for a blocked (rejected) result.
factory
-
SecurityResult.flag({required double riskScore, List<
String> flags = const [], required String message, String? layerName}) -
Convenience constructor for a result that is allowed to continue but
flagged for review (e.g. suspicious but not conclusive).
factory
Properties
- allowed → bool
-
Whether the request is allowed to continue through the pipeline.
final
-
flags
→ List<
String> -
Human-readable flags describing why a layer reacted the way it did.
Example:
"missing_signature","rate_limit_exceeded".final - hashCode → int
-
The hash code for this object.
no setterinherited
- layerName → String?
-
The name of the layer that produced this result. Populated by the
engine when aggregating results; individual layers may leave it null.
final
- message → String
-
A short human-readable explanation of the decision.
final
- riskScore → double
-
A normalized risk score between 0.0 (no risk) and 1.0 (maximum risk).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- verdict → SecurityVerdict
-
The verdict derived from allowed and riskScore. Layers can set
this explicitly, or rely on SecurityResult.allow/block/flag
factories which set it consistently.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Serializes this result to a JSON-compatible map.
-
toString(
) → String -
A string representation of this object.
override
-
withLayerName(
String name) → SecurityResult - Returns a copy of this result with the given layerName attached.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited