Skip to content

Commit

Permalink
[taint] Remove unnecessary record field block_passed_to from a taint …
Browse files Browse the repository at this point in the history
…config unit

Summary: The information needed was already in the `Block` or `BlockNameRegex` variant of the `procedure_macther` type.

Reviewed By: geralt-encore

Differential Revision: D45608928

fbshipit-source-id: 10f8677a86db4b363df26755792b79d9d75f523c
  • Loading branch information
dulmarod authored and facebook-github-bot committed May 9, 2023
1 parent 0db8cee commit f6a046f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
10 changes: 4 additions & 6 deletions infer/src/pulse/PulseTaintConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,16 @@ module Unit = struct
{ procedure_matcher: procedure_matcher
; arguments: Pulse_config_t.argument_constraint list
; kinds: Kind.t list
; target: Target.t
; block_passed_to: procedure_matcher }
; target: Target.t }

let pp_arguments f arguments =
F.pp_print_string f (Pulse_config_j.string_of_argument_constraint arguments)


let pp f unit =
F.fprintf f "procedure_matcher=%a, arguments=%a, kinds=%a, target=%a, block_passed_to=%a"
pp_procedure_matcher unit.procedure_matcher (Pp.comma_seq pp_arguments) unit.arguments
(Pp.comma_seq Kind.pp) unit.kinds Target.pp unit.target pp_procedure_matcher
unit.block_passed_to
F.fprintf f "procedure_matcher=%a, arguments=%a, kinds=%a, target=%a" pp_procedure_matcher
unit.procedure_matcher (Pp.comma_seq pp_arguments) unit.arguments (Pp.comma_seq Kind.pp)
unit.kinds Target.pp unit.target
end

module SinkPolicy = struct
Expand Down
3 changes: 1 addition & 2 deletions infer/src/pulse/PulseTaintConfig.mli
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ module Unit : sig
{ procedure_matcher: procedure_matcher
; arguments: Pulse_config_t.argument_constraint list
; kinds: Kind.t list
; target: Target.t
; block_passed_to: procedure_matcher }
; target: Target.t }

val pp : F.formatter -> t -> unit
end
Expand Down
5 changes: 2 additions & 3 deletions infer/src/pulse/PulseTaintItemMatcher.ml
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ let matcher_of_config ~default_taint_target ~option_name matchers =
; kinds= TaintConfig.Kind.kinds_of_strings_opt matcher.kinds
; target=
TaintConfig.Target.target_of_gen_target
(Option.value ~default:default_taint_target matcher.taint_target)
; block_passed_to= procedure_matcher } )
(Option.value ~default:default_taint_target matcher.taint_target) } )


let type_matches tenv actual_typ types =
Expand Down Expand Up @@ -261,7 +260,7 @@ let procedure_matches tenv matchers ?block_passed_to proc_name actuals =
false
in
let block_passed_to_matches =
match (matcher.block_passed_to, block_passed_to) with
match (matcher.procedure_matcher, block_passed_to) with
| Block {name}, Some block_passed_to_proc_name ->
let proc_name_s = F.asprintf "%a" Procname.pp_verbose block_passed_to_proc_name in
String.is_substring ~substring:name proc_name_s
Expand Down
6 changes: 1 addition & 5 deletions infer/src/pulse/PulseTaintOperations.ml
Original file line number Diff line number Diff line change
Expand Up @@ -614,11 +614,7 @@ let pulse_models_to_treat_as_unknown_for_taint =
(* HACK: make a list of matchers just to reuse the matching code below *)
let dummy_matcher_of_procedure_matcher procedure_matcher =
let open TaintConfig in
{ Unit.procedure_matcher
; arguments= []
; kinds= []
; target= ReturnValue
; block_passed_to= Block {name= ""} }
{Unit.procedure_matcher; arguments= []; kinds= []; target= ReturnValue}
in
[ ClassAndMethodNames
{ class_names= ["java.lang.StringBuilder"]
Expand Down

0 comments on commit f6a046f

Please sign in to comment.