Skip to content

Enable script-based rules to be contributed to the core ruleset #743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
daviwil opened this issue Mar 31, 2017 · 5 comments
Open

Enable script-based rules to be contributed to the core ruleset #743

daviwil opened this issue Mar 31, 2017 · 5 comments

Comments

@daviwil
Copy link
Contributor

daviwil commented Mar 31, 2017

Just opening up this issue to track the need for this. @ThmsRynr has a few rules he'd like to contribute so we'll need to make it possible for his rules and more like them to be contributed.

@bergmeister
Copy link
Collaborator

bergmeister commented Apr 1, 2018

@ThmsRynr I have a prototype in my branch here that makes this work for the CommunityAnalyzerRules only (due to a hard-coded folder name as a PoC ) if you copy the CommunityAnalyzerRules folder into a folder named ScriptRules into the PSSA module installation directory (i.e. something like C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer\1.16.1\ScriptRules).
As expected, it has a bad performance hit. Whenn running it against simple one-liners, execution time (after JITTING/warmup but the factor are similar when running the command for the first time) increased from around 80 ms to 350ms and executing the entire test suite increases from 2 to 5 min.
Could you give a link to the rules that you would like to contribute? Depending on how complex they are, it might be better to just rewrite them in C#.

@bergmeister
Copy link
Collaborator

@ThmsRynr I discussed this with @SteveL-MSFT at psconf.eu. We either need to either provide a way of optionally running script base rules or translate the rule into C# for performance reasons. Could you provide some examples of the rules that you would like to contribute?

@thomasrayner
Copy link
Contributor

Hey, @bergmeister . As I continue to get deeper into writing PSSA rules myself, I'm growing increasingly willing to write them in C#, but I'm just one case. I'm sure there are lots of awesome rules or contributions waiting to be made by people who are PowerShell people but aren't willing to learn C#.

I've got a modest repo of custom PSSA rules that I'd consider proposing, written in PowerShell. https://github.com/ThmsRynr/CustomPSSARules

Some of them are more deserving of consideration than others, and some could use some polishing. The ones that make the most sense are probably in the Casing folder.

@SteveL-MSFT
Copy link
Member

I think what we could do is make running script based rules opt-in. We should still take contributions that are in PowerShell Script, but I'm hoping the community can help converting popular rules to C# over time.

@thomasrayner
Copy link
Contributor

That sounds like a pretty reasonable compromise, @SteveL-MSFT. When the issue was originally opened, I don't think we anticipated the size of the performance impact of running PowerShell-based rules. The idealist in me wants to reply with something about addressing the performance impact but I know it's not likely a PSSA issue, and it's probably not worth tackling even if it was.

Clearly this is a big conspiracy to force me to start writing C# again. Looking forward to getting back into some C#!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants