[quandary] pass call flags to sink creation

Reviewed By: mbouaziz

Differential Revision: D7607708

fbshipit-source-id: e78fb97
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent 0820b5e81e
commit cfa2dd5f83

@ -14,13 +14,13 @@ module L = Logging
module type Kind = sig module type Kind = sig
include TraceElem.Kind include TraceElem.Kind
val get : Typ.Procname.t -> HilExp.t list -> Tenv.t -> (t * IntSet.t) option val get : Typ.Procname.t -> HilExp.t list -> CallFlags.t -> Tenv.t -> (t * IntSet.t) option
end end
module type S = sig module type S = sig
include TraceElem.S include TraceElem.S
val get : CallSite.t -> HilExp.t list -> Tenv.t -> t option val get : CallSite.t -> HilExp.t list -> CallFlags.t -> Tenv.t -> t option
val indexes : t -> IntSet.t val indexes : t -> IntSet.t
end end
@ -38,8 +38,8 @@ module Make (Kind : Kind) = struct
let make ?(indexes= IntSet.empty) kind site = {kind; site; indexes} let make ?(indexes= IntSet.empty) kind site = {kind; site; indexes}
let get site actuals tenv = let get site actuals call_flags tenv =
match Kind.get (CallSite.pname site) actuals tenv with match Kind.get (CallSite.pname site) actuals call_flags tenv with
| Some (kind, indexes) -> | Some (kind, indexes) ->
Some {kind; site; indexes} Some {kind; site; indexes}
| None -> | None ->

@ -12,14 +12,14 @@ open! IStd
module type Kind = sig module type Kind = sig
include TraceElem.Kind include TraceElem.Kind
val get : Typ.Procname.t -> HilExp.t list -> Tenv.t -> (t * IntSet.t) option val get : Typ.Procname.t -> HilExp.t list -> CallFlags.t -> Tenv.t -> (t * IntSet.t) option
(** return Some kind if the given procname/actuals are a sink, None otherwise *) (** return Some kind if the given procname/actuals are a sink, None otherwise *)
end end
module type S = sig module type S = sig
include TraceElem.S include TraceElem.S
val get : CallSite.t -> HilExp.t list -> Tenv.t -> t option val get : CallSite.t -> HilExp.t list -> CallFlags.t -> Tenv.t -> t option
(** return Some sink if the given call site/actuals are a sink, None otherwise *) (** return Some sink if the given call site/actuals are a sink, None otherwise *)
val indexes : t -> IntSet.t val indexes : t -> IntSet.t

@ -32,7 +32,7 @@ end
module MakeSink (TraceElem : TraceElem.S) = struct module MakeSink (TraceElem : TraceElem.S) = struct
include TraceElem include TraceElem
let get _ _ _ = None let get _ _ _ _ = None
let indexes _ = IntSet.empty let indexes _ = IntSet.empty
end end

@ -271,7 +271,7 @@ module SinkKind = struct
external_sinks external_sinks
let get pname actuals _ = let get pname actuals _ _ =
let is_buffer_like pname = let is_buffer_like pname =
(* assume it's a buffer class if it's "vector-y", "array-y", or "string-y". don't want to (* assume it's a buffer class if it's "vector-y", "array-y", or "string-y". don't want to
report on accesses to maps etc., but also want to recognize custom vectors like fbvector report on accesses to maps etc., but also want to recognize custom vectors like fbvector

@ -309,7 +309,7 @@ module SinkKind = struct
(QuandaryConfig.Sink.of_json Config.quandary_sinks) (QuandaryConfig.Sink.of_json Config.quandary_sinks)
let get pname actuals tenv = let get pname actuals _ tenv =
match pname with match pname with
| Typ.Procname.Java java_pname | Typ.Procname.Java java_pname
-> ( -> (

@ -464,7 +464,8 @@ module Make (TaintSpecification : TaintSpec.S) = struct
List.map ~f:(fun index_ae -> HilExp.AccessExpression index_ae) indexes List.map ~f:(fun index_ae -> HilExp.AccessExpression index_ae) indexes
in in
let sinks = let sinks =
TraceDomain.Sink.get dummy_call_site dummy_actuals proc_data.ProcData.tenv TraceDomain.Sink.get dummy_call_site dummy_actuals CallFlags.default
proc_data.ProcData.tenv
in in
let astate_acc_result = let astate_acc_result =
match sinks with match sinks with
@ -533,7 +534,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct
|> add_sinks_for_access_path lhs_access_expr loc |> exec_write lhs_access_expr rhs_exp |> add_sinks_for_access_path lhs_access_expr loc |> exec_write lhs_access_expr rhs_exp
| Assume (assume_exp, _, _, loc) -> | Assume (assume_exp, _, _, loc) ->
add_sources_sinks_for_exp assume_exp loc astate add_sources_sinks_for_exp assume_exp loc astate
| Call (ret_opt, Direct called_pname, actuals, _, callee_loc) -> | Call (ret_opt, Direct called_pname, actuals, call_flags, callee_loc) ->
let astate = let astate =
List.fold List.fold
~f:(fun acc exp -> add_sources_sinks_for_exp exp callee_loc acc) ~f:(fun acc exp -> add_sources_sinks_for_exp exp callee_loc acc)
@ -666,7 +667,9 @@ module Make (TaintSpecification : TaintSpec.S) = struct
let astate_with_sink = let astate_with_sink =
if List.is_empty actuals then astate if List.is_empty actuals then astate
else else
match TraceDomain.Sink.get call_site actuals proc_data.ProcData.tenv with match
TraceDomain.Sink.get call_site actuals call_flags proc_data.ProcData.tenv
with
| Some sink -> | Some sink ->
add_sink sink actuals astate proc_data call_site add_sink sink actuals astate proc_data call_site
| None -> | None ->

@ -32,7 +32,7 @@ module MockTrace = Trace.Make (struct
module Sink = Sink.Make (struct module Sink = Sink.Make (struct
include MockTraceElem include MockTraceElem
let get pname _ _ = let get pname _ _ _ =
if String.is_prefix ~prefix:"SINK" (Typ.Procname.to_string pname) then if String.is_prefix ~prefix:"SINK" (Typ.Procname.to_string pname) then
Some (CallSite.make pname Location.dummy, IntSet.singleton 0) Some (CallSite.make pname Location.dummy, IntSet.singleton 0)
else None else None

Loading…
Cancel
Save