Trait puffin::protocol::ProtocolBehavior

source ·
pub trait ProtocolBehavior: 'static {
    type ProtocolTypes: ProtocolTypes;
    type Claim: Claim<Self::ProtocolTypes>;
    type SecurityViolationPolicy: SecurityViolationPolicy<Self::ProtocolTypes, Self::Claim>;
    type ProtocolMessage: ProtocolMessage<Self::ProtocolTypes, Self::OpaqueProtocolMessage>;
    type OpaqueProtocolMessage: OpaqueProtocolMessage<Self::ProtocolTypes>;
    type ProtocolMessageFlight: ProtocolMessageFlight<Self::ProtocolTypes, Self::ProtocolMessage, Self::OpaqueProtocolMessage, Self::OpaqueProtocolMessageFlight>;
    type OpaqueProtocolMessageFlight: OpaqueProtocolMessageFlight<Self::ProtocolTypes, Self::OpaqueProtocolMessage> + From<Self::ProtocolMessageFlight>;

    // Required methods
    fn create_corpus() -> Vec<(Trace<Self::ProtocolTypes>, &'static str)>;
    fn try_read_bytes(
        bitstring: &[u8],
        ty: TypeId,
    ) -> Result<Box<dyn EvaluatedTerm<Self::ProtocolTypes>>, Error>;

    // Provided method
    fn any_get_encoding(
        message: &dyn EvaluatedTerm<Self::ProtocolTypes>,
    ) -> Vec<u8>  { ... }
}
Expand description

Defines the protocol which is being tested.

The fuzzer is generally abstract over the used protocol. We assume that protocols have opaque messages, structured messages, and a way to deframe an arbitrary stream of bytes into messages.

Also the library allows the definition of a type for claims and a (security policy)SecurityViolationPolicy over sequences of them. Finally, there is a matcher which allows traces to include queries for knowledge.

Required Associated Types§

Required Methods§

source

fn create_corpus() -> Vec<(Trace<Self::ProtocolTypes>, &'static str)>

Creates a sane initial seed corpus.

source

fn try_read_bytes( bitstring: &[u8], ty: TypeId, ) -> Result<Box<dyn EvaluatedTerm<Self::ProtocolTypes>>, Error>

Try to read a bitstring and interpret it as the TypeShape, which is the type of a message as per the PB’s internal structure This is expected to fail for many types of messages!

Provided Methods§

source

fn any_get_encoding(message: &dyn EvaluatedTerm<Self::ProtocolTypes>) -> Vec<u8>

Downcast from Box<dyn Any> and encode as bitstring any message as per the PB’s internal structure

Object Safety§

This trait is not object safe.

Implementors§