Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tamasvajk
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the C# label Mar 17, 2021
@tamasvajk
Copy link
Contributor Author

@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]
Copy link
Contributor

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]
Copy link
Contributor

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]
Copy link
Contributor

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]
Copy link
Contributor

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]
Copy link
Contributor

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]
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants