Skip to content

Commit 8a21a4f

Browse files
committed
Deprecate WriteNode.writesComponent
1 parent 59e3c14 commit 8a21a4f

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

go/ql/lib/semmle/go/controlflow/ControlFlowGraph.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,11 @@ module ControlFlow {
225225
}
226226

227227
/**
228+
* DEPRECATED: Use the disjunct of `writesElement` and `writesField` instead.
229+
*
228230
* Holds if this node sets any field or element of `base` to `rhs`.
229231
*/
230-
predicate writesComponent(DataFlow::Node base, DataFlow::Node rhs) {
232+
deprecated predicate writesComponent(DataFlow::Node base, DataFlow::Node rhs) {
231233
this.writesElement(base, _, rhs) or this.writesField(base, _, rhs)
232234
}
233235

go/ql/lib/semmle/go/frameworks/Protobuf.qll

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,10 @@ module Protobuf {
141141
private class WriteMessageFieldStep extends TaintTracking::AdditionalTaintStep {
142142
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
143143
[succ.getType(), succ.getType().getPointerType()] instanceof MessageType and
144-
exists(DataFlow::Node n, DataFlow::ReadNode base |
145-
succ.(DataFlow::PostUpdateNode).getPreUpdateNode() = getUnderlyingNode(base)
144+
exists(DataFlow::Write w, DataFlow::ReadNode base |
145+
w.writesElementPreUpdate(base, _, pred) or w.writesFieldPreUpdate(base, _, pred)
146146
|
147-
any(DataFlow::Write w).writesComponent(n, pred) and
148-
// The below line only works because `base`'s type, `DataFlow::ReadNode`,
149-
// is incompatible with `DataFlow::PostUpdateNode`.
150-
base = [n, n.(DataFlow::PostUpdateNode).getPreUpdateNode()]
147+
succ.(DataFlow::PostUpdateNode).getPreUpdateNode() = getUnderlyingNode(base)
151148
)
152149
}
153150
}

0 commit comments

Comments
 (0)