You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func TestTaintedAndSinkedInDifferentBranches(objects chan interface{}) {
select {
case objects <- core.Source{}:
case s := <-objects:
// TODO(211) want no report here, because objects is only tainted if the
// other branch is taken, and only one branch can be taken
core.Sink(s) // want "a source has reached a sink"
}
}
Given the semantics of select, one of two things can happen:
We put a source on the objects channel
We get an interface{} value from the objects channel and we sink it
As indicated by the TODO, it is therefore not possible that the channel be tainted and that a tainted value is obtained from it in the same call to this function.
However, this code may still be unsafe, because the fact that one of the cases puts a source on the channel indicates that the channel may contain sources in general. Consider e.g. a case where this function is called concurrently in two different goroutines. Such a case would be unsafe code. Handling this behavior in full generality within the scope of a single function would require us to model every interaction with the channel. Alternatively, this could be handled via interprocedural analysis (#99).
This issue is somewhat related to #161 and #210, in the sense that it is related to a behavior where we may want to leverage
The text was updated successfully, but these errors were encountered:
Consider the following test case:
Given the semantics of
select
, one of two things can happen:objects
channelinterface{}
value from theobjects
channel and we sink itAs indicated by the
TODO
, it is therefore not possible that the channel be tainted and that a tainted value is obtained from it in the same call to this function.However, this code may still be unsafe, because the fact that one of the cases puts a source on the channel indicates that the channel may contain sources in general. Consider e.g. a case where this function is called concurrently in two different goroutines. Such a case would be unsafe code. Handling this behavior in full generality within the scope of a single function would require us to model every interaction with the channel. Alternatively, this could be handled via interprocedural analysis (#99).
This issue is somewhat related to #161 and #210, in the sense that it is related to a behavior where we may want to leverage
The text was updated successfully, but these errors were encountered: