Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6194d5c

Browse files
committed
C#: Add test for CaptureSinkModel query.
1 parent 5babb0e commit 6194d5c

4 files changed

Lines changed: 44 additions & 1 deletion

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| Sinks;NewSinks;false;WrapFieldResponseWriteFile;();Argument[Qualifier];html |
2+
| Sinks;NewSinks;false;WrapResponseWrite;(System.Object);Argument[0];html |
3+
| Sinks;NewSinks;false;WrapResponseWriteFile;(System.String);Argument[0];html |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
utils/model-generator/CaptureSinkModels.ql
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Web;
3+
4+
namespace Sinks;
5+
6+
public class NewSinks
7+
{
8+
private string tainted;
9+
10+
// New sink
11+
public void WrapResponseWrite(object o)
12+
{
13+
var response = new HttpResponse();
14+
response.Write(o);
15+
}
16+
17+
// NOT new sink as method is private
18+
private void PrivateWrapResponseWrite(object o)
19+
{
20+
var response = new HttpResponse();
21+
response.Write(o);
22+
}
23+
24+
// New sink
25+
public void WrapResponseWriteFile(string s)
26+
{
27+
var response = new HttpResponse();
28+
response.WriteFile(s);
29+
}
30+
31+
// New sink
32+
public void WrapFieldResponseWriteFile()
33+
{
34+
var response = new HttpResponse();
35+
response.WriteFile(tainted);
36+
}
37+
38+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
semmle-extractor-options: /r:System.Linq.dll
1+
semmle-extractor-options: /r:System.Linq.dll /r:System.Collections.Specialized.dll
2+
semmle-extractor-options: ${testdir}/../../resources/stubs/System.Web.cs

0 commit comments

Comments
 (0)