mirror of
https://github.com/indetectables-net/toolkit.git
synced 2026-10-28 19:40:47 +00:00
Add tools checksum gen
This commit is contained in:
1 parent
05b996f362
commit
d800868287
2 files changed
+20
-5
No files matched your search
@@ -74,7 +74,7 @@ jobs:
|
||||
run: |
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||
.\generate-checksums.ps1 -Directory "${{ env.SRC_PATH }}/toolkit" -OutputFile "${{ github.workspace }}/tools_checksums.txt"
|
||||
.\generate-checksums.ps1 -Directory "${{ github.workspace }}" -FilePattern "*.exe" -OutputFile "${{ github.workspace }}/installer_checksums.txt"
|
||||
.\generate-checksums.ps1 -Directory "${{ github.workspace }}" -FilePattern "*.exe" -NoRecurse -OutputFile "${{ github.workspace }}/installer_checksums.txt"
|
||||
|
||||
- name: Upload Setup as Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
param (
|
||||
[string]$Directory = ".",
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Directory,
|
||||
[string]$OutputFile = "checksums.txt",
|
||||
[string]$FilePattern = "*"
|
||||
[string]$FilePattern = "*",
|
||||
[switch]$NoRecurse
|
||||
)
|
||||
|
||||
# Initialize an array to store the hash results
|
||||
@@ -21,13 +23,26 @@ function Get-FileHashSHA256 {
|
||||
return [BitConverter]::ToString($hash) -replace "-", ""
|
||||
}
|
||||
|
||||
# Verify that the Directory parameter is provided
|
||||
if (-not $Directory) {
|
||||
Write-Error "The 'Directory' parameter is mandatory."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Get the full path of the directory
|
||||
$fullDirectoryPath = (Get-Item -Path $Directory).FullName
|
||||
|
||||
# Determine if recursion is enabled
|
||||
if ($NoRecurse) {
|
||||
$searchOption = [System.IO.SearchOption]::TopDirectoryOnly
|
||||
} else {
|
||||
$searchOption = [System.IO.SearchOption]::AllDirectories
|
||||
}
|
||||
|
||||
# Iterate over each file in the directory matching the pattern
|
||||
Get-ChildItem -Path $Directory -Filter $FilePattern -File -Recurse | ForEach-Object {
|
||||
Get-ChildItem -Path $Directory -Filter $FilePattern -File -Recurse:$searchOption | ForEach-Object {
|
||||
$fileHash = Get-FileHashSHA256 -filePath $_.FullName
|
||||
$relativePath = $_.FullName.Substring($fullDirectoryPath.Length).TrimStart('\')
|
||||
$relativePath = $_.FullName.Substring($fullDirectoryPath.Length + 1).TrimStart('\')
|
||||
$hashResults += "$fileHash .\$relativePath"
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user