mirror of
https://github.com/github/codeql.git
synced 2026-01-30 06:42:57 +01:00
Move getUnderlyingNode into Protobuf.qll
This is its only user for now.
This commit is contained in:
@@ -600,16 +600,6 @@ class ComponentReadNode extends ReadNode {
|
||||
Node getBase() { result = instructionNode(insn.getBase()) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data-flow node representing the bottom of a stack of zero or more `ComponentReadNode`s.
|
||||
*
|
||||
* For example, in the expression a.b[c].d[e], this would return the dataflow node for the read from `a`.
|
||||
*/
|
||||
Node getUnderlyingNode(ReadNode read) {
|
||||
(result = read or result = read.(ComponentReadNode).getBase+()) and
|
||||
not result instanceof ComponentReadNode
|
||||
}
|
||||
|
||||
/**
|
||||
* A data-flow node that reads an element of an array, map, slice or string.
|
||||
*/
|
||||
|
||||
@@ -145,16 +145,26 @@ module Protobuf {
|
||||
exists(Type base | base.getPointerType() instanceof MessageType | result = base.getField(_))
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data-flow node representing the bottom of a stack of zero or more `ComponentReadNode`s.
|
||||
*
|
||||
* For example, in the expression a.b[c].d[e], this would return the dataflow node for the read from `a`.
|
||||
*/
|
||||
DataFlow::Node getUnderlyingNode(DataFlow::ReadNode read) {
|
||||
(result = read or result = read.(DataFlow::ComponentReadNode).getBase+()) and
|
||||
not result instanceof DataFlow::ComponentReadNode
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional taint step tainting a Message when taint is written to any of its fields and/or elements.
|
||||
*/
|
||||
private class WriteMessageFieldStep extends TaintTracking::AdditionalTaintStep {
|
||||
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
|
||||
exists(DataFlow::ReadNode base | succ = DataFlow::getUnderlyingNode(base) |
|
||||
exists(DataFlow::ReadNode base | succ = getUnderlyingNode(base) |
|
||||
any(DataFlow::Write w).writesField(base, getAMessageField(), pred)
|
||||
)
|
||||
or
|
||||
exists(DataFlow::ReadNode base | succ = DataFlow::getUnderlyingNode(base) |
|
||||
exists(DataFlow::ReadNode base | succ = getUnderlyingNode(base) |
|
||||
any(DataFlow::Write w).writesElement(base, _, pred) and
|
||||
[succ.getType(), succ.getType().getPointerType()] instanceof MessageType
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user