text stringlengths 0 601k |
|---|
type parameter_source_taint = { name : string ; sources : Sources . t list ; } |
type parameter_sanitize = { name : string ; sanitize : Domains . Sanitize . t ; } |
type error_expectation = { code : int ; pattern : string ; } |
type expectation = { kind : [ ` Function | ` Method | ` Override | ` Object | ` PropertySetter ] ; define_name : string ; source_parameters : parameter_source_taint list ; sink_parameters : parameter_taint list ; tito_parameters : parameter_taint list ; returns : Sources . t list ; errors : error_expectation list ; glo... |
let outcome ~ kind ( ? source_parameters = [ ] ) ( ? sink_parameters = [ ] ) ( ? tito_parameters = [ ] ) ( ? returns = [ ] ) ( ? errors = [ ] ) ( ? global_sanitizer = Domains . Sanitize . empty ) ( ? parameters_sanitizer = Domains . Sanitize . empty ) ( ? return_sanitizer = Domains . Sanitize . empty ) ( ? parameter_sa... |
let create_callable kind define_name = let name = Reference . create define_name in match kind with | ` Method -> Target . create_method name | ` Function -> Target . create_function name | ` PropertySetter -> Target . create_property_setter name | ` Override -> Target . create_override name | ` Object -> Target . crea... |
let check_expectation ~ get_model ~ get_errors ~ environment { kind ; define_name ; source_parameters ; sink_parameters ; tito_parameters ; returns ; errors ; global_sanitizer ; parameters_sanitizer ; return_sanitizer ; parameter_sanitizers ; analysis_modes = expected_analysis_modes ; } = let callable = create_callable... |
let initial_models_source = { | def _test_sink ( arg : TaintSink [ Test , Via [ special_sink ] ] ) : . . . def _test_source ( ) -> TaintSource [ Test , Via [ special_source ] ] : . . . def _tito ( * x : TaintInTaintOut , ** kw : TaintInTaintOut ) : . . . def eval ( arg : TaintSink [ RemoteCodeExecution ] ) : . . . def ... |
let get_initial_models ~ context = let global_resolution = Test . ScratchProject . setup ~ context [ ] |> Test . ScratchProject . build_global_resolution in let { ModelParser . models ; errors ; _ } = ModelParser . parse ~ resolution : ( TypeCheck . resolution global_resolution ( module TypeCheck . DummyContext ) ) ~ s... |
type test_environment = { static_analysis_configuration : Configuration . StaticAnalysis . t ; callgraph : DependencyGraph . callgraph ; overrides : DependencyGraph . t ; callables_to_analyze : Target . t list ; initial_callables : Target . t list ; stubs : Target . t list ; override_targets : Target . t list ; initial... |
let set_up_decorator_inlining ~ handle models = let decorators_to_skip = models >>| Analysis . InlineDecorator . decorators_to_skip ~ path ( : PyrePath . create_absolute handle ) |> Option . value ~ default [ ] : in List . iter decorators_to_skip ~ f ( : fun decorator -> Analysis . InlineDecorator . DecoratorsToSkip . ... |
let initialize ( ? handle = " test . py " ) ? models_source ( ? add_initial_models = true ) ? find_missing_flows ( ? taint_configuration = TaintConfiguration . default ) ~ context source_content = let configuration , environment , errors = let project = Test . ScratchProject . setup ~ context [ handle , source_content ... |
let assert_ver_file ocs pkg ver oasis tarball_org = let mk_fn bn = in_dist_dir ocs ( FilePath . make_filename [ pkg ; ver ; bn ] ) in let ver = assert_create_file ( mk_fn " storage . sexp " ) ; odb_run ( fun ~ ctxt ( ) -> ODBPkgVer . from_file ~ ctxt ( mk_fn " storage . sexp " ) ) in let tarball_fn = mk_fn ver . tarbal... |
let upload ocs date fn = let fn_sexp = in_incoming_dir ocs ( sexp_of_tarball fn ) in let fn_tarball = in_incoming_dir ocs fn in let tm = Calendar . to_unixfloat ( Printer . Calendar . from_string date ) in if ! verbose then Printf . eprintf " Copying file % s to % s \ n " %! ( in_data_dir fn ) ( fn_tarball ) ; cp [ in_... |
let tests = let one ocs ( fn , time , pkg , ver , oasis ) ( ) = upload ocs time fn ; assert_ver_file ocs pkg ver oasis ( in_data_dir fn ) in let vecs = [ " baz_3 . O ~ alpha1 . zip " , " 2010 - 07 - 31 15 : 35 : 09 " , " baz " , " 3 . 0 ~ alpha1 " , true ; " foo - 0 . 1 . 0 . tar . gz " , " 2010 - 07 - 30 16 : 00 : 00 ... |
let all_tests_ok = ref true ; ; |
let finish ( ) = match ! all_tests_ok with | true -> print_endline " \ nAll tests succeeded . " | _ -> print_endline " \ n \ n ********* Test suite failed . ***********\ n " ; ; |
let test_num = ref ( - 1 ) ; ; |
let print_test_number ( ) = print_string " " ; print_int ! test_num ; flush stdout ; ; |
let next_test ( ) = incr test_num ; print_test_number ( ) ; ; |
let print_test_fail ( ) = all_tests_ok := false ; print_string ( Printf . sprintf " \ n ********* Test number % i failed ***********\ n " ! test_num ) ; ; |
let print_failure_test_fail ( ) = all_tests_ok := false ; print_string ( Printf . sprintf " \ n ********* Failure Test number % i incorrectly failed ***********\ n " ! test_num ) ; ; |
let print_failure_test_succeed ( ) = all_tests_ok := false ; print_string ( Printf . sprintf " \ n ********* Failure Test number % i failed to fail ***********\ n " ! test_num ) ; ; |
let test b = next_test ( ) ; if not b then print_test_fail ( ) ; ; |
let test_raises_exc_p pred f x = next_test ( ) ; try ignore ( f x ) ; print_failure_test_succeed ( ) ; false with | x -> pred x || ( print_failure_test_fail ( ) ; false ) ; ; |
let test_raises_some_exc f = test_raises_exc_p ( fun _ -> true ) f ; ; |
let test_raises_this_exc exc = test_raises_exc_p ( fun x -> x = exc ) ; ; |
let test_raises_this_failure s f x = test_raises_exc_p ( fun x -> x = Failure s ) f x ; ; |
let test_raises_some_failure f x = test_raises_exc_p ( function Failure _ -> true | _ -> false ) f x ; ; |
let failure_test f x s = test_raises_this_failure s f x ; ; |
let scan_failure_test f x = test_raises_exc_p ( function Scan_failure _ -> true | _ -> false ) f x ; ; |
let unit ppf ( ) = Format . fprintf ppf " ( ) " |
let float ppf f = Format . fprintf ppf " . % 10f " f |
let int64 ppf i = Format . fprintf ppf " % Ld " i |
let raw_span ppf ( d , ps ) = Format . fprintf ppf " [ @< 1 ( >% d , @ % Ld ) ] " @ d ps |
let eq_raw_span = eq ~ eq ( ) := ~ pp : raw_span |
let eq_span = eq ~ eq : Ptime . Span . equal ~ pp : span |
let eq_span_opt = eq_option ~ eq : Ptime . Span . equal ~ pp : span |
let eq_stamp = eq ~ eq : Ptime . equal ~ pp : stamp |
let eq_stamp_opt = eq_option ~ eq : Ptime . equal ~ pp : stamp |
let raw_date ppf ( y , m , d ) = Format . fprintf ppf " ( % d , % d , % d ) " y m d |
let eq_date = eq ~ eq ( ) := ~ pp : raw_date |
let raw_time ppf ( _ , ( ( hh , mm , ss ) , tz ) ) = Format . fprintf ppf " ( % d , % d , % d ) , % d " hh mm ss tz |
let raw_date_time ppf ( ( y , m , d ) , ( ( hh , mm , ss ) , tz ) ) = Format . fprintf ppf " ( % d , % d , % d ) , ( ( % d , % d , % d ) , % d ) " y m d hh mm ss tz |
let eq_date_time v v ' = eq ~ eq ( ) := ~ pp : raw_date_time v v ' |
let eq_date_time_opt v v ' = eq_option ~ eq ( ) := ~ pp : raw_date_time v v ' |
let assert_option_intersection_equal expect actual = match ( expect , actual ) with | ( None , None ) -> assert true | ( Some a , Some b ) when a == b -> assert true | _ -> assert false |
let tests = " Intersections " >::: [ " An intersection encapsulates t and object " >:: ( fun test_ctxt -> let s = RTCSphere . build ( ) in let i = build 3 . 5 s [ ] in assert_equal 3 . 5 i . t ; assert ( s == i . shape ) ) ; " Aggregating intersections " >:: ( fun test_ctxt -> let s = RTCSphere . build ( ) in let i1 = ... |
let test msg producer consumer src dst = print_string msg ; print_newline ( ) ; let ic = open_in_bin src in let oc = open_out_bin dst in let ( in_fd , out_fd ) = Unix . pipe ( ) in let ipipe = Unix . in_channel_of_descr in_fd in let opipe = Unix . out_channel_of_descr out_fd in let prod = Thread . create producer ( ic ... |
let copy_file sz ( ic , oc ) = let buffer = String . create sz in let rec copy ( ) = let n = input ic buffer 0 sz in if n = 0 then ( ) else begin output oc buffer 0 n ; copy ( ) end in copy ( ) ; close_in ic ; close_out oc |
let copy_random sz ( ic , oc ) = let buffer = String . create sz in let rec copy ( ) = let s = 1 + Random . int sz in let n = input ic buffer 0 s in if n = 0 then ( ) else begin output oc buffer 0 n ; copy ( ) end in copy ( ) ; close_in ic ; close_out oc |
let copy_line ( ic , oc ) = try while true do output_string oc ( input_line ic ) ; output_char oc ' \ n ' done with End_of_file -> close_in ic ; close_out oc |
let make_lines ofile = let oc = open_out ofile in for i = 1 to 256 do output_string oc ( String . make ( i * 16 ) ' . ' ) ; output_char oc ' \ n ' done ; close_out oc |
let test_trunc_line ofile = print_string " truncated line " ; print_newline ( ) ; let oc = open_out ofile in output_string oc " A line without newline " ; ! close_out oc ; try let ic = open_in ofile in let s = input_line ic in close_in ic ; if s = " A line without newline " ! then print_string " passed " else print_str... |
let main ( ) = let ifile = Sys . argv . ( 1 ) in let ofile = Filename . temp_file " testio " " " in test " 256 - byte chunks , 256 - byte chunks " ( copy_file 256 ) ( copy_file 256 ) ifile ofile ; test " 4096 - byte chunks , 4096 - byte chunks " ( copy_file 4096 ) ( copy_file 4096 ) ifile ofile ; test " 65536 - byte ch... |
let _ = Unix . handle_unix_error main ( ) ; exit 0 |
type ( ' x , ' y ) poly = ( ' x , ' y ) Test . poly = { fst : ' x list ; snd : ( ' x , ' y ) poly option } |
type ' a p ' = ' a Test . p ' = A | Bb of ' a p ' | Ccccc of ' a |
type val1 = Test . val1 = { val1_x : int } |
type val2 = Test . val2 = { val2_x : val1 ; val2_y : val1 option } |
type mixed_record = Test . mixed_record = { field0 : int option ; field1 : float option ; field2 : string option ; field3 : Int64 . t ; field4 : float Atdgen_runtime . Util . ocaml_array ; field5 : bool option ; field6 : string option ; field7 : test_variant ; field8 : string Atdgen_runtime . Util . ocaml_array ; field... |
type test = Test . test = { x0 : int option ; x1 : float option ; x2 : mixed ; x3 : mixed_record list ; x4 : Int64 . t } |
type test_field_prefix = Test . test_field_prefix = { theprefix_hello : bool ; theprefix_world : int } |
type ' a generic = ' a Test . generic = { x294623 : int } |
type some_record = Test . some_record = { some_field : int } |
type precision = Test . precision = { sqrt2_5 : float ; small_2 : float ; large_2 : float } |
type floats = Test . floats = { f32 : float ; f64 : float } |
type extended = Test . extended = { b0x : int ; b1x : bool ; b2x : string ; b3x : string option ; b4x : string option ; b5x : float } |
type base = Test . base = { b0 : int ; b1 : bool } |
type ' a array = ' a Test . array |
type ' a abs3 = ' a Test . abs3 |
type ' a abs2 = ' a Test . abs2 |
type ' a abs1 = ' a Test . abs1 |
let write__19 write__a = ( Atdgen_runtime . Oj_run . write_list ( write__a ) ) |
let string_of__19 write__a ( ? len = 1024 ) x = let ob = Bi_outbuf . create len in write__19 write__a ob x ; Bi_outbuf . contents ob |
let read__19 read__a = ( Atdgen_runtime . Oj_run . read_list ( read__a ) ) |
let _19_of_string read__a s = read__19 read__a ( Yojson . Safe . init_lexer ( ) ) ( Lexing . from_string s ) |
let rec write_p ' write__a : _ -> ' a p ' -> _ = ( fun ob x -> match x with | A -> Bi_outbuf . add_string ob " " <\ A " " \> | Bb x -> Bi_outbuf . add_string ob " " <\ Bb " " ; \: ( write_p ' write__a ) ob x ; Bi_outbuf . add_char ob ' ' > | Ccccc x -> Bi_outbuf . add_string ob " " <\ Ccccc " " ; \: ( write__a ) ob x ;... |
let rec read_p ' read__a = ( fun p lb -> Yojson . Safe . read_space p lb ; match Yojson . Safe . start_any_variant p lb with | ` Edgy_bracket -> ( match Yojson . Safe . read_ident p lb with | " A " -> Yojson . Safe . read_space p lb ; Yojson . Safe . read_gt p lb ; ( A : ' a p ' ) | " Bb " -> Atdgen_runtime . Oj_run . ... |
let rec write_p = ( fun ob x -> match x with | ` A -> Bi_outbuf . add_string ob " " <\ A " " \> | ` B x -> Bi_outbuf . add_string ob " " <\ B " " ; \: ( write_r ) ob x ; Bi_outbuf . add_char ob ' ' > | ` C -> Bi_outbuf . add_string ob " " <\ C " " \> ) let ob = Bi_outbuf . create len in write_p ob x ; Bi_outbuf . conte... |
let rec read_p = ( fun p lb -> Yojson . Safe . read_space p lb ; match Yojson . Safe . start_any_variant p lb with | ` Edgy_bracket -> ( match Yojson . Safe . read_ident p lb with | " A " -> Yojson . Safe . read_space p lb ; Yojson . Safe . read_gt p lb ; ` A | " B " -> Atdgen_runtime . Oj_run . read_until_field_value ... |
let rec write__20 write__a write__b ob x = ( Atdgen_runtime . Oj_run . write_option ( write_poly write__a write__b ) let ob = Bi_outbuf . create len in write__20 write__a write__b ob x ; Bi_outbuf . contents ob fun ob ( x : ( ' x , ' y ) poly ) -> Bi_outbuf . add_char ob ' { ' ; let is_first = ref true in if ! is_first... |
let rec read__20 read__a read__b = ( fun p lb -> Yojson . Safe . read_space p lb ; match Yojson . Safe . start_any_variant p lb with | ` Edgy_bracket -> ( match Yojson . Safe . read_ident p lb with | " None " -> Yojson . Safe . read_space p lb ; Yojson . Safe . read_gt p lb ; ( None : _ option ) | " Some " -> Atdgen_ru... |
let rec write__2 ob x = ( Atdgen_runtime . Oj_run . write_list ( write_test_variant ) let ob = Bi_outbuf . create len in write__2 ob x ; Bi_outbuf . contents ob fun ob x -> match x with | ` Case1 -> Bi_outbuf . add_string ob " " <\ Case1 " " \> | ` Case2 x -> Bi_outbuf . add_string ob " " <\ Case2 " " ; \: ( Yojson . S... |
let rec read__2 p lb = ( Atdgen_runtime . Oj_run . read_list ( read_test_variant ) read__2 ( Yojson . Safe . init_lexer ( ) ) ( Lexing . from_string s ) fun p lb -> Yojson . Safe . read_space p lb ; match Yojson . Safe . start_any_variant p lb with | ` Edgy_bracket -> ( match Yojson . Safe . read_ident p lb with | " Ca... |
let rec write__1 : _ -> _ p ' -> _ = ( fun ob x -> match x with | A -> Bi_outbuf . add_string ob " " <\ A " " \> | Bb x -> Bi_outbuf . add_string ob " " <\ Bb " " ; \: ( write__1 ) ob x ; Bi_outbuf . add_char ob ' ' > | Ccccc x -> Bi_outbuf . add_string ob " " <\ Ccccc " " ; \: ( Yojson . Safe . write_int ) ob x ; Bi_o... |
let rec read__1 = ( fun p lb -> Yojson . Safe . read_space p lb ; match Yojson . Safe . start_any_variant p lb with | ` Edgy_bracket -> ( match Yojson . Safe . read_ident p lb with | " A " -> Yojson . Safe . read_space p lb ; Yojson . Safe . read_gt p lb ; ( A : _ p ' ) | " Bb " -> Atdgen_runtime . Oj_run . read_until_... |
let write_validated_string_check = ( Yojson . Safe . write_string ) |
let string_of_validated_string_check ( ? len = 1024 ) x = let ob = Bi_outbuf . create len in write_validated_string_check ob x ; Bi_outbuf . contents ob |
let read_validated_string_check = ( Atdgen_runtime . Oj_run . read_string ) |
let validated_string_check_of_string s = read_validated_string_check ( Yojson . Safe . init_lexer ( ) ) ( Lexing . from_string s ) |
let write__31 = ( Atdgen_runtime . Oj_run . write_list ( Yojson . Safe . write_string ) ) |
let string_of__31 ( ? len = 1024 ) x = let ob = Bi_outbuf . create len in write__31 ob x ; Bi_outbuf . contents ob |
let read__31 = ( Atdgen_runtime . Oj_run . read_list ( Atdgen_runtime . Oj_run . read_string ) ) |
let _31_of_string s = read__31 ( Yojson . Safe . init_lexer ( ) ) ( Lexing . from_string s ) |
let write_validate_me = ( write__31 ) |
let string_of_validate_me ( ? len = 1024 ) x = let ob = Bi_outbuf . create len in write_validate_me ob x ; Bi_outbuf . contents ob |
let read_validate_me = ( read__31 ) |
let validate_me_of_string s = read_validate_me ( Yojson . Safe . init_lexer ( ) ) ( Lexing . from_string s ) |
let write_val1 : _ -> val1 -> _ = ( fun ob ( x : val1 ) -> Bi_outbuf . add_char ob ' { ' ; let is_first = ref true in if ! is_first then is_first := false else Bi_outbuf . add_char ob ' , ' ; Bi_outbuf . add_string ob " " \ val1_x " " ; \: ( Yojson . Safe . write_int ) ob x . val1_x ; Bi_outbuf . add_char ob ' } ' ; ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.