buskill-app
buskill-app copied to clipboard
Add Integrity Check to "Initialize USB Storage"
This ticket will track the effort to update the Initialize USB Storage process to include integrity checks when provisioning a USB drive with the BusKill software.
This was skipped in the initial ticket because it's non-trivial to execute something like sha256sum -c recursively on a directory in Windows.
Today we got a question answered on SE that may address that:
- https://stackoverflow.com/questions/72087842/windows-equivalent-to-sha256sum-c-cryptographic-hash-digest-file-recursive
Create the digest file
Run the following command on Windows to generate a sha256sums file (in fact, we won't be doing this as the file is generated in linux).
Get-ChildItem -Recurse -Exclude sha256sums | Get-FileHash -Algorithm SHA256
| % {$_.Hash + " " + (Resolve-Path -Path $_.Path -Relative)} | Out-File
-FilePath sha256sums -Encoding utf8NoBOM
Verify the digest file
Run this command on Windows to recursively verify the integrity of a sha256sums digest file
Get-Content -Path sha256sums | % {$Hash, $_, $File = $_.Split(" ", 3); if
($Hash) { [PSCustomObject]@{Path=$File; Result=if ((Get-FileHash -Path
$File -Algorithm SHA256).Hash -eq $Hash) { "OK" } else { "FAILED" }}}} |
Format-List
I've not verified the efficacy of the above command at all.