Skip to content

Conversation

@MathiasVP
Copy link
Collaborator

Pipeline elements appear implicitly in a lot of places in Powershell. For example, in something like:

$a = My-Foo 42

This looks like an assignment where the right-hand side is a Cmd, but it's actually an assignment where the right-hand side is a Pipeline containing a single element: A Cmd.

This is an artifact from the Powershell parser, and from a query-writing perspective is very confusing. So this PR removes Pipelines containing only a single element. This means that the right-hand of $a = MyFoo-42 actually is a Cmd. However, if one were to write something like $a = My-Foo 42 | MyBar "abc" then we'd have a Pipeline on the right-hand side as expected.

The first commit updates the extractor to skip Pipelines when they wrap a single element. Most of the touched files are because we had to change the way we generate the parent relation such that it skips single-element Pipelines. For example, the parent of My-Foo 42 in $a = My-Foo 42isn't thePipeline(since we don't extract single-elementPipelinesanymore), but rather the parent of thatPipeline`.

The next commit fixes up the GitHub script for generating up- and down-grade scripts to also work on Powershell, and the next commit runs the script to generate the up- and down-grade scripts. It's probably possible to generate a better up- and down-grade script pair that improves analyses on old databases, but I don't think it's really worth it since we don't actually run a lot of Powershell analysis yet.

The final commit accepts the test changes. This is simple removal of elements that are no longer in the database.

@MathiasVP MathiasVP merged commit be8a763 into main Sep 23, 2024
MathiasVP added a commit that referenced this pull request Sep 23, 2024
bdrodes pushed a commit that referenced this pull request Jan 9, 2025
Make Argument Injection queries experimental
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants