Skip to content

Commit

Permalink
[inferpython][html] hide some attributes
Browse files Browse the repository at this point in the history
Summary: Python frontend is not interested by all attributes. We just hide them from the html debug.

Reviewed By: ngorogiannis

Differential Revision:
D67077620

Privacy Context Container: L1208441

fbshipit-source-id: f45135e2cf92a598162de207d009bc63244aaf85
  • Loading branch information
davidpichardie authored and facebook-github-bot committed Dec 11, 2024
1 parent a0d6821 commit 834871b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions infer/src/pulse/PulseBaseAddressAttributes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ let empty = Graph.empty

let filter = Graph.filter

let map = Graph.map

(* for an abstract value v, where f_keep(v) == false, find an abstract value v_keep, where
f_keep(v_keep) == true and where v_keep has taint propagated from v *)
let mk_transitive_taint_from_subst f_keep memory =
Expand Down Expand Up @@ -384,6 +386,8 @@ module type S = sig

val filter_with_discarded_addrs : (key -> bool) -> t -> t * AbstractValue.t list

val map : (Attributes.t -> Attributes.t) -> t -> t

val find_opt : key -> t -> Attributes.t option

val add_one : key -> Attribute.t -> t -> t
Expand Down
2 changes: 2 additions & 0 deletions infer/src/pulse/PulseBaseAddressAttributes.mli
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module type S = sig

val filter_with_discarded_addrs : (key -> bool) -> t -> t * AbstractValue.t list

val map : (Attributes.t -> Attributes.t) -> t -> t

val find_opt : key -> t -> Attributes.t option

val add_one : key -> Attribute.t -> t -> t
Expand Down
18 changes: 18 additions & 0 deletions infer/src/pulse/PulseBaseDomain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ let empty =
type cell = Memory.Edges.t * Attributes.t

let pp fmt {heap; stack; attrs} =
let attrs =
if Language.curr_language_is Python then
let filter_attribute (attr : Attribute.t) =
match attr with
| Attribute.Allocated _ | AwaitedAwaitable | MustNotBeTainted _ | StaticType _ | Tainted _
->
true
| _ ->
false
in
let attrs = AddressAttributes.map (Attributes.filter ~f:filter_attribute) attrs in
AddressAttributes.filter
(fun _ attr ->
let set = Attributes.filter attr ~f:filter_attribute in
not (Attributes.is_empty set) )
attrs
else attrs
in
F.fprintf fmt "{@[<v1> roots=@[<hv>%a@];@;mem =@[<hv>%a@];@;attrs=@[<hv>%a@];@]}" Stack.pp stack
Memory.pp heap AddressAttributes.pp attrs

Expand Down

0 comments on commit 834871b

Please sign in to comment.