Skip to content

Commit 8e3bfda

Browse files
committed
C#: Re-factor LogForging to use the new API.
1 parent 8284487 commit 8e3bfda

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

csharp/ql/lib/semmle/code/csharp/security/dataflow/LogForgingQuery.qll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ abstract class Sink extends DataFlow::ExprNode { }
2525
abstract class Sanitizer extends DataFlow::ExprNode { }
2626

2727
/**
28+
* DEPRECATED: Use `LogForging` instead.
29+
*
2830
* A taint-tracking configuration for untrusted user input used in log entries.
2931
*/
30-
class TaintTrackingConfiguration extends TaintTracking::Configuration {
32+
deprecated class TaintTrackingConfiguration extends TaintTracking::Configuration {
3133
TaintTrackingConfiguration() { this = "LogForging" }
3234

3335
override predicate isSource(DataFlow::Node source) { source instanceof Source }
@@ -37,6 +39,22 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
3739
override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer }
3840
}
3941

42+
/**
43+
* A taint-tracking configuration for untrusted user input used in log entries.
44+
*/
45+
private module LogForgingConfig implements DataFlow::ConfigSig {
46+
predicate isSource(DataFlow::Node source) { source instanceof Source }
47+
48+
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
49+
50+
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
51+
}
52+
53+
/**
54+
* A taint-tracking module for untrusted user input used in log entries.
55+
*/
56+
module LogForging = TaintTracking::Global<LogForgingConfig>;
57+
4058
/** A source of remote user input. */
4159
private class RemoteSource extends Source instanceof RemoteFlowSource { }
4260

csharp/ql/src/Security Features/CWE-117/LogForging.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
import csharp
1515
import semmle.code.csharp.security.dataflow.LogForgingQuery
16-
import semmle.code.csharp.dataflow.DataFlow::DataFlow::PathGraph
16+
import LogForging::PathGraph
1717

18-
from TaintTrackingConfiguration c, DataFlow::PathNode source, DataFlow::PathNode sink
19-
where c.hasFlowPath(source, sink)
18+
from LogForging::PathNode source, LogForging::PathNode sink
19+
where LogForging::flowPath(source, sink)
2020
select sink.getNode(), source, sink, "This log entry depends on a $@.", source.getNode(),
2121
"user-provided value"

0 commit comments

Comments
 (0)