mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
C#: Re-factor InsecureSqlConnection to use the new API.
This commit is contained in:
@@ -11,15 +11,13 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
import DataFlow::PathGraph
|
||||
import InsecureSqlConnection::PathGraph
|
||||
|
||||
/**
|
||||
* A data flow configuration for tracking strings passed to `SqlConnection[StringBuilder]` instances.
|
||||
*/
|
||||
class TaintTrackingConfiguration extends DataFlow::Configuration {
|
||||
TaintTrackingConfiguration() { this = "TaintTrackingConfiguration" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
module InsecureSqlConnectionConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
exists(string s | s = source.asExpr().(StringLiteral).getValue().toLowerCase() |
|
||||
s.matches("%encrypt=false%")
|
||||
or
|
||||
@@ -27,7 +25,7 @@ class TaintTrackingConfiguration extends DataFlow::Configuration {
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
exists(ObjectCreation oc |
|
||||
oc.getRuntimeArgument(0) = sink.asExpr() and
|
||||
(
|
||||
@@ -39,8 +37,13 @@ class TaintTrackingConfiguration extends DataFlow::Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
from TaintTrackingConfiguration c, DataFlow::PathNode source, DataFlow::PathNode sink
|
||||
where c.hasFlowPath(source, sink)
|
||||
/**
|
||||
* A data flow configuration for tracking strings passed to `SqlConnection[StringBuilder]` instances.
|
||||
*/
|
||||
module InsecureSqlConnection = DataFlow::Global<InsecureSqlConnectionConfig>;
|
||||
|
||||
from InsecureSqlConnection::PathNode source, InsecureSqlConnection::PathNode sink
|
||||
where InsecureSqlConnection::flowPath(source, sink)
|
||||
select sink.getNode(), source, sink,
|
||||
"$@ flows to this SQL connection and does not specify `Encrypt=True`.", source.getNode(),
|
||||
"Connection string"
|
||||
|
||||
Reference in New Issue
Block a user