Skip to content

Instantly share code, notes, and snippets.

@idavis
Created June 12, 2015 16:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idavis/c16f117c0f99eb20c49f to your computer and use it in GitHub Desktop.
Save idavis/c16f117c0f99eb20c49f to your computer and use it in GitHub Desktop.
PowerShell Module Security
@ferventcoder
Copy link

This seems like a bit of a security issue.

@ferventcoder
Copy link

This seems similar to how we discovered Mocking with Chocolatey - https://github.com/chocolatey/chocolatey/tree/fcc68ba881a52984c187390c7c9de66a787505e9/tests

@ferventcoder
Copy link

Recently I learned you don't even need to overwrite the function, just create an alias with the same name and it doesn't matter what your function is named. If the user is just calling it, without a local scope, it will call your alias instead. https://technet.microsoft.com/en-us/library/hh848304.aspx

Windows PowerShell uses the following
precedence order when it runs commands:

1. Alias
2. Function
3. Cmdlet 
4. Native Windows commands

Update: May only work for the exported functions, not the private ones.

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