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

Only allow -File to accept .ps1 scripts on Windows #15859

Merged
merged 5 commits into from
Aug 3, 2021

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Aug 3, 2021

PR Summary

A change was made previously to support shebang on Linux to accept files without requiring .ps1 extension. However, Windows doesn't support shebang, so we should be consistent with Windows PowerShell and only allow for scripts with .ps1 extension.

Fix is to update consolehost -File parsing path to check if the file has a .ps1 extension on Windows and return an error.
A bunch of tests had to be updated with the new behavior.

PR Checklist

@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Aug 3, 2021
@SteveL-MSFT
Copy link
Member Author

static analysis failures are not related to this PR, still not sure why those URLs fail in CI but work locally from my dev machine unless CI is using a proxy for internet.

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Aug 3, 2021
…eterParser.cs

Co-authored-by: Paul Higinbotham <paulhi@microsoft.com>
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Aug 3, 2021
@SteveL-MSFT
Copy link
Member Author

SteveL-MSFT commented Aug 3, 2021

Don't know why codeql is failing as it's complaining about --print-diagnostics-summary being an invalid switch, but it's clearly supported via https://codeql.github.com/docs/codeql-cli/manual/database-interpret-results/

@TravisEz13 TravisEz13 added the WG-Security security related areas such as JEA label Aug 3, 2021
@TravisEz13 TravisEz13 changed the title Only allow -File to accept .ps1 scripts on Windows Only allow -File to accept .ps1 scripts on Windows Aug 3, 2021
@TravisEz13 TravisEz13 merged commit 6933c5b into PowerShell:master Aug 3, 2021
@SteveL-MSFT SteveL-MSFT deleted the file-ps1 branch August 6, 2021 20:02
xtqqczze pushed a commit to xtqqczze/PowerShell that referenced this pull request Aug 9, 2021
)

Co-authored-by: Ilya <darpa@yandex.ru>
Co-authored-by: Paul Higinbotham <paulhi@microsoft.com>
@ghost
Copy link

ghost commented Aug 23, 2021

🎉v7.2.0-preview.9 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Sep 28, 2021

🎉v7.2.0-preview.10 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log WG-Security security related areas such as JEA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants