Skip to content

Commit 7fe1a94

Browse files
committed
C++: Update PotentiallyExposedSystemData with DataFlow::ConfigSig
1 parent 53aa34b commit 7fe1a94

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

cpp/ql/src/Security/CWE/CWE-497/PotentiallyExposedSystemData.ql

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@ import cpp
2828
import semmle.code.cpp.ir.dataflow.TaintTracking
2929
import semmle.code.cpp.models.interfaces.FlowSource
3030
import semmle.code.cpp.security.OutputWrite
31-
import DataFlow::PathGraph
31+
import PotentiallyExposedSystemData::PathGraph
3232
import SystemData
3333

34-
class PotentiallyExposedSystemDataConfiguration extends TaintTracking::Configuration {
35-
PotentiallyExposedSystemDataConfiguration() { this = "PotentiallyExposedSystemDataConfiguration" }
36-
37-
override predicate isSource(DataFlow::Node source) {
34+
module PotentiallyExposedSystemDataConfiguration implements DataFlow::ConfigSig {
35+
predicate isSource(DataFlow::Node source) {
3836
source = any(SystemData sd | sd.isSensitive()).getAnExpr()
3937
}
4038

41-
override predicate isSink(DataFlow::Node sink) {
39+
predicate isSink(DataFlow::Node sink) {
4240
exists(OutputWrite ow, Expr child | child = ow.getASource().getAChild*() |
4341
// Most sinks receive a pointer as an argument (for example `printf`),
4442
// and we use an indirect sink for those.
@@ -53,9 +51,10 @@ class PotentiallyExposedSystemDataConfiguration extends TaintTracking::Configura
5351
}
5452
}
5553

56-
from
57-
PotentiallyExposedSystemDataConfiguration config, DataFlow::PathNode source,
58-
DataFlow::PathNode sink
59-
where config.hasFlowPath(source, sink)
54+
module PotentiallyExposedSystemData =
55+
TaintTracking::Make<PotentiallyExposedSystemDataConfiguration>;
56+
57+
from PotentiallyExposedSystemData::PathNode source, PotentiallyExposedSystemData::PathNode sink
58+
where PotentiallyExposedSystemData::hasFlowPath(source, sink)
6059
select sink, source, sink, "This operation potentially exposes sensitive system data from $@.",
6160
source, source.getNode().toString()

0 commit comments

Comments
 (0)