Skip to content

Commit

Permalink
Merge pull request #824 from Ana06/signature-chrome
Browse files Browse the repository at this point in the history
Add VM-Assert-Signature & use to to add Google Chrome
  • Loading branch information
Ana06 authored Jan 12, 2024
2 parents 680d76b + 898e91f commit 9775211
Show file tree
Hide file tree
Showing 5 changed files with 57 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
12 changes: 12 additions & 0 deletions packages/googlechrome.vm/googlechrome.vm.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>googlechrome.vm</id>
<version>0.0.0.20240111</version>
<authors>Google LLC.</authors>
<description>Chrome is a popular web browser.</description>
<dependencies>
<dependency id="common.vm" version="0.0.0.20240111" />
</dependencies>
</metadata>
</package>
26 changes: 26 additions & 0 deletions packages/googlechrome.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
$ErrorActionPreference = 'Stop'
Import-Module vm.common -Force -DisableNameChecking

try {
# Download the installer
$packageArgs = @{
packageName = $env:ChocolateyPackageName
file = Join-Path ${Env:TEMP} 'googlechromeinstaller.msi'
url = 'https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise.msi'
url64bit = 'https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise64.msi'
}
$filePath = Get-ChocolateyWebFile @packageArgs
VM-Assert-Path $filePath
VM-Assert-Signature $filePath

# Install the downloaded installer
$packageArgs = @{
packageName = $env:ChocolateyPackageName
file = $filePath
fileType = 'MSI'
silentArgs = "/quiet /norestart /l*v `"$($env:TEMP)\$($env:chocolateyPackageName).$($env:chocolateyPackageVersion).MsiInstall.log`""
}
Install-ChocolateyInstallPackage @packageArgs
} catch {
VM-Write-Log-Exception $_
}
1 change: 1 addition & 0 deletions scripts/test/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ class UsesInvalidCategory(Lint):
"debloat.vm",
"dokan.vm",
"flarevm.installer.vm",
"googlechrome.vm",
"ida.plugin.capa.vm",
"idafree.vm",
"installer.vm",
Expand Down

0 comments on commit 9775211

Please sign in to comment.