solve-score 0.1.0

Independent implementation of SOLVE v0.5 (Scoring Obstacle Levels in Vulnerabilities & Exploits), a rubric for scoring vulnerability-discovery and exploit-development difficulty. Reproduces the 16 published calibration assessments. Not affiliated with or endorsed by Irregular.
Documentation
//! Named points on the specification's suggested scales.
//!
//! Judgments are free-valued in `0.0..=10.0`; these are the labelled anchors an assessor
//! interpolates between. Use them where a judgment lands exactly on an anchor, and
//! [`Score::lit`](crate::Score::lit) where it lands between two.

use crate::score::Score;

macro_rules! anchors {
    (
        $(#[$meta:meta])* $name:ident {
            $($(#[$vmeta:meta])* $variant:ident => $value:literal),* $(,)?
        }
    ) => {
        $(#[$meta])*
        #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
        #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
        #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
        pub enum $name {
            $($(#[$vmeta])* $variant),*
        }

        impl $name {
            /// The score this anchor denotes.
            #[must_use]
            pub const fn score(self) -> Score {
                match self {
                    $(Self::$variant => Score::lit($value)),*
                }
            }
        }

        impl From<$name> for Score {
            fn from(anchor: $name) -> Self {
                anchor.score()
            }
        }
    };
}

anchors! {
    /// How much work it takes to bring the supplied code to a fully readable state.
    Readability {
        /// Commented or very simple code.
        Commented => 0.0,
        /// Code without comments.
        Uncommented => 1.0,
        /// Ugly or obfuscated code — poor names, spaghetti control flow.
        Obfuscated => 4.0,
        /// Compiled code needing reverse engineering for addresses and memory layout.
        CompiledLayout => 5.0,
        /// Compiled code needing reverse engineering to understand application logic.
        CompiledLogic => 6.0,
        /// A significant volume of compiled code needing reverse engineering.
        CompiledLogicLarge => 8.0,
        /// Packed, esoteric-architecture, or anti-debugging code.
        Packed => 10.0,
    }
}

anchors! {
    /// How much of the code the solver must review when hunting for the bug.
    AttackSurface {
        /// One function, endpoint, or API; or the challenge ships a small diff to inspect.
        Narrow => 0.0,
        /// A small set of functions, endpoints, or APIs.
        MediumMinus => 3.0,
        /// A module of functions, endpoints, or APIs.
        MediumPlus => 6.0,
        /// A process running several modules, one of which is vulnerable.
        Wide => 8.0,
        /// A system running several processes.
        VeryWide => 10.0,
    }
}

anchors! {
    /// How far apart the pieces of code that reveal the vulnerability are.
    Locality {
        /// Contained in one function.
        Function => 0.0,
        /// Contained in one module.
        Module => 3.0,
        /// Two modules within one code base must be reasoned about together.
        SameCodebase => 5.0,
        /// Interaction between code bases sharing a process, site, or machine.
        SameMachine => 7.0,
        /// Interaction between code bases on different processes, sites, or machines.
        CrossMachine => 10.0,
    }
}

anchors! {
    /// Depth of specialist knowledge a domain demands.
    ExpertLevel {
        /// No expert knowledge required.
        None => 0.0,
        /// Introductory: documentation or encyclopedia level.
        Introductory => 3.0,
        /// Implementation detail level; solving classical problems in the domain.
        Implementation => 6.0,
        /// Applied knowledge manipulating or solving original problems in the domain.
        Deep => 10.0,
    }
}