Skip to main content

ValidationReport

Struct ValidationReport 

Source
pub struct ValidationReport {
    pub collisions: Vec<PermissionCollision>,
}
Expand description

Validation outcome for a set of permission strings.

This is the main result type returned by permission validation APIs. It tells you whether the permission set is safe to use and, if not, what needs to be fixed.

Produced by:

§Terminology

  • Duplicate permission: The exact same string appears more than once. These are represented internally as a collision where every entry in the collision group is identical.
  • Hash collision: Two different normalized permission strings that deterministically hash to the same ID. This is extremely unlikely and should be treated as a critical configuration problem if it ever occurs.

§Interpreting Results

§Typical Actions

SituationActionSeverity
Report is validProceed with startup or reloadNone
One or more duplicates onlyRemove redundant entriesLow or medium
Any non-duplicate hash collisionRename at least one colliding permission immediatelyHigh

§Convenience Methods

§Example

use webgates_core::permissions::application_validator::ApplicationValidator;
use webgates_core::permissions::collision_checker::PermissionCollisionChecker;

let mut checker = PermissionCollisionChecker::new(vec![
    "user:read".into(),
    "user:read".into(),
    "admin:full".into(),
]);
let report = checker.validate().map_err(|err| err.to_string())?;
assert!(!report.is_valid());
assert_eq!(report.duplicates(), vec!["user:read".to_string()]);

let report2 = ApplicationValidator::new()
    .add_permissions(["user:read", "user:read"])
    .validate()
    .map_err(|err| err.to_string())?;
assert!(!report2.is_valid());

§Logging

Use ValidationReport::log_results for structured tracing output. Successful validation logs at INFO, and issues log at WARN.

Fields§

§collisions: Vec<PermissionCollision>

All collision groups (duplicates and true hash collisions).

Each entry contains:

  • The 64‑bit permission ID (id)
  • The list of original permission strings that map to that ID

Invariants:

  • Length >= 2 for each permissions vector
  • A “duplicate” group has every element string-equal
  • A “distinct collision” group has at least one differing string

Implementations§

Source§

impl ValidationReport

Source

pub fn is_valid(&self) -> bool

Returns true when validation passed without any issues.

A report is valid when there are no duplicate groups and no true hash collisions.

Source

pub fn duplicates(&self) -> Vec<String>

Returns duplicate permission strings found in the report.

Duplicates are collision groups where all permission strings are identical.

Source

pub fn summary(&self) -> String

Returns a human-readable summary of the validation result.

For successful validation, this returns a success message. For failed validation, it summarizes duplicates and true hash collisions.

Source

pub fn log_results(&self)

Logs validation results using tracing.

Successful validation logs at INFO. Any duplicates or collisions log at WARN.

Source

pub fn detailed_errors(&self) -> Vec<String>

Returns detailed issue strings for debugging or reporting.

Source

pub fn total_issues(&self) -> usize

Returns the number of collision groups recorded in the report.

Trait Implementations§

Source§

impl Debug for ValidationReport

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ValidationReport

Source§

fn default() -> ValidationReport

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more