package pfff

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file check_all_generic.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(* Yoann Padioleau
 *
 * Copyright (C) 2010-2012 Facebook
 * Copyright (C) 2019 r2c
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation, with the
 * special exception on linking described in file license.txt.
 * 
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the file
 * license.txt for more details.
 *)

(*****************************************************************************)
(* Prelude *)
(*****************************************************************************)
(*
 * A driver for our different checkers:
 * 
 * todo:
 *  - use/def of global entities (functions, classes)
 *  - use/def of local variables
 *  - function/method call arity
 *  - dataflow based useless assignments
 *  - type checker (e.g. wrong type of argument, expr is not a bool,
 *    use of array instead of scalar, etc)
 *  - record checker (fields)
 *  - protocol checker, statistical analysis a la Engler
 *  - ...
 *)

(*****************************************************************************)
(* Main entry points *)
(*****************************************************************************)

let check_file ?(verbose=true) ?(find_entity=None) ast =

 Common.save_excursion Flag_linter.verbose_checking verbose (fun() ->

  (* todo? some unsugaring? *)

  (* even if find_entity=None, check_and_annotate_program can find
   * interesting bugs on local variables. There will be false positives
   * but it's better than nothing.
   *)
  (* Check_variables_php.check_and_annotate_program find_entity ast; *)

  Check_cfg_generic.check_program ast;

(*
  (* not ready yet: Check_dfg_php.check_program ?find_entity ast; *)
  Check_micro_clones_php.check ast;
*)
  (* work only when have a find_entity; requires a global view of the code *)
  find_entity |> Common.do_option (fun _find_entity ->
(*
    Check_functions_php.check_program find_entity ast;
    Check_classes_php.check_program   find_entity ast;
*)
    (* could have a Check_typedefs_php.check_program but hack will
     * already check the important things so no point doing redundant
     * checks.
     *)
    ()
  );
  ()
 )
OCaml

Innovation. Community. Security.