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

Add-PoshGitToProfile should not modify signed prof #428

Merged
merged 2 commits into from
Feb 20, 2017

Conversation

rkeithhill
Copy link
Collaborator

Forgot to address this issue before shipping 0.7.0 - #328 (comment)

Merge to develop.

Forgot to address this issue before shipping 0.7.0 - #328 (comment)

Merge to develop.
@rkeithhill rkeithhill added this to the v0.7.1 milestone Feb 18, 2017
Copy link
Owner

@dahlbyk dahlbyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question.

Merge to develop.

We can periodically open PRs from master into develop.

src/Utils.ps1 Outdated
# If the profile script exists and is signed, then we should not modify it
if (Test-Path -LiteralPath $profilePath) {
$sig = Get-AuthenticodeSignature $profilePath
if ($sig.Status -eq [System.Management.Automation.SignatureStatus]::Valid) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we warn/abort if $sig.Status is anything other than NotSigned?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. I'll make that change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that turned out to be a little ugly as there are three values that can represent an unsigned file (NotValid, UnknownError, IncompatibleFileType) and four values that can represent a signed file. Switching to testing the SignatureType field.

@@ -82,18 +82,32 @@ function Invoke-Utf8ConsoleCommand([ScriptBlock]$cmd) {
.OUTPUTS
None.
#>
function Add-PoshGitToProfile([switch]$AllHosts, [switch]$Force, [switch]$WhatIf) {
function Add-PoshGitToProfile {
[CmdletBinding(SupportsShouldProcess)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Always forget about this.

SignatureStatus appears to have four enum values that correspond to a signed file vs three for not signed.  Switching to check the SignatureType value as it will indicate Authenticode when file is Authenticode signed even if the hash doesn't match (been modified previously) or the cert is not trusted / incompatible.
@dahlbyk dahlbyk merged commit 80e62b2 into master Feb 20, 2017
@dahlbyk dahlbyk deleted the rkeithhill/do-not-modify-signed-profile branch February 20, 2017 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants