[quandary] moving logging of errors into analysis

Reviewed By: jeremydubreil

Differential Revision: D3850807

fbshipit-source-id: d34f1ab
master
Sam Blackshear 9 years ago committed by Facebook Github Bot 9
parent 31435fa936
commit d6d7293633

@ -185,4 +185,15 @@ include
true true
| _ -> | _ ->
false false
let get_reportable_exn 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
Exceptions.Checkers (msg, Localise.verbatim_desc description)
end) end)

@ -138,10 +138,10 @@ module Make (TraceDomain : QuandarySummary.Trace) = struct
| Some (actual_trace, _) -> | Some (actual_trace, _) ->
(* add callee_pname to actual trace as a sink *) (* add callee_pname to actual trace as a sink *)
let actual_trace' = TraceDomain.add_sink sink_param.sink actual_trace in let actual_trace' = TraceDomain.add_sink sink_param.sink actual_trace in
TraceDomain.log_reports let pname = Cfg.Procdesc.get_proc_name proc_data.ProcData.pdesc in
actual_trace' IList.iter
(Cfg.Procdesc.get_proc_name proc_data.ProcData.pdesc) (Reporting.log_error pname ~loc)
loc; (TraceDomain.get_reportable_exns actual_trace');
TaintDomain.add_trace actual_ap actual_trace' access_tree_acc TaintDomain.add_trace actual_ap actual_trace' access_tree_acc
| None -> | None ->
access_tree_acc access_tree_acc

@ -18,6 +18,9 @@ module type Spec = sig
(** should a flow originating at source and entering sink be reported? *) (** should a flow originating at source and entering sink be reported? *)
val should_report : Source.t -> Sink.t -> bool val should_report : Source.t -> Sink.t -> bool
(** get a loggable exception reporting a flow from source -> sink *)
val get_reportable_exn : Source.t -> Sink.t -> Passthrough.Set.t -> exn
end end
module type S = sig module type S = sig
@ -35,8 +38,8 @@ module type S = sig
(** get the reportable source-sink flows in this trace *) (** get the reportable source-sink flows in this trace *)
val get_reports : t -> (Source.t * Sink.t * Passthrough.Set.t) list val get_reports : t -> (Source.t * Sink.t * Passthrough.Set.t) list
(** log the reportable source-sink flows in this trace *) (** get logging-ready exceptions for the reportable source-sink flows in this trace *)
val log_reports : t -> Procname.t -> Location.t -> unit val get_reportable_exns : t -> exn list
(** create a trace from a source *) (** create a trace from a source *)
val of_source : Source.t -> t val of_source : Source.t -> t
@ -102,18 +105,10 @@ module Make (Spec : Spec) = struct
else acc in else acc in
Sources.fold (fun source acc -> Sinks.fold (report_one source) t.sinks acc) t.sources [] Sources.fold (fun source acc -> Sinks.fold (report_one source) t.sinks acc) t.sources []
let log_reports t pname loc = let get_reportable_exns t =
let report_one (source, sink, passthroughs) = IList.map
let pp_error fmt () = (fun (source, sink, passthroughs) -> Spec.get_reportable_exn source sink passthroughs)
F.fprintf (get_reports t)
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 of_source source =
let sources = Sources.singleton source in let sources = Sources.singleton source in

@ -56,7 +56,9 @@ module MockTrace = Trace.Make(struct
else [] else []
end end
let should_report _ _ = true let should_report _ _ = false
let get_reportable_exn _ _ _ = assert false
end) end)
module MockTaintAnalysis = TaintAnalysis.Make(struct module MockTaintAnalysis = TaintAnalysis.Make(struct

@ -76,6 +76,8 @@ module MockTrace = Trace.Make(struct
let should_report source sink = let should_report source sink =
Source.kind source = Sink.kind sink Source.kind source = Sink.kind sink
let get_reportable_exn _ _ _ = assert false
end) end)
let tests = let tests =

Loading…
Cancel
Save