Skip to content

Commit 9a62f51

Browse files
committed
C#: Re-factor AssemblyPathInjection to use the new API.
1 parent ca029f5 commit 9a62f51

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

csharp/ql/src/Security Features/CWE-114/AssemblyPathInjection.ql

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@
1515
import csharp
1616
import semmle.code.csharp.security.dataflow.flowsources.Remote
1717
import semmle.code.csharp.commons.Util
18-
import DataFlow::PathGraph
18+
import AssemblyPathInjection::PathGraph
1919

2020
/**
2121
* A taint-tracking configuration for untrusted user input used to load a DLL.
2222
*/
23-
class TaintTrackingConfiguration extends TaintTracking::Configuration {
24-
TaintTrackingConfiguration() { this = "DLLInjection" }
25-
26-
override predicate isSource(DataFlow::Node source) {
23+
module AssemblyPathInjectionConfig implements DataFlow::ConfigSig {
24+
predicate isSource(DataFlow::Node source) {
2725
source instanceof RemoteFlowSource or
2826
source.asExpr() = any(MainMethod main).getParameter(0).getAnAccess()
2927
}
3028

31-
override predicate isSink(DataFlow::Node sink) {
29+
predicate isSink(DataFlow::Node sink) {
3230
exists(MethodCall mc, string name, int arg |
3331
mc.getTarget().getName().matches(name) and
3432
mc.getTarget()
@@ -48,7 +46,12 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
4846
}
4947
}
5048

51-
from TaintTrackingConfiguration c, DataFlow::PathNode source, DataFlow::PathNode sink
52-
where c.hasFlowPath(source, sink)
49+
/**
50+
* A taint-tracking module for untrusted user input used to load a DLL.
51+
*/
52+
module AssemblyPathInjection = TaintTracking::Global<AssemblyPathInjectionConfig>;
53+
54+
from AssemblyPathInjection::PathNode source, AssemblyPathInjection::PathNode sink
55+
where AssemblyPathInjection::flowPath(source, sink)
5356
select sink.getNode(), source, sink, "This assembly path depends on a $@.", source,
5457
"user-provided value"

0 commit comments

Comments
 (0)