gretard / sonar-ps-plugin

Powershell language plugin for SonarQube
GNU Lesser General Public License v3.0
36 stars 7 forks source link

PS Plugin Support for Linux? #32

Closed kirkpabk closed 7 months ago

kirkpabk commented 7 months ago

Since PowerShell is largely cross-platform, are there any plans to help drive PS Script Analyzer for Linux?

Understand this is not core to this project--but additional pushing, might help.

gretard commented 7 months ago

Hi, Thanks for raising this, but I think it is already supported. Please check:

  1. Installing Powershell on Linux (for example Ubuntu https://learn.microsoft.com/en-us/powershell/scripting/install/install-ubuntu?view=powershell-7.4)
  2. Installing PSScript analyzer (https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview?view=ps-modules#installing-psscriptanalyzer), for example in the terminal execute to install it: pwsh -Command "Install-Module -Name PSScriptAnalyzer -Force"
  3. Test if module is working properly: pwsh -Command "Invoke-ScriptAnalyzer -ScriptDefinition '"b" = "b"; function eliminate-file () { }'"
  4. Once you executed previous steps, please specify "sonar.ps.executable" property to point to powershell executable on the linux (you can find it by using command whereis pwsh): sonar.ps.executable="/usr/bin/pwsh"

Now plugin should be able to work on Linux and you should see results on the SonarQube server :) Please let me know if that helped.

kirkpabk commented 7 months ago

Thanks @gretard! We will give it a shot. Our environment is closed, so we'd have the manually install the modules. The only binaries we saw were the packaged ones with the .dll assemblies. So--we'll take another look. Thanks again!