Skip to content

Commit 0b06fcd

Browse files
committed
PS: Add instance edges for New-Object in API graphs.
1 parent b3e1f57 commit 0b06fcd

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ module API {
367367

368368
Node methodEdge(string name) { none() }
369369

370+
Node instanceEdge() { none() }
371+
370372
final predicate isImplicit() { not this.isExplicit(_) }
371373

372374
predicate isExplicit(DataFlow::Node node) { none() }
@@ -431,6 +433,14 @@ module API {
431433
result = Impl::MkNewObjectTypeNameNode(prefix + "." + name)
432434
}
433435

436+
final override Node instanceEdge() {
437+
exists(DataFlow::ObjectCreationNode creation |
438+
prefix = creation.getLowerCaseConstructedTypeName() and
439+
Specific::needsNewObjectTypeNameNode(creation, prefix) and
440+
result = getForwardStartNode(creation)
441+
)
442+
}
443+
434444
final override predicate isExplicit(DataFlow::Node node) {
435445
Specific::needsNewObjectTypeNameNode(node, prefix)
436446
}
@@ -698,6 +708,8 @@ module API {
698708
pred = getForwardEndNode(objCreation.getConstructedTypeNode()) and
699709
succ = getForwardStartNode(objCreation)
700710
)
711+
or
712+
pred.(TypeNameNode).instanceEdge() = succ
701713
}
702714

703715
cached

0 commit comments

Comments
 (0)