Skip to content

Commit cd5168b

Browse files
committed
C#: Limit the defintion of database flow source and use summaries for better paths and reduced result multiplicity.
1 parent 38d246a commit cd5168b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

csharp/ql/lib/semmle/code/csharp/security/dataflow/flowsources/Stored.qll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,23 @@ class DbRawSqlStoredFlowSource extends DatabaseInputSource {
3939
* An expression that has a type of `DbDataReader` or a sub-class, representing the result of a
4040
* data command.
4141
*/
42-
class DbDataReaderStoredFlowSource extends DatabaseInputSource {
43-
DbDataReaderStoredFlowSource() {
44-
this.asExpr().getType() = any(SystemDataCommon::DbDataReader dataReader).getASubType*()
42+
class DbDataReaderParameterStoredFlowSource extends DatabaseInputSource {
43+
DbDataReaderParameterStoredFlowSource() {
44+
[this.asParameter().getType(), this.asExpr().(MethodCall).getTarget().getReturnType()] =
45+
any(SystemDataCommon::DbDataReader dataReader).getASubType*()
4546
}
4647
}
4748

4849
/** An expression that accesses a method of `DbDataReader` or a sub-class. */
49-
class DbDataReaderMethodStoredFlowSource extends DatabaseInputSource {
50+
deprecated class DbDataReaderMethodStoredFlowSource extends DataFlow::Node {
5051
DbDataReaderMethodStoredFlowSource() {
5152
this.asExpr().(MethodCall).getTarget().getDeclaringType() =
5253
any(SystemDataCommon::DbDataReader dataReader).getASubType*()
5354
}
5455
}
5556

5657
/** An expression that accesses a property of `DbDataReader` or a sub-class. */
57-
class DbDataReaderPropertyStoredFlowSource extends DatabaseInputSource {
58+
deprecated class DbDataReaderPropertyStoredFlowSource extends DataFlow::Node {
5859
DbDataReaderPropertyStoredFlowSource() {
5960
this.asExpr().(PropertyAccess).getTarget().getDeclaringType() =
6061
any(SystemDataCommon::DbDataReader dataReader).getASubType*()

csharp/ql/test/library-tests/frameworks/EntityFramework/StoredFlowSources.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ import csharp
22
import semmle.code.csharp.security.dataflow.flowsources.Stored
33

44
from StoredFlowSource source
5+
where source.asExpr().fromSource()
56
select source

0 commit comments

Comments
 (0)