@@ -9,15 +9,22 @@ private import semmle.code.csharp.frameworks.system.data.Entity
99private import semmle.code.csharp.frameworks.EntityFramework
1010private import semmle.code.csharp.frameworks.NHibernate
1111private import semmle.code.csharp.frameworks.Sql
12+ private import semmle.code.csharp.security.dataflow.flowsources.SourceNode
1213
1314/** 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+ }
1522
1623/**
1724 * An expression that has a type of `DbRawSqlQuery`, representing the result of an Entity Framework
1825 * SqlQuery.
1926 */
20- class DbRawSqlStoredFlowSource extends StoredFlowSource {
27+ class DbRawSqlStoredFlowSource extends DatabaseInputSource {
2128 DbRawSqlStoredFlowSource ( ) {
2229 this .asExpr ( ) .getType ( ) instanceof SystemDataEntityInfrastructure:: DbRawSqlQuery
2330 }
@@ -27,30 +34,30 @@ class DbRawSqlStoredFlowSource extends StoredFlowSource {
2734 * An expression that has a type of `DbDataReader` or a sub-class, representing the result of a
2835 * data command.
2936 */
30- class DbDataReaderStoredFlowSource extends StoredFlowSource {
37+ class DbDataReaderStoredFlowSource extends DatabaseInputSource {
3138 DbDataReaderStoredFlowSource ( ) {
3239 this .asExpr ( ) .getType ( ) = any ( SystemDataCommon:: DbDataReader dataReader ) .getASubType * ( )
3340 }
3441}
3542
3643/** An expression that accesses a method of `DbDataReader` or a sub-class. */
37- class DbDataReaderMethodStoredFlowSource extends StoredFlowSource {
44+ class DbDataReaderMethodStoredFlowSource extends DatabaseInputSource {
3845 DbDataReaderMethodStoredFlowSource ( ) {
3946 this .asExpr ( ) .( MethodCall ) .getTarget ( ) .getDeclaringType ( ) =
4047 any ( SystemDataCommon:: DbDataReader dataReader ) .getASubType * ( )
4148 }
4249}
4350
4451/** An expression that accesses a property of `DbDataReader` or a sub-class. */
45- class DbDataReaderPropertyStoredFlowSource extends StoredFlowSource {
52+ class DbDataReaderPropertyStoredFlowSource extends DatabaseInputSource {
4653 DbDataReaderPropertyStoredFlowSource ( ) {
4754 this .asExpr ( ) .( PropertyAccess ) .getTarget ( ) .getDeclaringType ( ) =
4855 any ( SystemDataCommon:: DbDataReader dataReader ) .getASubType * ( )
4956 }
5057}
5158
5259/** A read of a mapped property. */
53- class ORMMappedProperty extends StoredFlowSource {
60+ class ORMMappedProperty extends DatabaseInputSource {
5461 ORMMappedProperty ( ) {
5562 this instanceof EntityFramework:: StoredFlowSource or
5663 this instanceof NHibernate:: StoredFlowSource
@@ -60,4 +67,6 @@ class ORMMappedProperty extends StoredFlowSource {
6067/** A file stream source is considered a stored flow source. */
6168class FileStreamStoredFlowSource extends StoredFlowSource {
6269 FileStreamStoredFlowSource ( ) { sourceNode ( this , "file" ) }
70+
71+ override string getThreatModel ( ) { result = "file" }
6372}
0 commit comments