Skip to content

Commit

Permalink
[common] Add VM-Assert-Signature
Browse files Browse the repository at this point in the history
`VM-Assert-Signature` will allows us to install packages checking their
signatures instead of their hash. Useful for Microsoft tools like
sysinternals that use URLs without version.

Co-authored-by: Genwei Jiang <[email protected]>
  • Loading branch information
Ana06 and binjo committed Jan 11, 2024
1 parent f9b8229 commit 4b95a74
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/common.vm/common.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>common.vm</id>
<version>0.0.0.20240105</version>
<version>0.0.0.20240111</version>
<description>Common libraries for VM-packages</description>
<authors>Mandiant</authors>
</metadata>
Expand Down
17 changes: 17 additions & 0 deletions packages/common.vm/tools/vm.common/vm.common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,23 @@ function VM-Assert-Path {
}
}

# Raise an exception if the Signature of $file_path is invalid
function VM-Assert-Signature {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[String] $file_path
)
$signature_status = (Get-AuthenticodeSignature -FilePath $file_path).Status
if ($signature_status -eq 'Valid') {
VM-Write-Log "INFO" "Valid signature: $file_path"
} else {
$err_msg = "Invalid signature: $file_path"
VM-Write-Log "ERROR" $err_msg
throw $err_msg
}
}

function VM-Get-DiskSize {
$diskdrive = "${Env:SystemDrive}"
$driveName = $diskdrive.substring(0, $diskdrive.length-1)
Expand Down

0 comments on commit 4b95a74

Please sign in to comment.