@@ -241,12 +241,6 @@ type var =
241241 | Control_var
242242
243243type source = {
244- rule_id : Rule_ID .t ;
245- (* EXPERIMENT: Group taint rules
246-
247- We keep track of rule_id for when we run taint on groups of taint rules.
248- See Taint_rule_group.mli for details. But we use this to distinguish
249- taints that belong to different rules. *)
250244 call_trace : R .taint_source call_trace ;
251245 label : string ;
252246 (* This is needed because we may change the label of a taint,
@@ -261,13 +255,6 @@ type source = {
261255and orig = Src of source | Var of var
262256and taint = { orig : orig ; rev_tokens : rev_tainted_tokens }
263257
264- (* * [is_valid_taint_for_rule rule_id taint] returns [true] if [taint] is valid for the
265- rule with id [rule_id], otherwise returns [false]. *)
266- let is_valid_taint_for_rule (rule_id : Rule_ID.t ) (taint : taint ) : bool =
267- match taint.orig with
268- | Var _ -> true
269- | Src source -> Rule_ID. equal source.rule_id rule_id
270-
271258(* See NOTE "on compare functions" *)
272259let compare_precondition (_ts1 , f1 ) (_ts2 , f2 ) =
273260 (* We don't consider the "incoming" taints here, assuming both
@@ -293,55 +280,36 @@ let compare_var v1 v2 =
293280
294281(* See NOTE "on compare functions" *)
295282let compare_source
296- {
297- rule_id = rule_id1 ;
298- call_trace = call_trace1 ;
299- label = label1 ;
300- precondition = precondition1 ;
301- }
302- {
303- rule_id = rule_id2 ;
304- call_trace = call_trace2 ;
305- label = label2 ;
306- precondition = precondition2 ;
307- } =
283+ { call_trace = call_trace1 ; label = label1 ; precondition = precondition1 }
284+ { call_trace = call_trace2 ; label = label2 ; precondition = precondition2 } =
308285 (* Comparing metavariable environments this way is not robust, e.g.:
309286 * [("$A",e1);("$B",e2)] is not considered equal to [("$B",e2);("$A",e1)].
310287 * For our purposes, this is OK.
311288 *)
312289 let pm1, ts1 = pm_of_trace call_trace1
313290 and pm2, ts2 = pm_of_trace call_trace2 in
314- (* We compare rule ids, because when we run dataflow with a group of rules,
315- * we could have taints that belong to different rules.
316- *
317- * Tean: We could change this comparison in the future. Right now, each
318- * source has a rule id attached to it, but it could be the case that if they
319- * actually correspond to the same source, we could merge them in some way? *)
320- match Rule_ID. compare rule_id1 rule_id2 with
291+ match compare_matches pm1 pm2 with
321292 | 0 -> (
322- match compare_matches pm1 pm2 with
293+ let l1 = label1 ^ ts1.R. label in
294+ let l2 = label2 ^ ts2.R. label in
295+ match String. compare l1 l2 with
323296 | 0 -> (
324- let l1 = label1 ^ ts1.R. label in
325- let l2 = label2 ^ ts2.R. label in
326- match String. compare l1 l2 with
327- | 0 -> (
328- (* It's important that we include preconditions as a distinguishing factor
297+ (* It's important that we include preconditions as a distinguishing factor
329298 between two taints.
330299
331300 Otherwise, suppose that we had a taint with label A with precondition `false`
332301 and one with precondition `true`. Obviously, only one actually exists. But
333302 if we pick the wrong one, we might fallaciously say a taint label finding does
334303 not actually occur.
335304 *)
336- match (precondition1, precondition2) with
337- | None , _
338- | _ , None ->
339- (* 'None' here is the same as 'true', although the `requires` of both taints
340- * may not be the same, in this specific case we consider them "the same",
341- * see 'pick_best_taint'. *)
342- 0
343- | Some pre1 , Some pre2 -> compare_precondition pre1 pre2)
344- | other -> other)
305+ match (precondition1, precondition2) with
306+ | None , _
307+ | _ , None ->
308+ (* 'None' here is the same as 'true', although the `requires` of both taints
309+ * may not be the same, in this specific case we consider them "the same",
310+ * see 'pick_best_taint'. *)
311+ 0
312+ | Some pre1 , Some pre2 -> compare_precondition pre1 pre2)
345313 | other -> other)
346314 | other -> other
347315
@@ -377,13 +345,11 @@ let show_var var =
377345 | Taint_in_shape_var lval -> " '<" ^ show_lval lval ^ " >"
378346 | Control_var -> " '<control>"
379347
380- let rec show_source { call_trace; rule_id = _ ; label; precondition } =
348+ let rec show_source { call_trace; label; precondition } =
381349 (* We want to show the actual label, not the originating label.
382350 This may change, for instance, if we have ever propagated this taint to
383351 a different label.
384352 *)
385- (* TODO: Show rule_id? Not showing by default because it clutters debug
386- * output. It could also cause conflicts with snapshot tests. *)
387353 let pm, ts = pm_of_trace call_trace in
388354 let matched_str =
389355 let tok1, tok2 = pm.range_loc in
@@ -753,7 +719,6 @@ let src_of_pm ~incoming ((pm : PM.t), (source : Rule.taint_source)) =
753719 Some
754720 (Src
755721 {
756- rule_id = pm.rule_id.id;
757722 call_trace = PM (pm, source);
758723 label = source.label;
759724 precondition = None ;
@@ -767,12 +732,7 @@ let src_of_pm ~incoming ((pm : PM.t), (source : Rule.taint_source)) =
767732 in
768733 Some
769734 (Src
770- {
771- rule_id = pm.rule_id.id;
772- call_trace = PM (pm, source);
773- label = source.label;
774- precondition;
775- })
735+ { call_trace = PM (pm, source); label = source.label; precondition })
776736
777737let taint_of_pm ~incoming pm =
778738 match src_of_pm ~incoming pm with
0 commit comments