From 834871b3d0ef9d417119398b7c5cb6e4fd40c4ef Mon Sep 17 00:00:00 2001 From: David Pichardie Date: Wed, 11 Dec 2024 06:23:44 -0800 Subject: [PATCH] [inferpython][html] hide some attributes 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 --- infer/src/pulse/PulseBaseAddressAttributes.ml | 4 ++++ infer/src/pulse/PulseBaseAddressAttributes.mli | 2 ++ infer/src/pulse/PulseBaseDomain.ml | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/infer/src/pulse/PulseBaseAddressAttributes.ml b/infer/src/pulse/PulseBaseAddressAttributes.ml index 7fe17bb5c29..70f10219e88 100644 --- a/infer/src/pulse/PulseBaseAddressAttributes.ml +++ b/infer/src/pulse/PulseBaseAddressAttributes.ml @@ -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 = @@ -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 diff --git a/infer/src/pulse/PulseBaseAddressAttributes.mli b/infer/src/pulse/PulseBaseAddressAttributes.mli index 9f4cae81577..d22f87e1ecc 100644 --- a/infer/src/pulse/PulseBaseAddressAttributes.mli +++ b/infer/src/pulse/PulseBaseAddressAttributes.mli @@ -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 diff --git a/infer/src/pulse/PulseBaseDomain.ml b/infer/src/pulse/PulseBaseDomain.ml index 97b0096ec18..2b88a6778c0 100644 --- a/infer/src/pulse/PulseBaseDomain.ml +++ b/infer/src/pulse/PulseBaseDomain.ml @@ -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 "{@[ roots=@[%a@];@;mem =@[%a@];@;attrs=@[%a@];@]}" Stack.pp stack Memory.pp heap AddressAttributes.pp attrs