GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Replace test certificates with self-signed certificate generating command by rjmholt · Pull Request #7875 · PowerShell/PowerShell Conversation
Collaborator
PR SummaryAdds a dependency on the newly published SelfSignedCertificate module so that we can construct our own self-signed certificates at test time rather than checking them in. To do this, the following happens:
PR Checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Rob Holt (rjmholt)
requested review from
Travis Plunk (TravisEz13),
Andrew (anmenaga) and
Dongbo Wang (daxian-dbw)
as code owners
Steve Lee (SteveL-MSFT)
requested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even though this module is for test, perhaps it's ok to just use
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had that exact discussion with James Truher (@JamesWTruher) and argued that we shouldn't pollute the installed modules because PowerShell was build on a machine. But I will make the change
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should not be polluting the user's space with anything that isn't explicitly testing our behavior for the current user. These tests are very likely to be run on a dev box and we should not be adding stuff to the current user's scope. Further, this is a tool only for our tests. If the user happens to have this already, it still shouldn't use it, we should be using the module that we know we should be using in the location that we control without molesting their environment.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather put it into a temp folder then
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, the pfx files should be generated outside of the repo structure
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The question is where. We don't have a cross-platform temp dir and I would very much prefer not to put it in Arguably we should refactor things to do exactly that, but I think that is out of scope of this PR.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now,
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't have a hardcoded password. Looks like the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe be better to store in env var the generated password rather than hardcode
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…emove-web-cmdlet-test-certs …holt/PowerShell into remove-web-cmdlet-test-certs
Rob Holt (rjmholt)
force-pushed
the
remove-web-cmdlet-test-certs
branch
from
07044ee to
89e27c7
Compare
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was an error while loading. Please reload this page.
|
Steve Lee (@SteveL-MSFT) Yes I just fixed them 🤞 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
72256f8 to
70c01d0
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Steve Lee (@SteveL-MSFT) I found some samples of hard coded passwords in test files by key "password". (And in New-TestHost too).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| # Path to a directory to store modules we temporarily need to test PowerShell | ||
| $script:TestModuleDirPath = Join-Path ([System.IO.Path]::GetTempPath()) 'PwshTestModules' | ||
| New-Item -Force -ItemType Directory -Path $script:TestModuleDirPath |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Do we need output to console? If no we should New-Item > $null.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| # Autoload (in subprocess) temporary modules used in our tests | ||
| $command += '$env:PSModulePath = '+"'$TestModulePath$TestModulePathSeparator'" + '+$($env:PSModulePath);' | ||
| $command += '$env:PSModulePath = '+"'$TestModulePath$TestModulePathSeparator$script:TestModuleDirPath$TestModulePathSeparator'" + '+$env:PSModulePath;' |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid of such expressions. Maybe use Join-Path before the line?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Join-Path won't work since we want ; and not \ (or : and not / on *nix). But I'll break this expression up a bit
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
|
||
| # Hackery to create a new 10 digit random hex string as a password | ||
| $rand = [Random]::new() | ||
| $global:protectedCertPassword = ConvertTo-SecureString -Force -AsPlainText (((1..10).ForEach{ '{0:x}' -f $rand.Next(0xf) }) -join '') |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Better expose it through a function, instead of a global variable. The global variable will linger around even after you remove the module from a session.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
|
||
| $random = [Random]::new() | ||
|
|
||
| return ((1..$Length).ForEach{ '{0:x}' -f $random.Next(0xf) }) -join '' |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This code is the same as New-CertificatePassword can we re-use the code?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is there a common module I could put the function to generate a password in that is imported in both the web cmdlet tests and the CmdMessage tests?
Right now the only common module I can think of is the SelfSignedCertificate module, but that's not part of this codebase
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.