[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
| _ ->
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)

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

@ -18,6 +18,9 @@ module type Spec = sig
(** should a flow originating at source and entering sink be reported? *)
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
module type S = sig
@ -35,8 +38,8 @@ 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
(** get logging-ready exceptions for the reportable source-sink flows in this trace *)
val get_reportable_exns : t -> exn list
(** create a trace from a source *)
val of_source : Source.t -> t
@ -102,18 +105,10 @@ 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 get_reportable_exns t =
IList.map
(fun (source, sink, passthroughs) -> Spec.get_reportable_exn source sink passthroughs)
(get_reports t)
let of_source source =
let sources = Sources.singleton source in

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

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

Loading…
Cancel
Save