Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d3d21d

Browse files
committed
Make StackTraceExposure use new API
1 parent d9844bd commit 2d3d21d

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

go/ql/src/Security/CWE-209/StackTraceExposure.ql

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import go
1717
import semmle.go.security.InsecureFeatureFlag::InsecureFeatureFlag
18-
import DataFlow::PathGraph
1918

2019
/**
2120
* A flag indicating the program is in debug or development mode, or that stack
@@ -48,18 +47,16 @@ class DebugStackFunction extends Function {
4847
* A taint-tracking configuration that looks for stack traces being written to
4948
* an HTTP response body without an intervening debug- or development-mode conditional.
5049
*/
51-
class StackTraceExposureConfig extends TaintTracking::Configuration {
52-
StackTraceExposureConfig() { this = "StackTraceExposureConfig" }
53-
54-
override predicate isSource(DataFlow::Node node) {
55-
node.(DataFlow::PostUpdateNode).getPreUpdateNode() =
50+
module StackTraceExposureConfig implements DataFlow::ConfigSig {
51+
predicate isSource(DataFlow::Node source) {
52+
source.(DataFlow::PostUpdateNode).getPreUpdateNode() =
5653
any(StackFunction f).getACall().getArgument(0) or
57-
node = any(DebugStackFunction f).getACall().getResult()
54+
source = any(DebugStackFunction f).getACall().getResult()
5855
}
5956

60-
override predicate isSink(DataFlow::Node node) { node instanceof Http::ResponseBody }
57+
predicate isSink(DataFlow::Node sink) { sink instanceof Http::ResponseBody }
6158

62-
override predicate isSanitizer(DataFlow::Node node) {
59+
predicate isBarrier(DataFlow::Node node) {
6360
// Sanitise everything controlled by an is-debug-mode check.
6461
// Imprecision: I don't try to guess which arm of a branch is intended
6562
// to mean debug mode, and which is production mode.
@@ -71,8 +68,12 @@ class StackTraceExposureConfig extends TaintTracking::Configuration {
7168
}
7269
}
7370

74-
from StackTraceExposureConfig cfg, DataFlow::PathNode source, DataFlow::PathNode sink
75-
where cfg.hasFlowPath(source, sink)
71+
module StackTraceExposureFlow = TaintTracking::Global<StackTraceExposureConfig>;
72+
73+
import StackTraceExposureFlow::PathGraph
74+
75+
from StackTraceExposureFlow::PathNode source, StackTraceExposureFlow::PathNode sink
76+
where StackTraceExposureFlow::flowPath(source, sink)
7677
select sink.getNode(), source, sink,
7778
"HTTP response depends on $@ and may be exposed to an external user.", source.getNode(),
7879
"stack trace information"

0 commit comments

Comments
 (0)