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

vm.common: add -iconLocation param to VM-Install-From-Zip #1202

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/capa-explorer-web.vm/capa-explorer-web.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>capa-explorer-web.vm</id>
<version>1.0.0</version>
<version>1.0.0.20241218</version>
<authors>Soufiane Fariss</authors>
<description>Web interface for exploring and understanding capa results</description>
<dependencies>
Expand Down
3 changes: 2 additions & 1 deletion packages/capa-explorer-web.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ $zipUrl = 'https://github.com/mandiant/capa/raw/refs/heads/master/web/explorer/r
$zipSha256 = '3a7cf6927b0e8595f08b685669b215ef779eade622efd5e8d33efefadd849025'

$executableName = "index.html"
VM-Install-From-Zip $toolName $category $zipUrl $zipSha256 -executableName $executableName -withoutBinFile -innerFolder $true
$iconName = "favicon.ico"
VM-Install-From-Zip $toolName $category $zipUrl $zipSha256 -executableName $executableName -iconLocation $iconName -withoutBinFile -innerFolder $true
Comment on lines +10 to +11
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Ana06 please let me know if this works out for you.

Copy link
Member

@Ana06 Ana06 Jan 10, 2025

Choose a reason for hiding this comment

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

Sorry for the late reply (Xmas vacation 🎄 😅). There are two issues:

  • You need to request in the nuspec of capa-explorer-web.vm that the version of common.vm is the one you where you have added the new function (or newer). To do this, the dependency has to be requested as <dependency id="common.vm" version="0.0.0.20241218" />
  • The iconLocation expects an absolute path in VM-Install-Shortcut. I think it is good to keep it local here, and look for it inside $toolDir in the VM-Install-From-Zip function, to pass the absolute path to VM-Install-Shortcut.

I recommend you to follow the Local Testing instruction in the Wiki to be able to easily test your changes. If you need any issues or questions while setting a local testing setup, please let me know. I am happy to help! 😄

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.20241216</version>
<version>0.0.0.20241218</version>
<description>Common libraries for VM-packages</description>
<authors>Mandiant</authors>
</metadata>
Expand Down
10 changes: 6 additions & 4 deletions packages/common.vm/tools/vm.common/vm.common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@ function VM-Install-From-Zip {
# $powershellCommand = "Get-Content README.md"
# $powershellCommand = "Import-Module module.ps1; Get-Help Main-Function"
[Parameter(Mandatory=$false)]
[string] $powershellCommand
[string] $powershellCommand,
[Parameter(Mandatory=$false)]
[string] $iconLocation
)
try {
$toolDir = Join-Path ${Env:RAW_TOOLS_DIR} $toolName
Expand Down Expand Up @@ -432,20 +434,20 @@ function VM-Install-From-Zip {

if ($powershellCommand) {
$executablePath = $toolDir
VM-Install-Shortcut -toolName $toolName -category $category -arguments $powershellCommand -executableDir $executablePath -powershell
VM-Install-Shortcut -toolName $toolName -category $category -arguments $powershellCommand -executableDir $executablePath -powershell -iconLocation $iconLocation
}
elseif ($withoutBinFile) { # Used when tool does not have an associated executable
if (-Not $executableName) { # Tool is located in $toolDir (c3.vm for example)
$executablePath = $toolDir
} else { # Tool is in a specific directory (pma-labs.vm for example)
$executablePath = Join-Path $toolDir $executableName -Resolve
}
VM-Install-Shortcut -toolName $toolName -category $category -executablePath $executablePath
VM-Install-Shortcut -toolName $toolName -category $category -executablePath $executablePath -iconLocation $iconLocation
}
else {
if (-Not $executableName) { $executableName = "$toolName.exe" }
$executablePath = Join-Path $toolDir $executableName -Resolve
VM-Install-Shortcut -toolName $toolName -category $category -executablePath $executablePath -consoleApp $consoleApp -arguments $arguments
VM-Install-Shortcut -toolName $toolName -category $category -executablePath $executablePath -consoleApp $consoleApp -arguments $arguments -iconLocation $iconLocation
Install-BinFile -Name $toolName -Path $executablePath
}
return ,@($toolDir, $executablePath)
Expand Down
Loading