Skip to content

Commit

Permalink
Add FN repro for #7815
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-marichal committed Aug 18, 2023
1 parent 01782bd commit 17c1a3a
Showing 1 changed file with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ void InvalidCases(string s1, string s2)
var webChemin = "http://www.mywebsite.com"; // FN
var windowsChemin = "c:\\blah\\blah\\blah.txt"; // FN


// The rule only checks the string literals that are [arguments in methods/constructors] or [assignment]
bool ReturnStement(string uri)
{
Expand Down Expand Up @@ -74,3 +73,35 @@ void ValidCases(string s)
}
}
}

// https://github.com/SonarSource/sonar-dotnet/issues/7815
class ReproFN_7815
{
class MyClass
{
public string FilePath { get; set; }
}

void Method()
{
var myClass = new MyClass
{
FilePath = "/my/other/folder" // Compliant - we ignore unix paths by default
};

var myClass2 = new MyClass
{
FilePath = @"\\my-network-drive\folder\file.txt" // FN
};

var myClass3 = new MyClass
{
FilePath = "http://www.mywebsite.com" // FN
};

var myClass4 = new MyClass
{
FilePath = "c:\\blah\\blah\\blah.txt" // FN
};
}
}

0 comments on commit 17c1a3a

Please sign in to comment.