@@ -9,15 +9,25 @@ 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.FlowSources
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+ /**
20+ * A node with input from a database.
21+ */
22+ abstract class DatabaseInputSource extends StoredFlowSource {
23+ override string getThreatModel ( ) { result = "database" }
24+ }
1525
1626/**
1727 * An expression that has a type of `DbRawSqlQuery`, representing the result of an Entity Framework
1828 * SqlQuery.
1929 */
20- class DbRawSqlStoredFlowSource extends StoredFlowSource {
30+ class DbRawSqlStoredFlowSource extends DatabaseInputSource {
2131 DbRawSqlStoredFlowSource ( ) {
2232 this .asExpr ( ) .getType ( ) instanceof SystemDataEntityInfrastructure:: DbRawSqlQuery
2333 }
@@ -27,30 +37,34 @@ class DbRawSqlStoredFlowSource extends StoredFlowSource {
2737 * An expression that has a type of `DbDataReader` or a sub-class, representing the result of a
2838 * data command.
2939 */
30- class DbDataReaderStoredFlowSource extends StoredFlowSource {
40+ class DbDataReaderStoredFlowSource extends DatabaseInputSource {
3141 DbDataReaderStoredFlowSource ( ) {
3242 this .asExpr ( ) .getType ( ) = any ( SystemDataCommon:: DbDataReader dataReader ) .getASubType * ( )
3343 }
3444}
3545
3646/** An expression that accesses a method of `DbDataReader` or a sub-class. */
37- class DbDataReaderMethodStoredFlowSource extends StoredFlowSource {
47+ class DbDataReaderMethodStoredFlowSource extends DatabaseInputSource {
3848 DbDataReaderMethodStoredFlowSource ( ) {
3949 this .asExpr ( ) .( MethodCall ) .getTarget ( ) .getDeclaringType ( ) =
4050 any ( SystemDataCommon:: DbDataReader dataReader ) .getASubType * ( )
4151 }
4252}
4353
4454/** An expression that accesses a property of `DbDataReader` or a sub-class. */
45- class DbDataReaderPropertyStoredFlowSource extends StoredFlowSource {
55+ class DbDataReaderPropertyStoredFlowSource extends DatabaseInputSource {
4656 DbDataReaderPropertyStoredFlowSource ( ) {
4757 this .asExpr ( ) .( PropertyAccess ) .getTarget ( ) .getDeclaringType ( ) =
4858 any ( SystemDataCommon:: DbDataReader dataReader ) .getASubType * ( )
4959 }
5060}
5161
52- /** A read of a mapped property. */
53- class ORMMappedProperty extends StoredFlowSource {
62+ /**
63+ * DEPRECATED: Use `EntityFramework::StoredFlowSource` and `NHibernate::StoredFlowSource` instead.
64+ *
65+ * A read of a mapped property.
66+ */
67+ deprecated class ORMMappedProperty extends DataFlow:: Node {
5468 ORMMappedProperty ( ) {
5569 this instanceof EntityFramework:: StoredFlowSource or
5670 this instanceof NHibernate:: StoredFlowSource
@@ -60,4 +74,6 @@ class ORMMappedProperty extends StoredFlowSource {
6074/** A file stream source is considered a stored flow source. */
6175class FileStreamStoredFlowSource extends StoredFlowSource {
6276 FileStreamStoredFlowSource ( ) { sourceNode ( this , "file" ) }
77+
78+ override string getThreatModel ( ) { result = "file" }
6379}
0 commit comments