Skip to main content

ScanContext

Struct ScanContext 

Source
#[non_exhaustive]
pub struct ScanContext { pub target: Url, pub client: Arc<Client>, pub discovered_endpoints: Arc<DashMap<String, Vec<String>>>, pub visited_urls: Arc<DashSet<String>>, pub telemetry_tx: UnboundedSender<String>, pub logger: Arc<Logger>, pub phase_timeout_secs: u64, pub cancel_token: CancellationToken, pub event_bus: Arc<EventBus>, /* private fields */ }
Expand description

Zero-copy shared state across all scan phases.

Construct contexts through ScanContext::new or one of the policy-aware constructors. Additional runtime state may be introduced without requiring extension authors to initialize internal fields.

§Examples

use reqwest::Client;
use url::Url;
use termivar_scanner::ScanContext;

let (telemetry_tx, _telemetry_rx) = tokio::sync::mpsc::unbounded_channel();
let context = ScanContext::new(
    Url::parse("https://example.test")?,
    Client::new(),
    telemetry_tx,
);

assert_eq!(context.knowledge().stats().evidence, 0);

Direct construction is intentionally unsupported so new runtime state does not break extension code:

ⓘ
use reqwest::Client;
use url::Url;
use termivar_scanner::ScanContext;

let (telemetry_tx, _telemetry_rx) = tokio::sync::mpsc::unbounded_channel();
let context = ScanContext::new(
    Url::parse("https://example.test").unwrap(),
    Client::new(),
    telemetry_tx,
);
let _modified = ScanContext {
    phase_timeout_secs: 30,
    ..context
};

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§target: Url

Compatibility view of the root URL whose scope is being scanned.

Mutating this pre-1.0 public field does not change the immutable target captured by built-in authorities or the runner’s provenance envelope.

§client: Arc<Client>

Raw HTTP client retained for phase one and custom phases that explicitly accept the legacy direct-I/O contract.

Built-in phases two through nine ignore this client. Discovery and verification use distinct private exact-origin bounded authorities.

§discovered_endpoints: Arc<DashMap<String, Vec<String>>>

Discovered endpoints mapped to their observed parameter names.

§visited_urls: Arc<DashSet<String>>

URLs already visited by discovery phases.

§telemetry_tx: UnboundedSender<String>

Asynchronous telemetry channel for logging and analysis.

§logger: Arc<Logger>

Structured logger shared by scan phases.

§phase_timeout_secs: u64

Maximum runtime of an individual phase, in seconds.

§cancel_token: CancellationToken

Token used to propagate graceful scan cancellation.

Calling [CancellationToken::cancel] affects the immutable shared token captured by the runner and built-in authorities. Replacing this public compatibility field does not replace that runtime authority.

§event_bus: Arc<EventBus>

Event bus used to publish scan lifecycle and progress events.

Implementations§

Source§

impl ScanContext

Source

pub fn new( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, ) -> Self

Creates a context with a five-minute phase timeout, a fresh cancellation token, and a fresh event bus.

Source

pub fn new_with_discovery_limits( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, discovery_limits: DiscoveryLimits, ) -> Self

Creates a context with a host-selected finite discovery envelope and otherwise default runtime services.

Source

pub fn new_with_verification_limits( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, verification_limits: VerificationLimits, ) -> Self

Creates a context with a host-selected finite verification envelope and otherwise default runtime services.

Source

pub fn with_timeout( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, phase_timeout_secs: u64, ) -> Self

Creates a context with an explicit per-phase timeout in seconds.

A fresh cancellation token and event bus are installed for the scan.

Source

pub fn with_cancellation( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, phase_timeout_secs: u64, cancel_token: CancellationToken, ) -> Self

Creates a context with explicit timeout and cancellation policy.

A fresh event bus is installed for the scan.

Source

pub fn with_event_bus( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, phase_timeout_secs: u64, cancel_token: CancellationToken, event_bus: Arc<EventBus>, ) -> Self

Creates a context with all externally configurable runtime services.

The authorized root endpoint is registered immediately; the visited set, typed forms, logger, and knowledge base start empty. The supplied raw HTTP client is promoted into shared ownership for unmigrated and custom legacy phases.

Source

pub const fn discovery_limits(&self) -> DiscoveryLimits

Returns the configured discovery envelope.

Source

pub const fn verification_limits(&self) -> VerificationLimits

Returns the finite envelope shared by built-in legacy verification phases five through nine.

Source

pub fn discovery_forms(&self) -> Vec<DiscoveryForm>

Returns stable typed form observations from bounded discovery.

Ownership is parser-tree-descendant based; malformed HTML form-owner associations are not inferred.

Source

pub fn log(&self, msg: String)

Sends a plain-text message to the telemetry channel.

Messages are dropped when the receiving side has closed.

Source

pub fn add_endpoint(&self, url: String, params: Vec<String>)

Records a discovered endpoint and its observed parameter names.

Recording the same URL again replaces its prior parameter list.

Source

pub fn mark_visited(&self, url: String)

Marks a URL as visited for duplicate-scan prevention.

Source

pub fn is_visited(&self, url: &str) -> bool

Returns whether a URL has already been marked as visited.

Source

pub fn endpoint_count(&self) -> usize

Returns the number of distinct discovered endpoint URLs.

Source

pub fn knowledge(&self) -> &KnowledgeBase

Returns the evidence-driven knowledge base shared by this scan.

The context retains ownership so the runtime can preserve one knowledge identity across phases and cloned contexts.

Trait Implementations§

Source§

impl Clone for ScanContext

Source§

fn clone(&self) -> ScanContext

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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