@@ -9,15 +9,22 @@ private import semmle.code.csharp.frameworks.system.data.Entity
9
9
private import semmle.code.csharp.frameworks.EntityFramework
10
10
private import semmle.code.csharp.frameworks.NHibernate
11
11
private import semmle.code.csharp.frameworks.Sql
12
+ private import semmle.code.csharp.security.dataflow.flowsources.SourceNode
12
13
13
14
/** A data flow source of stored user input. */
14
- abstract class StoredFlowSource extends DataFlow:: Node { }
15
+ abstract class StoredFlowSource extends SourceNode {
16
+ override string getThreatModel ( ) { result = "local" }
17
+ }
18
+
19
+ abstract class DatabaseInputSource extends StoredFlowSource {
20
+ override string getThreatModel ( ) { result = "database" }
21
+ }
15
22
16
23
/**
17
24
* An expression that has a type of `DbRawSqlQuery`, representing the result of an Entity Framework
18
25
* SqlQuery.
19
26
*/
20
- class DbRawSqlStoredFlowSource extends StoredFlowSource {
27
+ class DbRawSqlStoredFlowSource extends DatabaseInputSource {
21
28
DbRawSqlStoredFlowSource ( ) {
22
29
this .asExpr ( ) .getType ( ) instanceof SystemDataEntityInfrastructure:: DbRawSqlQuery
23
30
}
@@ -27,30 +34,30 @@ class DbRawSqlStoredFlowSource extends StoredFlowSource {
27
34
* An expression that has a type of `DbDataReader` or a sub-class, representing the result of a
28
35
* data command.
29
36
*/
30
- class DbDataReaderStoredFlowSource extends StoredFlowSource {
37
+ class DbDataReaderStoredFlowSource extends DatabaseInputSource {
31
38
DbDataReaderStoredFlowSource ( ) {
32
39
this .asExpr ( ) .getType ( ) = any ( SystemDataCommon:: DbDataReader dataReader ) .getASubType * ( )
33
40
}
34
41
}
35
42
36
43
/** An expression that accesses a method of `DbDataReader` or a sub-class. */
37
- class DbDataReaderMethodStoredFlowSource extends StoredFlowSource {
44
+ class DbDataReaderMethodStoredFlowSource extends DatabaseInputSource {
38
45
DbDataReaderMethodStoredFlowSource ( ) {
39
46
this .asExpr ( ) .( MethodCall ) .getTarget ( ) .getDeclaringType ( ) =
40
47
any ( SystemDataCommon:: DbDataReader dataReader ) .getASubType * ( )
41
48
}
42
49
}
43
50
44
51
/** An expression that accesses a property of `DbDataReader` or a sub-class. */
45
- class DbDataReaderPropertyStoredFlowSource extends StoredFlowSource {
52
+ class DbDataReaderPropertyStoredFlowSource extends DatabaseInputSource {
46
53
DbDataReaderPropertyStoredFlowSource ( ) {
47
54
this .asExpr ( ) .( PropertyAccess ) .getTarget ( ) .getDeclaringType ( ) =
48
55
any ( SystemDataCommon:: DbDataReader dataReader ) .getASubType * ( )
49
56
}
50
57
}
51
58
52
59
/** A read of a mapped property. */
53
- class ORMMappedProperty extends StoredFlowSource {
60
+ class ORMMappedProperty extends DatabaseInputSource {
54
61
ORMMappedProperty ( ) {
55
62
this instanceof EntityFramework:: StoredFlowSource or
56
63
this instanceof NHibernate:: StoredFlowSource
@@ -60,4 +67,6 @@ class ORMMappedProperty extends StoredFlowSource {
60
67
/** A file stream source is considered a stored flow source. */
61
68
class FileStreamStoredFlowSource extends StoredFlowSource {
62
69
FileStreamStoredFlowSource ( ) { sourceNode ( this , "file" ) }
70
+
71
+ override string getThreatModel ( ) { result = "file" }
63
72
}
0 commit comments