From 91071af3ad274080535dcfcee9c9a4f586fb0bad Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Fri, 2 Sep 2016 10:04:48 -0700 Subject: [PATCH] logging errors Reviewed By: dkgi Differential Revision: D3806718 fbshipit-source-id: 3abe08a --- infer/lib/python/inferlib/issues.py | 1 + infer/src/quandary/TaintAnalysis.ml | 4 ++++ infer/src/quandary/Trace.ml | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/infer/lib/python/inferlib/issues.py b/infer/lib/python/inferlib/issues.py index 310bba404..0a75bfa15 100644 --- a/infer/lib/python/inferlib/issues.py +++ b/infer/lib/python/inferlib/issues.py @@ -60,6 +60,7 @@ ISSUE_TYPES = [ 'REGISTERED_OBSERVER_BEING_DEALLOCATED', 'ASSIGN_POINTER_WARNING', 'GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL', + 'QUANDARY_TAINT_ERROR', # TODO (t11307776): Turn this back on once some of the FP issues are fixed 'UNSAFE_GUARDED_BY_ACCESS', ] diff --git a/infer/src/quandary/TaintAnalysis.ml b/infer/src/quandary/TaintAnalysis.ml index 12c4371ac..ce6bdd24d 100644 --- a/infer/src/quandary/TaintAnalysis.ml +++ b/infer/src/quandary/TaintAnalysis.ml @@ -134,6 +134,10 @@ module Make (TraceDomain : Trace.S) = struct | Some (actual_trace, _) -> (* add callee_pname to actual trace as a sink *) let actual_trace' = TraceDomain.add_sink sink actual_trace in + TraceDomain.log_reports + actual_trace' + (Cfg.Procdesc.get_proc_name proc_data.ProcData.pdesc) + loc; TaintDomain.add_trace actual_ap actual_trace' access_tree_acc | None -> access_tree_acc diff --git a/infer/src/quandary/Trace.ml b/infer/src/quandary/Trace.ml index 1de7627fa..3c4f4dcc4 100644 --- a/infer/src/quandary/Trace.ml +++ b/infer/src/quandary/Trace.ml @@ -35,6 +35,9 @@ module type S = sig (** get the reportable source-sink flows in this trace *) val get_reports : t -> (Source.t * Sink.t * Passthrough.Set.t) list + (** log the reportable source-sink flows in this trace *) + val log_reports : t -> Procname.t -> Location.t -> unit + (** create a trace from a source *) val of_source : Source.t -> t @@ -99,6 +102,19 @@ module Make (Spec : Spec) = struct else acc in Sources.fold (fun source acc -> Sinks.fold (report_one source) t.sinks acc) t.sources [] + let log_reports t pname loc = + let report_one (source, sink, passthroughs) = + let pp_error fmt () = + F.fprintf + fmt + "Error: %a -> %a via %a" + Source.pp source Sink.pp sink Passthrough.Set.pp passthroughs in + let msg = "QUANDARY_TAINT_ERROR" in + let description = pp_to_string pp_error () in + let exn = Exceptions.Checkers (msg, Localise.verbatim_desc description) in + Reporting.log_error pname exn ~loc in + IList.iter report_one (get_reports t) + let of_source source = let sources = Sources.singleton source in let passthroughs = Passthrough.Set.empty in