Specify a system. Find the process that breaks it.

SAPLE models a system as process equations over shared state, written in its language SPL, and checks its properties and patterns with symbolic execution and an SMT solver.

Download the latest release

// Every coin should buy one pass.
type Gate = { LOCKED, UNLOCKED } ;

schema Turnstile {
    attributes {
        gate   : Gate = LOCKED ;
        coins  : Int  = 0 ;
        passes : Int  = 0 ;
    }
}

transition coin() { guard: coins < 2 ;
    effect: coins += 1 ; gate := UNLOCKED ; }
transition push() { guard: gate == UNLOCKED ;
    effect: passes += 1 ; gate := LOCKED ; }

agent Controller() {
    attributes { }
    process {
        Locked   = [coins < 2]  coin() . Unlocked
                 + [coins == 2] done ;
        Unlocked = push() . Locked
                 + coin() . Unlocked ;
    }
}

system Entrance {
    schema: Turnstile ;
    agents { Controller() ; }
    properties { noLostCoin : coins <= passes + 1 ; }
}
Two coins, no pass, so a coin is lost. Real output, trimmed; exit status 1.

Run

A real terminal recording of the released saple v0.3.0 binary, running both front ends exactly as their docs show. First the Intel x86-64 Model on a CWE-190 listing, then the AArch64 Model on a recorded run.

Recording saple v0.3.0
x86-64: saple translate …/imul32_overflow_before_malloc.txt --arch x86-64 -o imul.spl, saple analyze imul.spl --pattern-set=v0.6. AArch64: saple translate …/chain_190_122.json --arch aarch64 -o chain.spl, saple analyze chain.spl --pattern-file patterns/aarch64-trace-v0.1.spl. GIF version

One file holds the state, the behaviour and what must hold.

An SPL model is a handful of declarations. SAPLE walks the agents' process equations over the shared state and reports every property that fails and every pattern that matches.

schema
The shared state: typed attributes with initial values. Integers, Booleans, enumerations, collections and bit-vectors.
schema Turnstile { attributes { coins : Int = 0 ; } }
transition
A guarded, atomic update of the state.
transition coin() { guard: coins < 2 ; effect: coins += 1 ; }
agent
Process equations over transitions: prefix ., choice +, parallel ||, guards and recursion.
Unlocked = push() . Locked + coin() . Unlocked ;
system
The agents that run together, the schema they share, and the properties SAPLE checks.
properties { noLostCoin : coins <= passes + 1 ; }
pattern
A behaviour to look for: a signature of actions plus a constraint, reported with a severity. From the cache-coherence example:
pattern dataRace {
    signature { cpuWriteShared(core1, val1) . cpuWriteShared(core2, val2) . done }
    constraints { core1 != core2 }
    severity: CRITICAL ;
}

The SPL language, construct by construct

Machine code, through two front ends.

Each front end turns machine code into an SPL model on bit-vector semantics, then matches the pattern libraries in patterns/ against it.

Intel x86-64 Model

A static Intel-syntax listing of one function. Every path is checked, with data flow along the path and conditional jumps as guards.

Shell
saple analyze listing.txt --arch x86-64 --pattern-set=v0.6

AArch64 Model

A trace-v1 recording of one run. Each pattern match is graded VERIFIED, OBSERVED, UNKNOWN or REFUTED.

Shell
saple translate run.json --arch aarch64 -o run.spl
saple analyze run.spl --pattern-file patterns/aarch64-trace-v0.1.spl

Seven models to read and run.

Each example is a complete, commented SPL file in examples/ with a walkthrough of what SAPLE reports.

All seven examples, with their full models

Install it, then run a model.

Prebuilt binaries for Windows, macOS and Linux. The example models live in the repository.

↑ ↓ to moveEnter to openEsc to close