Skip to content

Commit

Permalink
Make TriggeredPartialSink local transforms
Browse files Browse the repository at this point in the history
Summary:
So that the UI would remove the local transforms when expanding the sink trace,
and hence the sink trace can now be properly shown.

 {F1762727283}

 {F1762727409}

Reviewed By: arthaud

Differential Revision: D59945696

fbshipit-source-id: 0fb88477acd8941b4495e9217832de8b4769b932
  • Loading branch information
Tianhan Lu authored and facebook-github-bot committed Jul 22, 2024
1 parent 3a6f789 commit 3e8e3ba
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 55 deletions.
5 changes: 4 additions & 1 deletion source/interprocedural_analyses/taint/issue.ml
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ module TriggeredSinkForCall = struct
Some
(BackwardTaint.singleton
call_info
(Sinks.create_triggered_sink ~triggering_source:source partial_sink)
(Sinks.make_transform
~base:(PartialSink partial_sink)
~local:[TaintTransform.TriggeredPartialSink { triggering_source = source }]
~global:[])
frame
|> BackwardTaint.transform
ExtraTraceFirstHop.Set.Self
Expand Down
7 changes: 0 additions & 7 deletions source/interprocedural_analyses/taint/sinks.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ let make_transform ~local ~global ~base =
| _ -> Transform { local; global; base }


let create_triggered_sink ~triggering_source partial_sink =
make_transform
~base:(PartialSink partial_sink)
~local:[]
~global:[TaintTransform.TriggeredPartialSink { triggering_source }]


let ignore_kind_at_call = function
| Attach -> true
| _ -> false
Expand Down
2 changes: 0 additions & 2 deletions source/interprocedural_analyses/taint/sinks.mli
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ val name : string

val make_transform : local:TaintTransforms.t -> global:TaintTransforms.t -> base:t -> t

val create_triggered_sink : triggering_source:string -> PartialSink.t -> t

val ignore_kind_at_call : t -> bool

val apply_call : t -> t
Expand Down
18 changes: 12 additions & 6 deletions source/interprocedural_analyses/taint/test/configurationTest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2231,6 +2231,12 @@ let test_matching_kinds _ =
]
~possible_tito_transforms:[TaintTransforms.empty]
();
let create_triggered_sink ~triggering_source partial_sink =
Sinks.make_transform
~base:(PartialSink partial_sink)
~local:[]
~global:[TaintTransform.TriggeredPartialSink { triggering_source }]
in
assert_matching
~source_filter:["A"; "B"]
~configuration:
Expand Down Expand Up @@ -2302,26 +2308,26 @@ let test_matching_kinds _ =
[
Sinks.PartialSink "PartialSink1[a]";
Sinks.PartialSink "PartialSink3[a]";
Sinks.create_triggered_sink ~triggering_source:"B" "PartialSink1[a]";
Sinks.create_triggered_sink ~triggering_source:"D" "PartialSink3[a]";
create_triggered_sink ~triggering_source:"B" "PartialSink1[a]";
create_triggered_sink ~triggering_source:"D" "PartialSink3[a]";
] );
( Sources.NamedSource "B",
Sinks.Set.of_list
[
Sinks.PartialSink "PartialSink1[b]";
Sinks.create_triggered_sink ~triggering_source:"A" "PartialSink1[b]";
create_triggered_sink ~triggering_source:"A" "PartialSink1[b]";
] );
]
~matching_sources:
[
Sinks.PartialSink "PartialSink1[a]", Sources.Set.of_list [Sources.NamedSource "A"];
Sinks.PartialSink "PartialSink1[b]", Sources.Set.of_list [Sources.NamedSource "B"];
Sinks.PartialSink "PartialSink3[a]", Sources.Set.of_list [Sources.NamedSource "A"];
( Sinks.create_triggered_sink ~triggering_source:"D" "PartialSink3[a]",
( create_triggered_sink ~triggering_source:"D" "PartialSink3[a]",
Sources.Set.of_list [Sources.NamedSource "A"] );
( Sinks.create_triggered_sink ~triggering_source:"B" "PartialSink1[a]",
( create_triggered_sink ~triggering_source:"B" "PartialSink1[a]",
Sources.Set.of_list [Sources.NamedSource "A"] );
( Sinks.create_triggered_sink ~triggering_source:"A" "PartialSink1[b]",
( create_triggered_sink ~triggering_source:"A" "PartialSink1[b]",
Sources.Set.of_list [Sources.NamedSource "B"] );
]
~possible_tito_transforms:[TaintTransforms.empty]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"port": "leaf:y"
}
],
"kind": "Triggered[TestC]:PartialSink[ShareBothSinksRight]"
"kind": "Triggered[TestC]@PartialSink[ShareBothSinksRight]"
}
],
"origin": {
Expand Down Expand Up @@ -134,7 +134,7 @@
"port": "leaf:y"
}
],
"kind": "Triggered[TestC]:PartialSink[ShareBothSinksRight]"
"kind": "Triggered[TestC]@PartialSink[ShareBothSinksRight]"
}
],
"origin": {
Expand Down Expand Up @@ -210,7 +210,7 @@
"leaves": [
{ "name": "multiple_sources.Node.send", "port": "leaf:vc" }
],
"kind": "Triggered[UserControlled]:PartialSink[PermissiveContextSink]"
"kind": "Triggered[UserControlled]@PartialSink[PermissiveContextSink]"
}
],
"origin": {
Expand Down Expand Up @@ -291,7 +291,7 @@
"port": "leaf:vc"
}
],
"kind": "Triggered[TestA]:PartialSink[ExpectsEitherTestB]"
"kind": "Triggered[TestA]@PartialSink[ExpectsEitherTestB]"
}
],
"origin": {
Expand Down Expand Up @@ -370,7 +370,7 @@
"port": "leaf:vc"
}
],
"kind": "Triggered[TestB]:PartialSink[ExpectsEitherTestB]"
"kind": "Triggered[TestB]@PartialSink[ExpectsEitherTestB]"
}
],
"origin": {
Expand Down Expand Up @@ -449,7 +449,7 @@
"port": "leaf:vc"
}
],
"kind": "Triggered[TestA]:PartialSink[ExpectsEitherTestB]"
"kind": "Triggered[TestA]@PartialSink[ExpectsEitherTestB]"
}
],
"origin": {
Expand Down Expand Up @@ -1309,7 +1309,7 @@
{ "name": "multiple_sources.Node.send", "port": "leaf:vc" }
],
"length": 1,
"kind": "Triggered[UserControlled]:PartialSink[PermissiveContextSink]"
"kind": "Triggered[UserControlled]@PartialSink[PermissiveContextSink]"
}
],
"call": {
Expand Down Expand Up @@ -1467,7 +1467,7 @@
"port": "leaf:permissive_context"
}
],
"kind": "Triggered[UserControlled]:PartialSink[PermissiveContextSink]"
"kind": "Triggered[UserControlled]@PartialSink[PermissiveContextSink]"
}
],
"origin": {
Expand Down Expand Up @@ -1548,7 +1548,7 @@
"port": "leaf:permissive_context"
}
],
"kind": "Triggered[UserControlled]:PartialSink[PermissiveContextSink]"
"kind": "Triggered[UserControlled]@PartialSink[PermissiveContextSink]"
}
],
"origin": {
Expand Down Expand Up @@ -1930,7 +1930,7 @@
"port": "leaf:x"
}
],
"kind": "Triggered[TestD]:PartialSink[ShareBothSinksLeft]"
"kind": "Triggered[TestD]@PartialSink[ShareBothSinksLeft]"
}
],
"origin": {
Expand Down Expand Up @@ -1981,7 +1981,7 @@
"port": "leaf:x"
}
],
"kind": "Triggered[TestD]:PartialSink[ShareBothSinksLeft]"
"kind": "Triggered[TestD]@PartialSink[ShareBothSinksLeft]"
}
],
"origin": {
Expand Down Expand Up @@ -2017,7 +2017,7 @@
"port": "leaf:x"
}
],
"kind": "Triggered[TestE]:PartialSink[ShareBothSinksLeft]"
"kind": "Triggered[TestE]@PartialSink[ShareBothSinksLeft]"
}
],
"origin": {
Expand Down Expand Up @@ -2068,7 +2068,7 @@
"port": "leaf:x"
}
],
"kind": "Triggered[TestD]:PartialSink[ShareBothSinksLeft]"
"kind": "Triggered[TestD]@PartialSink[ShareBothSinksLeft]"
}
],
"origin": {
Expand Down Expand Up @@ -2104,7 +2104,7 @@
"port": "leaf:x"
}
],
"kind": "Triggered[TestE]:PartialSink[ShareBothSinksLeft]"
"kind": "Triggered[TestE]@PartialSink[ShareBothSinksLeft]"
}
],
"origin": {
Expand Down Expand Up @@ -2149,7 +2149,7 @@
"leaves": [
{ "name": "multiple_sources.Node.send", "port": "leaf:vc" }
],
"kind": "Triggered[UserControlled]:PartialSink[PermissiveContextSink]"
"kind": "Triggered[UserControlled]@PartialSink[PermissiveContextSink]"
}
],
"origin": {
Expand Down Expand Up @@ -2202,7 +2202,7 @@
"leaves": [
{ "name": "multiple_sources.Node.send", "port": "leaf:vc" }
],
"kind": "Triggered[UserControlled]:PartialSink[PermissiveContextSink]"
"kind": "Triggered[UserControlled]@PartialSink[PermissiveContextSink]"
}
],
"origin": {
Expand Down Expand Up @@ -2255,7 +2255,7 @@
"port": "leaf:y"
}
],
"kind": "Triggered[TestC]:PartialSink[ShareBothSinksRight]"
"kind": "Triggered[TestC]@PartialSink[ShareBothSinksRight]"
}
],
"origin": {
Expand Down Expand Up @@ -2306,7 +2306,7 @@
"port": "leaf:self"
}
],
"kind": "Triggered[PermissiveContext]:PartialSink[UserControlledSink]"
"kind": "Triggered[PermissiveContext]@PartialSink[UserControlledSink]"
}
],
"local_features": [
Expand Down Expand Up @@ -2405,7 +2405,7 @@
"leaves": [
{ "name": "multiple_sources.Node.send", "port": "leaf:vc" }
],
"kind": "Triggered[UserControlled]:PartialSink[PermissiveContextSink]"
"kind": "Triggered[UserControlled]@PartialSink[PermissiveContextSink]"
}
],
"origin": {
Expand Down Expand Up @@ -2437,7 +2437,7 @@
"leaves": [
{ "name": "multiple_sources.Node.send", "port": "leaf:vc" }
],
"kind": "Triggered[UserControlled]:PartialSink[PermissiveContextSink]"
"kind": "Triggered[UserControlled]@PartialSink[PermissiveContextSink]"
}
],
"origin": {
Expand Down Expand Up @@ -2724,7 +2724,7 @@
}
],
"length": 1,
"kind": "Triggered[UserControlled]:PartialSink[PermissiveContextSink]"
"kind": "Triggered[UserControlled]@PartialSink[PermissiveContextSink]"
}
],
"call": {
Expand Down
Loading

0 comments on commit 3e8e3ba

Please sign in to comment.