From 87afdae1c751b34ca5ec9c2245b11a3b9bc5df38 Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Fri, 16 Jul 2021 10:47:06 +0100 Subject: [PATCH] use hasFlowTo where possible --- ql/src/experimental/CWE-942/CorsMisconfiguration.ql | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ql/src/experimental/CWE-942/CorsMisconfiguration.ql b/ql/src/experimental/CWE-942/CorsMisconfiguration.ql index 6efb24c852a..fa07af5914f 100644 --- a/ql/src/experimental/CWE-942/CorsMisconfiguration.ql +++ b/ql/src/experimental/CWE-942/CorsMisconfiguration.ql @@ -91,9 +91,9 @@ predicate allowCredentialsIsSetToTrue(AllowOriginHeaderWrite allowOriginHW) { * The `message` parameter is populated with the warning message to be returned by the query. */ predicate flowsFromUntrustedToAllowOrigin(AllowOriginHeaderWrite allowOriginHW, string message) { - exists(FlowsUntrustedToAllowOriginHeader cfg, DataFlow::PathNode source, DataFlow::PathNode sink | - cfg.hasFlowPath(source, sink) and - cfg.isSink(sink.getNode(), allowOriginHW) + exists(FlowsUntrustedToAllowOriginHeader cfg, DataFlow::Node sink | + cfg.hasFlowTo(sink) and + cfg.isSink(sink, allowOriginHW) | message = headerAllowOrigin() + " header is set to a user-defined value, and " + @@ -168,11 +168,8 @@ class FlowsFromUntrusted extends TaintTracking::Configuration { * Holds if the provided `dst` is also destination of a `UntrustedFlowSource`. */ predicate flowsToGuardedByCheckOnUntrusted(AllowOriginHeaderWrite allowOriginHW) { - exists( - FlowsFromUntrusted cfg, DataFlow::PathNode source, DataFlow::PathNode sink, - ControlFlow::ConditionGuardNode cgn - | - cfg.hasFlowPath(source, sink) and cfg.isSink(sink.getNode(), cgn) + exists(FlowsFromUntrusted cfg, DataFlow::Node sink, ControlFlow::ConditionGuardNode cgn | + cfg.hasFlowTo(sink) and cfg.isSink(sink, cgn) | cgn.dominates(allowOriginHW.getBasicBlock()) )