pub struct TermConstraints {Show 14 fields
pub min_term_size: usize,
pub max_term_size: usize,
pub max_result_term_size: usize,
pub must_be_symbolic: bool,
pub no_payload_in_subterm: bool,
pub must_payload_in_subterm: bool,
pub not_inside_list: bool,
pub weighted_depth: bool,
pub must_be_root: bool,
pub not_readable: bool,
pub must_be_det: bool,
pub zoo_gen_how_many: usize,
pub zoo_max_depth: Option<u16>,
pub threshold_max_payloads_per_term: usize,
}Expand description
Size budget for terms and traces during mutation.
§Units
All *_size values below are node counts in the term tree (Term::size()): every
application/variable counts 1, summed over the whole (symbolic) tree; Trace::size() sums each
input step’s recipe size and additionally counts every output action as one node. They are NOT
bytes.
§How the caps relate
min_term_size/max_term_size: bounds on a sub-term selected as a mutation candidate.max_result_term_size: hard post-condition on the result of a replacement mutation — a mutation that would push any single step recipe overmax_result_term_sizeis rejected (reject-whole). Whole-trace growth is bounded instead by the number of steps (MutationConfig::max_result_trace_length) times this per-step cap. It is enforced incrementally on top of an already-bounded input (seeds within caps + reject-whole preserve the invariant), so set them at or above the largest seed: a cap configured below an existing seed’s size is a corpus-boundary misconfiguration and cannot be enforced retroactively by the mutators (see the precondition onreplacement_within_caps).
§Maintenance rules — READ THIS BEFORE ADDING A PROTOCOL OR EXTENDING A MAPPER
These numbers are chosen from the sizes of the hand-written seeds/attacks. When you add a protocol, add seeds, or grow the signature (mapper), re-measure the seeds and re-check the rules below. As of this writing the largest seed values are:
| metric | TLS | OPC UA | SSH | rule for the cap |
|---|---|---|---|---|
| max single-step recipe (nodes) | 324 | 137 | 285 | max_term_size >= 2 * max_seed_term |
| max #steps | 13 | 10 | 10 | max_result_trace_length >= max_seed_steps + 2 |
The current values sit well above these minima on purpose, to leave headroom for future growth of the mappers (larger signatures / seed terms / longer attacks) without another cap bump:
max_term_sizeMUST be at least2 * (largest single-term size across all seeds)so seeds (and moderately grown variants) stay selectable. Largest today = 324 (TLS) ⇒ rule wants ≥648; set to 800.- whole-trace growth is bounded by
MutationConfig::max_result_trace_length(max #steps) times the per-stepmax_result_term_sizecap, so there is no separate whole-trace node cap.max_result_trace_lengthis set to 20 (largest seed today = 13 steps, rule wants ≥15). max_result_term_size(whole step recipe after a replacement) is kept >=max_term_sizeso a max-size replacement sub-term still fits; set to 1000.
Fields§
§min_term_size: usizeMinimum size of a sub-term selected as a mutation candidate.
max_term_size: usizeMaximum size of a sub-term selected as a mutation candidate. Rule: >= 2 * max_seed_term
(largest single-term size across all seeds). Measured max seed term = 324 (TLS).
max_result_term_size: usizeHard post-condition: reject a replacement whose result makes any single step recipe
exceed this many nodes. Rule: > max_seed_term with headroom (measured max = 324).
must_be_symbolic: bool§no_payload_in_subterm: boolwhen true: only look for terms with no payload in sub-terms
must_payload_in_subterm: bool§not_inside_list: boolwhen true: we do not choose terms that have a list symbol and whose parent also has a list symbol those terms are thus “inside a list”, like t in fn_append(t,t3) for t = fn(append(t1,t2)
weighted_depth: boolchoose term giving higher probability to deeper term
must_be_root: boolonly select root terms
not_readable: boolwhen true: only look for readable terms
must_be_det: boolForbids sub-terms with no det function symbols
zoo_gen_how_many: usizeNumber of terms to generate for each type
zoo_max_depth: Option<u16>Max depth of the terms generated for the zoo, None to use the protocol’s
crate::protocol::ProtocolBehavior::ZOO_MAX_DEPTH, see crate::fuzzer::term_zoo
threshold_max_payloads_per_term: usizeMax number of paylaods per term (limiting further MakeMessage)
Implementations§
Source§impl TermConstraints
impl TermConstraints
Sourcepub fn satisfy_size_max_constraints<PT: ProtocolTypes>(
&self,
term: &Term<PT>,
) -> bool
pub fn satisfy_size_max_constraints<PT: ProtocolTypes>( &self, term: &Term<PT>, ) -> bool
Returns whether a term is not extremely large (in which case we don’t even bother exploring it)
Sourcepub fn satisfy_constraints_with_size<PT: ProtocolTypes>(
&self,
term: &Term<PT>,
size: usize,
) -> bool
pub fn satisfy_constraints_with_size<PT: ProtocolTypes>( &self, term: &Term<PT>, size: usize, ) -> bool
Returns whether term satisfies the constraints, for a caller that already knows its size.
TermType::size is recursive, so recomputing it at every node of a term makes a traversal
quadratic in the term size. Traversals that fold the sizes bottom-up (see
reservoir_sample) pass the size in instead.
Sourcepub fn should_recurse<PT: ProtocolTypes>(&self, term: &Term<PT>) -> bool
pub fn should_recurse<PT: ProtocolTypes>(&self, term: &Term<PT>) -> bool
Returns whether we should recurse into the sub-terms of a given term.
Sourcepub fn no_constraint() -> Self
pub fn no_constraint() -> Self
Return TermConstraints with minimal/no constraint
Trait Implementations§
Source§impl Clone for TermConstraints
impl Clone for TermConstraints
Source§fn clone(&self) -> TermConstraints
fn clone(&self) -> TermConstraints
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TermConstraints
impl Debug for TermConstraints
Source§impl Default for TermConstraints
Default values which represent no constraint
impl Default for TermConstraints
Default values which represent no constraint
impl Copy for TermConstraints
Auto Trait Implementations§
impl Freeze for TermConstraints
impl RefUnwindSafe for TermConstraints
impl Send for TermConstraints
impl Sync for TermConstraints
impl Unpin for TermConstraints
impl UnwindSafe for TermConstraints
Blanket Implementations§
§impl<Head, T> Append<T> for Head
impl<Head, T> Append<T> for Head
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneAny for T
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<I, S> MutatedTransform<I, S> for Iwhere
I: Clone,
S: HasCorpus<I>,
impl<I, S> MutatedTransform<I, S> for Iwhere
I: Clone,
S: HasCorpus<I>,
§fn try_transform_from(base: &mut Testcase<I>, state: &S) -> Result<I, Error>
fn try_transform_from(base: &mut Testcase<I>, state: &S) -> Result<I, Error>
§fn try_transform_into(
self,
_state: &S,
) -> Result<(I, <I as MutatedTransform<I, S>>::Post), Error>
fn try_transform_into( self, _state: &S, ) -> Result<(I, <I as MutatedTransform<I, S>>::Post), Error>
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);