Giter Site home page Giter Site logo

formalsec / smtml Goto Github PK

View Code? Open in Web Editor NEW
12.0 8.0 7.0 1.64 MB

A Multi Back-end Front-end for SMT Solvers in OCaml

Home Page: https://formalsec.github.io/smtml/

License: GNU General Public License v3.0

OCaml 98.87% Standard ML 0.57% Turing 0.05% Perl 0.11% Raku 0.36% Scheme 0.05%
ocaml smt-lib symbolic-execution z3

smtml's People

Contributors

chambart avatar filipeom avatar hra687261 avatar joaomhmpereira avatar krtab avatar matzoc avatar rageknify avatar zapashcanon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smtml's Issues

Crash in symbolic string operations

// inherit parent's constructor
var code = members.__parent.toString();
var args = code.substring( code.indexOf("(")+1, code.indexOf(")") );
var inner_code = code.substring( code.indexOf("{")+1, code.lastIndexOf("}") );
eval('constructor = function ('+args+') {'+inner_code+'};');
	

Move operators `extract` and `concat` expressions into `bvOp.ml`

Is your feature request related to a problem? Please describe.
Currently, the operators extract and concat are defined as generic expressions in expression.ml. However, these operators are only semantically defined over bit vector values.

Describe the solution you'd like
So, it is more semantically correct that the extract and concat operators are moved into the bvOp.ml module as, respectively, triops and binops.

Describe alternatives you've considered
No alternatives.

Additional context
No additional context.

Avoid installing Z3 as default solver

Ship the encoding with another solver that is quicker to install (Bitwuzla?). Is it possible to retain the z3_mappings implementation? Perhaps, utilize a stub z3 library that fails at runtime if z3 is not installed?

Allow Z3 mappings to create contexts without models

During symbolic executions, contexts without models are slightly faster than when this option is enabled. Models are only used for test-suite generation at the end of the analysis, accounting for only a fraction of the executed queries.

Make the expression type a GADT

Mainly resistant due to operators types. Maybe we could type operators like this?

(* ty.ml *)
type _ t =
  | Ty_int : [ `Ty_int ] t
  | Ty_real : [ `Ty_real ] t
  | Ty_bool : [ `Ty_bool ] t
  | Ty_str : [ `Ty_str ] t
  | Ty_bitv : int -> [ `Ty_bitv ] t
  | Ty_fp : int -> [ `Ty_fp ] t

type _ unop =
  | Abs : [< `Ty_real | `Ty_fp ] unop
  | Ceil : [< `Ty_real | `Ty_fp ] unop
  | Clz : [ `Ty_bitv ] unop
  | Ctz : [ `Ty_bitv ] unop
  | Floor : [< `Ty_real | `Ty_fp ] unop
  | Is_nan : [ `Ty_fp ] unop
  | Len : [ `Ty_str ] unop
  | Neg : [< `Ty_int | `Ty_real | `Ty_bitv | `Ty_fp ] unop
  | Nearest : [< `Ty_real | `Ty_fp ] unop
  | Not : [< `Ty_bitv | `Ty_bool ] unop
  | Sqrt : [< `Ty_real | `Ty_fp ] unop
  | Trim : [ `Ty_str ] unop
  | Trunc : [< `Ty_real | `Ty_fp ] unop

...

Lower bounds CI

Add a CI rule that maximise this criteria in opam to emulate the lower-bounds checking in opam-ci:

+removed,+count[version-lag,solution]

Nary operators

Maybe we could have something like this?

type nary = Add | Sub | Mul
type bary = And | Or
type sary = Concat
...

type nop =
  | Int of nary
  | Real of nary
  | Bool of bary
  | Str of sary
  | ...

type expr =
  ...
  | Nary of nop * expr list

Use Z3 bindings to lift floating-point values

Is your feature request related to a problem? Please describe.
Currently, floating-point (fp) value lifting is done through string parsing of the fp numeral string representation. This is problematic as one cannot guarantee that this fp numeral string representation will be kept in future versions of Z3.

Describe the solution you'd like
Rather than parsing the floating-point numeral string, employ the OCaml Z3 bindings to decode floating-point values into the abstract syntax.

Describe alternatives you've considered
Alternatives have yet to be considered.

Additional context
No additional context.

Restructure lib directory to organise source files

Is your feature request related to a problem? Please describe.
Although the files in lib are correctly named, it would help having them organised into sub-directories that aggregate related code. This feature would reduce mental effort in locating desired source files.

Describe the solution you'd like
For example, files related with the abstract syntax (e.g., intOp.ml or floatOp.ml) should be place in a directory titled syntax.

Describe alternatives you've considered
Alternatives have yet to be considered.

Additional context
No additional context.

Missing simplifications

Some simplifications are missing/incomplete.

Current:
(int.add (int.add $_descending 3) 10)

Should be:
(int.add $_descending 13)

Bring ECMA-SL's concrete evaluation to encoding

Needed in order to allow for the completion of formalsec/ECMA-SL#20

  • โ˜‘๏ธ Exists
  • โŒ TODO
  • โ›” Will not support
  • โ— Might exist, needs verification
  • โ“ Don't know yet, don't add for now

Unary

Operators Status New Name
Typeof โ›”
Neg โ˜‘๏ธ
BitwiseNot โ˜‘๏ธ
LogicalNot โ˜‘๏ธ
IntToFloat โ˜‘๏ธ
IntToString โ˜‘๏ธ
IntToFourHex โ›”
OctalToDecimal โ›”
FloatToInt โ˜‘๏ธ
FloatToString โ˜‘๏ธ
ToInt โ›”
ToInt32 โ›”
ToUint16 โ›”
ToUint32 โ›”
IsNaN โ˜‘๏ธ
StringToInt โ˜‘๏ธ
StringToFloat โ˜‘๏ธ
FromCharCode โ˜‘๏ธ
FromCharCodeU โ›”
ToCharCode โ˜‘๏ธ
ToCharCodeU โ›”
ToLowerCase โ›”
ToUpperCase โ›”
Trim โ˜‘๏ธ
StringLen โ˜‘๏ธ Length
StringLenU โ›”
StringConcat โ˜‘๏ธ
ObjectToList โ›”
ObjectFields โ›”
ArrayLen โ›”
ListToArray โ›”
ListHead โŒ Head
ListTail โŒ Tail
ListLen โŒ Length
ListSort โ›”
ListReverse โŒ Reverse
ListRemoveLast โ›”
TupleFirst โŒ Head
TupleSecond โŒ Tail
TupleLen โŒ Length
FloatToByte โ›”
Float32ToLEBytes โ›”
Float32ToBEBytes โ›”
Float64ToLEBytes โ›”
Float64ToBEBytes โ›”
Float32FromLEBytes โ›”
Float32FromBEBytes โ›”
Float64FromLEBytes โ›”
Float64FromBEBytes โ›”
BytesToString โ›”
Random โ›”
Abs โ˜‘๏ธ
Sqrt โ˜‘๏ธ
Ceil โ˜‘๏ธ
Floor โ˜‘๏ธ
Trunc โ˜‘๏ธ
Exp โ˜‘๏ธ
Log2 โ›”
LogE โ›”
Log10 โ›”
Sin โ›”
Cos โ›”
Tan โ›”
Sinh โ›”
Cosh โ›”
Tanh โ›”
Asin โ›”
Acos โ›”
Atan โ›”
Utf8Decode โ›”
HexDecode โ›”
ParseNumber โ›”
ParseString โ›”
ParseDate โ›”

Binary

Operator Status New Name
Plus โ˜‘๏ธ
Minus โ˜‘๏ธ
Times โ˜‘๏ธ
Div โ˜‘๏ธ
Modulo โ˜‘๏ธ
Pow โ˜‘๏ธ
BitwiseAnd โ˜‘๏ธ
BitwiseOr โ˜‘๏ธ
BitwiseXor โ˜‘๏ธ
ShiftLeft โ˜‘๏ธ
ShiftRight โ˜‘๏ธ
ShiftRightLogical โ˜‘๏ธ
LogicalAnd โ˜‘๏ธ
LogicalOr โ˜‘๏ธ
SCLogicalAnd โ˜‘๏ธ
SCLogicalOr โ˜‘๏ธ
Eq โ˜‘๏ธ
NE โ˜‘๏ธ
Lt โ˜‘๏ธ
Gt โ˜‘๏ธ
Le โ˜‘๏ธ
Ge โ˜‘๏ธ
ToPrecision โ›”
ToExponential โ›”
ToFixed โ›”
ObjectMem โ›”
StringNth โ˜‘๏ธ
StringNthU โ›”
StringSplit โ›”
ArrayMake โ›”
ArrayNth โ›”
ListMem โ›”
ListNth โŒ At
ListAdd โŒ List_append_last
ListPrepend โŒ List_append
ListConcat โŒ Concat
ListRemove โ›”
ListRemoveNth โ›”
TupleNth โŒ At
IntToBEBytes โ›”
IntFromLEBytes โ›”
UintFromLEBytes โ›”
Min โ˜‘๏ธ
Max โ˜‘๏ธ
Atan2 โ›”

Ternary

Operator Status New Name
ITE โ˜‘๏ธ
StringSubstr โ˜‘๏ธ
StringSubstrU โ›”
ArraySet โ›”
ListSet โŒ List_set

N-Ary

Operator Status
NAryLogicalAnd โ›”
NAryLogicalOr โ›”
ArrayExpr โ˜‘๏ธ
ListExpr โ˜‘๏ธ
TupleExpr โ˜‘๏ธ

Fix display of gigantic floats in `Model.pp`

Model:
    (model
      (symbol_1 f64 (f64 -338460706455329128135018695364373065576360054171204343201037173805357995568625611429596369334345869072216864991017687935090688.000000))
      (symbol_2 i32 (i32 11821))
      (symbol_0 f32 (f32 nan))
      (symbol_3 i64 (i64 0)))

Abstract the underlying expression variant representations

Is your feature request related to a problem? Please describe.
Currently, one must directly use the variant representations from Expressions and Types to build expressions of the abstract syntax. This make expression building an extremely painful process.

Describe the solution you'd like
To solve this, create the following six modules: Integer, Real, Boolean, Strings, FloatingPoint and BitVector that expose mk_ function constructors. The obvious advantage of this feature is the employment of ocamldoc for documention.

Describe alternatives you've considered
No alternatives.

Additional context
No additional context required.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.