Skip to content
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

Powershell linter throws error if the path it is analyzing has a space in it #1728

Closed
brandonmcclure opened this issue Aug 9, 2022 · 4 comments · Fixed by #1730
Closed
Labels
bug Something isn't working

Comments

@brandonmcclure
Copy link

Describe the bug
When I configure the POWERSHELL_POWERSHELL linter via github CI and change a .ps1 file that has a space in it's file path, I get an error:

--Error detail:
Invoke-ScriptAnalyzer: A positional parameter cannot be found that accepts argument 'with'.

To Reproduce
Steps to reproduce the behavior:

I created a repository that reproduces the behavior I am seeing. https://github.com/brandonmcclure/megalinter_repro/pulls

Expected behavior
The linter to run in the same way it does for modified ps1 files that do not have a space in their path. See this PR for an example of success: https://github.com/brandonmcclure/megalinter_repro/pull/2

@brandonmcclure brandonmcclure added the bug Something isn't working label Aug 9, 2022
@Kurt-von-Laven
Copy link
Collaborator

Have you already attempted to reproduce this issue by running PSScriptAnalyzer directly?

@brandonmcclure
Copy link
Author

I had not, but running these commands from that repo show it working/the same failure if there are no quotes around the file path.

git checkout brandonmcclure-patch-1; Invoke-ScriptAnalyzer -Path '.\path with spaces\test.ps1'

I get the expected result, which is the output of failed rules.

a file with no spaces works good as well/will not

git checkout noSpaces; Invoke-ScriptAnalyzer -Path .\noSpaces.ps1

If I ommit the quotes I get an error, which is the same when running as an action.

git checkout brandonmcclure-patch-1; Invoke-ScriptAnalyzer -Path .\path with spaces\test.ps1
Invoke-ScriptAnalyzer: A positional parameter cannot be found that accepts argument 'with'.

@Kurt-von-Laven
Copy link
Collaborator

Sounds like we are most likely omitting quotes when calling PSScriptAnalyzer then. Thank you for narrowing it down.

@nvuillam
Copy link
Member

@brandonmcclure it should be ok now, please can you check with oxsecurity/megalinter:beta ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants