Skip to content

Commit f4ee1a5

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

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

csharp/ql/src/Security Features/CWE-134/UncontrolledFormatString.ql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,29 @@ import csharp
1515
import semmle.code.csharp.security.dataflow.flowsources.Remote
1616
import semmle.code.csharp.security.dataflow.flowsources.Local
1717
import semmle.code.csharp.frameworks.Format
18-
import DataFlow::PathGraph
18+
import FormatString::PathGraph
1919

20-
class FormatStringConfiguration extends TaintTracking::Configuration {
21-
FormatStringConfiguration() { this = "FormatStringConfiguration" }
22-
23-
override predicate isSource(DataFlow::Node source) {
20+
module FormatStringConfig implements DataFlow::ConfigSig {
21+
predicate isSource(DataFlow::Node source) {
2422
source instanceof RemoteFlowSource
2523
or
2624
source instanceof LocalFlowSource
2725
}
2826

29-
override predicate isSink(DataFlow::Node sink) {
27+
predicate isSink(DataFlow::Node sink) {
3028
sink.asExpr() = any(FormatCall call | call.hasInsertions()).getFormatExpr()
3129
}
3230
}
3331

32+
module FormatString = TaintTracking::Global<FormatStringConfig>;
33+
3434
string getSourceType(DataFlow::Node node) {
3535
result = node.(RemoteFlowSource).getSourceType()
3636
or
3737
result = node.(LocalFlowSource).getSourceType()
3838
}
3939

40-
from FormatStringConfiguration config, DataFlow::PathNode source, DataFlow::PathNode sink
41-
where config.hasFlowPath(source, sink)
40+
from FormatString::PathNode source, FormatString::PathNode sink
41+
where FormatString::flowPath(source, sink)
4242
select sink.getNode(), source, sink, "This format string depends on $@.", source.getNode(),
4343
("this" + getSourceType(source.getNode()))

0 commit comments

Comments
 (0)