Skip to content

Commit

Permalink
Package proposal: magika
Browse files Browse the repository at this point in the history
  • Loading branch information
emtuls committed Mar 6, 2024
1 parent 11f59e9 commit 2a718e2
Show file tree
Hide file tree
Showing 5 changed files with 49 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.20240304</version>
<version>0.0.0.20240306</version>
<description>Common libraries for VM-packages</description>
<authors>Mandiant</authors>
</metadata>
Expand Down
10 changes: 10 additions & 0 deletions packages/common.vm/tools/vm.common/vm.common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1460,3 +1460,13 @@ function VM-Add-To-Path {
[System.Environment]::SetEnvironmentVariable("Path", $newPath, [System.EnvironmentVariableTarget]::Machine)
}
}

function VM-Pip-Install {
param (
[string]$package
)
# Create output file to log python module installation details
$outputFile = VM-New-Install-Log ${Env:VM_COMMON_DIR}

Invoke-Expression "py -3.10 -m pip install $package --disable-pip-version-check 2>&1 >> $outputFile"
}
13 changes: 13 additions & 0 deletions packages/magika.vm/magika.vm.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>magika.vm</id>
<version>0.5.0</version>
<authors>Google</authors>
<description>Magika is an AI powered file type detection tool that uses deep learning to provide accurate detection.</description>
<dependencies>
<dependency id="common.vm" />
<dependency id="libraries.python3.vm" />
</dependencies>
</metadata>
</package>
16 changes: 16 additions & 0 deletions packages/magika.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$ErrorActionPreference = 'Stop'
Import-Module vm.common -Force -DisableNameChecking

try {
$toolName = 'magika'
$category = 'File Information'
$executablePath = "$toolName"
$arguments = "-h"
$iconLocation = Join-Path ${Env:WinDir} "system32\cmd.exe" -Resolve

VM-Pip-Install $toolName

VM-Install-Shortcut $toolName $category $executablePath -consoleApp $true -arguments $arguments -iconLocation $iconLocation
} catch {
VM-Write-Log-Exception $_
}
9 changes: 9 additions & 0 deletions packages/magika.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$ErrorActionPreference = 'Continue'
Import-Module vm.common -Force -DisableNameChecking

$toolName = 'magika'
$category = 'File Information'

Invoke-Expression "py -3.10 -m pip uninstall $toolName -y"

VM-Uninstall $toolName $category

0 comments on commit 2a718e2

Please sign in to comment.