Skip to content

Commit 1f775b9

Browse files
committed
PS: Add 'fieldEdge' to ApiGraphs.
1 parent d1f1807 commit 1f775b9

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

powershell/ql/lib/semmle/code/powershell/ApiGraphs.qll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ module API {
249249
result = this.getContent(contents.getAReadContent())
250250
}
251251

252+
/**
253+
* Gets a representative for the instanceof field of the given `name`.
254+
*/
255+
pragma[inline]
256+
Node getField(string name) {
257+
// This predicate is currently not 'inline_late' because 'name' can be an input or output
258+
Impl::fieldEdge(this.getAnEpsilonSuccessor(), name, result)
259+
}
260+
252261
/**
253262
* Gets a representative for an arbitrary element of this collection.
254263
*/
@@ -615,6 +624,15 @@ module API {
615624
contentEdge(pred, any(DataFlow::ContentSet set | set.isAnyElement()).getAReadContent(), succ)
616625
}
617626

627+
cached
628+
predicate fieldEdge(Node pred, string name, Node succ) {
629+
exists(DataFlow::ContentSet set, DataFlow::Content::FieldContent fc |
630+
fc.getLowerCaseName() = name and
631+
set.isSingleton(fc) and
632+
contentEdge(pred, set.getAReadContent(), succ)
633+
)
634+
}
635+
618636
cached
619637
predicate parameterEdge(Node pred, DataFlowDispatch::ParameterPosition paramPos, Node succ) {
620638
exists(DataFlowPrivate::ParameterNodeImpl parameter, DataFlow::CallableNode callable |

0 commit comments

Comments
 (0)