Skip to main content

RunHookPayload

Struct RunHookPayload 

Source
pub struct RunHookPayload(/* private fields */);
Expand description

A runHookPayload that is known to fit the service ceiling.

The type is the guard: there is no way to build one over 4096 bytes, so no call site has to remember to check. See the module docs for the measurement and for why the service model’s own documentation string disagrees with its shape.

Implementations§

Source§

impl RunHookPayload

Source

pub fn for_agent_token(agent_token: &str) -> Result<RunHookPayload, Error>

The payload carrying an agent token, as the daemon expects to find it.

{"agent_token": "<token>"} — and the platform wraps this whole string as the value of runHookPayload, which is the extra parse the daemon does.

Checked even though this function builds the JSON itself, because the token is caller-supplied: someone passing a JWT or a signed blob rather than a bearer token is exactly who this catches.

Source

pub fn for_launch( agent_token: &str, env: &HashMap<String, String>, ) -> Result<RunHookPayload, Error>

The payload carrying an agent token and a launch environment.

{"agent_token": "<token>", "env": {...}}, and the platform wraps that whole string as the value of runHookPayload — the extra parse the daemon does. The daemon applies env as the base environment of every subsequent exec, under the per-request env.

This is where the 4096-byte refusal fires for a launch env. The check is on the serialized payload rather than on the map, because the ceiling is on the string: JSON escaping, the key names, and the punctuation all count, so a caller who measured their own values would measure the wrong thing. And it is local rather than left to the service for the same reason super::super::control::image’s require_workdir and require_matching_from are local: the service’s answer arrives as a ValidationException on a member the caller did not know they were filling, after the call, and botocore does not enforce it client-side at all (measured; docs/PLATFORM.md). env is what makes this reachable in practice — one bearer token has always fit with room to spare, and a map of credentials does not.

The env is omitted from the JSON entirely when it is empty, so a caller who passes no launch env produces byte-for-byte the payload RunHookPayload::for_agent_token always produced. A pinned daemon that has never heard of env therefore sees no change, and the two constructors do not have two different budgets.

Source

pub fn for_launch_with_identity( agent_token: &str, env: &HashMap<String, String>, identity: Option<&LaunchIdentity>, ) -> Result<RunHookPayload, Error>

RunHookPayload::for_launch, optionally carrying the tunnel identity material.

The two identity fields are the VM’s own seed and the launching host’s public key, under the keys protocol::identity declares — the daemon pins one and derives from the other, which lets microvm tunnel --verify-identity prove possession of the launch-pinned key under protocol::identity’s trust assumptions. None produces byte-for-byte the payload the other constructors always built, so a caller who never asks for identity cannot be affected by the field existing (the same compatibility rule env follows).

The material costs protocol::identity::IDENTITY_PAYLOAD_BYTES of the shared 4096-byte budget — two 44-character base64 values plus JSON framing — and the ceiling check below covers it like everything else in the payload.

Source

pub fn new(payload: impl Into<String>) -> Result<RunHookPayload, Error>

An arbitrary payload, if it fits.

Public because the run-hook body is the caller’s channel and this crate does not own what goes in it; the ceiling is the only thing it enforces.

Source

pub fn as_str(&self) -> &str

The payload’s bytes as the wire will carry them.

Source

pub fn len(&self) -> usize

The size in bytes, which is what the ceiling measures.

Source

pub fn is_empty(&self) -> bool

Whether the payload is empty. The model’s minimum is 0, so an empty payload is legal.

Trait Implementations§

Source§

impl Clone for RunHookPayload

Source§

fn clone(&self) -> RunHookPayload

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
Source§

impl Debug for RunHookPayload

Prints the size and nothing else.

The payload is the platform’s only per-VM secret channel — its whole purpose is to carry the agent token — so a derived Debug would print that token into every log line that formats one, and into every line that formats the RunMicrovmRequest holding it. RunMicrovmRequest keeps its derive: with this impl in place, the derived one prints RunHookPayload(<N bytes>) for that field, so the safety is inherited rather than restated. The length is kept because it is the number every TRAP-5 diagnosis needs.

Source§

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

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

impl Eq for RunHookPayload

Source§

impl PartialEq for RunHookPayload

Source§

fn eq(&self, other: &RunHookPayload) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RunHookPayload

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

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

Source§

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
Source§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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