diff --git a/infer/src/quandary/ClangTrace.ml b/infer/src/quandary/ClangTrace.ml index 7f8fbd8c7..c5ff34d5e 100644 --- a/infer/src/quandary/ClangTrace.ml +++ b/infer/src/quandary/ClangTrace.ml @@ -54,8 +54,6 @@ module SourceKind = struct (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 *) let get_external_source qualified_pname = let return = None in @@ -164,7 +162,7 @@ module SourceKind = struct (Typ.Procname.ObjC_Cpp.get_class_name cpp_pname) (Typ.Procname.get_method pname) 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 -> UserControlledEndpoint (name, desc) ) else if overrides_service_method pname tenv then diff --git a/infer/src/quandary/QuandaryConfig.ml b/infer/src/quandary/QuandaryConfig.ml index 648b55112..c82b8cbb1 100644 --- a/infer/src/quandary/QuandaryConfig.ml +++ b/infer/src/quandary/QuandaryConfig.ml @@ -74,9 +74,7 @@ module Sanitizer = struct [] end -module Endpoint = struct - type t = string - +module Endpoints = struct let of_json = function | `List endpoints -> let parse_endpoint = Yojson.Basic.Util.to_string in @@ -84,3 +82,7 @@ module Endpoint = struct | _ -> [] 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 diff --git a/infer/src/quandary/QuandaryConfig.mli b/infer/src/quandary/QuandaryConfig.mli index 35a638afb..4f7ae3024 100644 --- a/infer/src/quandary/QuandaryConfig.mli +++ b/infer/src/quandary/QuandaryConfig.mli @@ -27,9 +27,4 @@ module Sanitizer : sig val of_json : [> `List of Yojson.Basic.json list] -> t list end -module Endpoint : sig - (** name of endpoint class *) - type t = string - - val of_json : [> `List of Yojson.Basic.json list] -> t list -end +val is_endpoint : string -> bool diff --git a/infer/src/quandary/TaintAnalysis.ml b/infer/src/quandary/TaintAnalysis.ml index 0c0c4116e..189034b2e 100644 --- a/infer/src/quandary/TaintAnalysis.ml +++ b/infer/src/quandary/TaintAnalysis.ml @@ -116,14 +116,10 @@ module Make (TaintSpecification : TaintSpec.S) = struct access_tree - let endpoints = - lazy (String.Set.of_list (QuandaryConfig.Endpoint.of_json Config.quandary_endpoints)) - - let is_endpoint source = match CallSite.pname (TraceDomain.Source.call_site source) with | 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