-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Add data flow tests for various pattern types #5429
base: main
Are you sure you want to change the base?
Conversation
@hvitved I added a couple of test cases for data flow on patterns. At one point, let's discuss which ones to tackle next... |
var ret1 = a switch | ||
{ | ||
Item("taint source", 1) { Y: 10 } z => Sink(z.X), // [TRUE POSITIVE] | ||
Item("not taint source", 1) { Y: 10 } z => Sink(z.X), // [FALSE POSITIVE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a false positive, as far as data flow is concerned. This is instead something where I would expect a given data flow configuration to prune data flow edges using guards.
It is basically the same as
var x = "tainted";
if (x == "not tainted")
Sink(x);
var ret2 = b switch | ||
{ | ||
("taint source", 0) => Sink(b.X), // [TRUE POSITIVE] | ||
("not taint source", 0) => Sink(b.X), // [FALSE POSITIVE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this case
("taint source", 0) => Sink(b.X), // [TRUE POSITIVE] | ||
("not taint source", 0) => Sink(b.X), // [FALSE POSITIVE] | ||
("taint source", 3) p => Sink(p.X), // [TRUE POSITIVE] | ||
("not taint source", 3) p => Sink(p.X), // [FALSE POSITIVE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this case
var ret3 = o switch | ||
{ | ||
Item("taint source", 1) { Y: 10 } z => Sink(z.X), // [TRUE POSITIVE] | ||
Item("not taint source", 1) { Y: 10 } z => Sink(z.X), // [FALSE POSITIVE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this case
var ret4 = tup switch | ||
{ | ||
("taint source", 2) => Sink(tup.Item1), // [TRUE POSITIVE] | ||
("not taint source", 2) => Sink(tup.Item1), // [FALSE POSITIVE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this case
("taint source", 2) => Sink(tup.Item1), // [TRUE POSITIVE] | ||
("not taint source", 2) => Sink(tup.Item1), // [FALSE POSITIVE] | ||
ValueTuple<string, int>("taint source", 3) { Item2: 3 } t1 => Sink(tup.Item1), // [TRUE POSITIVE] | ||
ValueTuple<string, int>("not taint source", 3) { Item2: 3 } t1 => Sink(tup.Item1), // [FALSE POSITIVE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this case
No description provided.