Skip to content

Commit 8c883e9

Browse files
committed
PS: Add instance edges for static constructor-like functions.
1 parent 0b06fcd commit 8c883e9

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,13 @@ module API {
701701
positionalParameterEdge(pred, n, succ)
702702
}
703703

704+
pragma[nomagic]
705+
private DataFlow::CallNode getStaticConstructorLikeCall() {
706+
exists(string type |
707+
typeModel(type, type + "!", "Method[" + result.getLowerCaseName() + "].ReturnValue")
708+
)
709+
}
710+
704711
cached
705712
predicate instanceEdge(Node pred, Node succ) {
706713
// TODO: Also model parameters with a given type here
@@ -709,6 +716,12 @@ module API {
709716
succ = getForwardStartNode(objCreation)
710717
)
711718
or
719+
exists(DataFlow::CallNode call |
720+
call = getStaticConstructorLikeCall() and
721+
pred = getForwardEndNode(call.getQualifier()) and
722+
succ = getForwardStartNode(call)
723+
)
724+
or
712725
pred.(TypeNameNode).instanceEdge() = succ
713726
}
714727

0 commit comments

Comments
 (0)