Skip to content

Instantly share code, notes, and snippets.

@fuzz-ai
fuzz-ai / ShuffleVector.tla
Last active May 15, 2024 15:41
Shuffle vector model in TLA+
------------------------- MODULE ShuffleVector ------------------------------
LOCAL INSTANCE Naturals
LOCAL INSTANCE Sequences
LOCAL INSTANCE TLC
(* A Shuffle Vector consists of a sequence of up to N elements.
Adding an element to the shuffle vector pushes an element onto the beginning
of the sequence and swaps it with a random element.
*)
--------------------------- MODULE MemoryTracking ---------------------------
(* A memory allocator which tracks usage by "phase" *)
CONSTANTS Phase, (* A set of phases *)
Thread, (* A set of threads *)
Address (* A set of addresses *)
VARIABLES memory, (* All in-use allocations *)
memoryByPhase, (* A mapping from phases to sets of allocated items *)
memoryByThread (* A mapping from threads to an allocated record *)
@fuzz-ai
fuzz-ai / fuzz.go
Created January 8, 2019 05:32
Ontology NeoVM fuzzing harness
// +build gofuzz
package test
import (
"github.com/ontio/ontology/smartcontract"
"github.com/ontio/ontology/core/types"
)
func Fuzz( data []byte ) int {
@fuzz-ai
fuzz-ai / testStress.cpp
Created January 2, 2019 06:37
fuzzed version of testStress()
while (!std::cin.eof() )
{
// pick a random ledger history
std::string curr = "";
char depth = getBits( maxDepth );
char offset = 0;
for(char d = 0; d < depth; ++d)
{
char a = offset + getBits( maxWidth );
curr += a;
@fuzz-ai
fuzz-ai / testStress.cpp
Created January 2, 2019 06:36
testStress() original version
void
testStress()
{
using namespace csf;
LedgerTrie<Ledger> t;
LedgerHistoryHelper h;
// Test quasi-randomly add/remove supporting for different ledgers
// from a branching history.
const int buf_size = MAX_MESSAGE_SIZE + 1024;
char buf[buf_size];
int main( int argc, char *argv[] ) {
std::cin.read( buf, buf_size );
if ( !std::cin.eof() ) {
std::cout << "String too long.\n";
return 1;
}
size_t size = std::cin.gcount();
struct hello_message
{
static const core_message_type_enum type;
std::string user_agent;
uint32_t core_protocol_version;
fc::ip::address inbound_address;
uint16_t inbound_port;
uint16_t outbound_port;
node_id_t node_public_key;
@fuzz-ai
fuzz-ai / snappy-harness.cpp
Created December 8, 2018 06:35
snappy compression round-trip test harness
#include <snappy.h>
#include <iostream>
#include <string>
#include <cstring>
#include <stdlib.h>
const size_t maxInputSize = 10 * 1024 * 1024;
char inputBuf[maxInputSize];
@fuzz-ai
fuzz-ai / stringFromStream.cpp
Created December 5, 2018 06:10
fc::json::stringFromStream snippet
template<typename T>
fc::string stringFromStream( T& in )
...
while( true )
{
switch( c = in.peek() )
{
@fuzz-ai
fuzz-ai / json-harness.cpp
Created December 5, 2018 06:05
fc::json::from_file test harness for AFL
#include <fc/variant.hpp>
#include <fc/io/json.hpp>
#include <fc/filesystem.hpp>
#include <fc/exception/exception.hpp>
#include <iostream>
using fc::path;
using fc::json;
using fc::variant;