mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
Refactor to use ConditionalBypassQuery.qll
This commit is contained in:
@@ -13,33 +13,10 @@
|
||||
*/
|
||||
|
||||
import java
|
||||
import semmle.code.java.dataflow.FlowSources
|
||||
import semmle.code.java.security.SensitiveActions
|
||||
import semmle.code.java.controlflow.Dominance
|
||||
import semmle.code.java.controlflow.Guards
|
||||
import semmle.code.java.dataflow.DataFlow
|
||||
import semmle.code.java.security.ConditionalBypassQuery
|
||||
import DataFlow::PathGraph
|
||||
|
||||
/**
|
||||
* Calls to a sensitive method that are controlled by a condition
|
||||
* on the given expression.
|
||||
*/
|
||||
predicate conditionControlsMethod(MethodAccess m, Expr e) {
|
||||
exists(ConditionBlock cb, SensitiveExecutionMethod def, boolean cond |
|
||||
cb.controls(m.getBasicBlock(), cond) and
|
||||
def = m.getMethod() and
|
||||
not cb.controls(def.getAReference().getBasicBlock(), cond.booleanNot()) and
|
||||
e = cb.getCondition()
|
||||
)
|
||||
}
|
||||
|
||||
class ConditionalBypassFlowConfig extends TaintTracking::Configuration {
|
||||
ConditionalBypassFlowConfig() { this = "ConditionalBypassFlowConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { conditionControlsMethod(_, sink.asExpr()) }
|
||||
}
|
||||
|
||||
from
|
||||
DataFlow::PathNode source, DataFlow::PathNode sink, MethodAccess m, Expr e,
|
||||
ConditionalBypassFlowConfig conf
|
||||
|
||||
Reference in New Issue
Block a user