PS: Handle more flow sources #200
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does a couple of things to add more flow sources to PowerShell:
It adds a
Stored.qll
file containing a subclass of local flow sources that represents file reads. It turns out we already have some flow sources belonging to this kind since we stole them from C#:codeql/powershell/ql/lib/semmle/code/powershell/frameworks/SystemIOFile/model.yml
Line 10 in 1637df0
SourceNode
😅Then, I also discovered two sources of user flow recently. For example, Select-XML, which can read user input when given an
-Path
argument. So this PR also adds MaD syntax for specifying "the return value of a call when there is a specific named argument". After adding this functionality, this PR also models calls toSelect-XML
andFormat-Hex
as remote flow sources of this kind.It fixes a bunch of incorrect models for flow sources. I had incorrectly marked some of them as static method calls, where they should have been non-static method calls.
Field
/Property
s should have beenMember
all along in the type models. I've done a mass-renaming to fix this. I've also made all the method names lower-case.It adds testcases for all the currently flow sources. Most of the above fixes are motivated by these tests which were written by a combination of me and Bing 😅