[quandary] Simplify endpoints config

Reviewed By: ngorogiannis

Differential Revision: D13465306

fbshipit-source-id: 18d25d048
master
Mehdi Bouaziz 6 years ago committed by Facebook Github Bot
parent 19faf643dc
commit a6d78db9b5

@ -54,8 +54,6 @@ module SourceKind = struct
(QuandaryConfig.Source.of_json Config.quandary_sources) (QuandaryConfig.Source.of_json Config.quandary_sources)
let endpoints = String.Set.of_list (QuandaryConfig.Endpoint.of_json Config.quandary_endpoints)
(* return a list of source kinds if [procedure_name] is in the list of externally specified sources *) (* return a list of source kinds if [procedure_name] is in the list of externally specified sources *)
let get_external_source qualified_pname = let get_external_source qualified_pname =
let return = None in let return = None in
@ -164,7 +162,7 @@ module SourceKind = struct
(Typ.Procname.ObjC_Cpp.get_class_name cpp_pname) (Typ.Procname.ObjC_Cpp.get_class_name cpp_pname)
(Typ.Procname.get_method pname) (Typ.Procname.get_method pname)
in in
if String.Set.mem endpoints qualified_pname then if QuandaryConfig.is_endpoint qualified_pname then
taint_all_but_this_and_return ~make_source:(fun name desc -> taint_all_but_this_and_return ~make_source:(fun name desc ->
UserControlledEndpoint (name, desc) ) UserControlledEndpoint (name, desc) )
else if overrides_service_method pname tenv then else if overrides_service_method pname tenv then

@ -74,9 +74,7 @@ module Sanitizer = struct
[] []
end end
module Endpoint = struct module Endpoints = struct
type t = string
let of_json = function let of_json = function
| `List endpoints -> | `List endpoints ->
let parse_endpoint = Yojson.Basic.Util.to_string in let parse_endpoint = Yojson.Basic.Util.to_string in
@ -84,3 +82,7 @@ module Endpoint = struct
| _ -> | _ ->
[] []
end end
let is_endpoint =
let endpoints = lazy (String.Set.of_list (Endpoints.of_json Config.quandary_endpoints)) in
fun name -> String.Set.mem (Lazy.force endpoints) name

@ -27,9 +27,4 @@ module Sanitizer : sig
val of_json : [> `List of Yojson.Basic.json list] -> t list val of_json : [> `List of Yojson.Basic.json list] -> t list
end end
module Endpoint : sig val is_endpoint : string -> bool
(** name of endpoint class *)
type t = string
val of_json : [> `List of Yojson.Basic.json list] -> t list
end

@ -116,14 +116,10 @@ module Make (TaintSpecification : TaintSpec.S) = struct
access_tree access_tree
let endpoints =
lazy (String.Set.of_list (QuandaryConfig.Endpoint.of_json Config.quandary_endpoints))
let is_endpoint source = let is_endpoint source =
match CallSite.pname (TraceDomain.Source.call_site source) with match CallSite.pname (TraceDomain.Source.call_site source) with
| Typ.Procname.Java java_pname -> | Typ.Procname.Java java_pname ->
String.Set.mem (Lazy.force endpoints) (Typ.Procname.Java.get_class_name java_pname) QuandaryConfig.is_endpoint (Typ.Procname.Java.get_class_name java_pname)
| _ -> | _ ->
false false

Loading…
Cancel
Save