Skip to content

Commit 7531d88

Browse files
committed
PS: Allow explicit module qualifiers to be selected with the 'instance' path.
1 parent 689a34b commit 7531d88

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ module API {
647647

648648
cached
649649
predicate instanceEdge(Node pred, Node succ) {
650+
// An instance of a type
650651
exists(string qualifiedType | pred = MkType(qualifiedType) |
651652
exists(DataFlow::ObjectCreationNode objCreation |
652653
objCreation.getConstructedTypeName() = qualifiedType and
@@ -658,6 +659,15 @@ module API {
658659
succ = getForwardStartNode(p)
659660
)
660661
)
662+
or
663+
// A use of a module (or static type?)
664+
// TODO: Consider implicit module qualiifers and use instance on all of them
665+
exists(string qualifiedType, DataFlow::TypeNameNode typeName |
666+
pred = MkModule(qualifiedType) and
667+
typeName.getTypeName() = qualifiedType
668+
|
669+
succ = getForwardStartNode(typeName)
670+
)
661671
}
662672

663673
cached

powershell/ql/lib/semmle/code/powershell/frameworks/data/internal/ApiGraphModelsSpecific.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ API::Node getExtraNodeFromType(string qualifiedType) {
7070
qualifiedType = "" and
7171
result = API::root()
7272
or
73-
// TODO: How to distinguish between these two cases? And do we need to?
73+
// TODO: How to distinguish between these cases? And do we need to?
7474
exists(string mod, string type | parseRelevantType(qualifiedType, mod, type) |
7575
result = API::mod(qualifiedType)
7676
or
77+
result = API::mod(qualifiedType).getInstance()
78+
or
7779
result = API::mod(mod).getType(type)
7880
)
7981
}

0 commit comments

Comments
 (0)