Powershell Checksum Verification Module
Powershell Module Designed to assist in ensuring the integrity of a codebase by generating and verifying a VERIFICATION.txt file, created for poweshell packages distributed via chocolatey, can be used to verify the integrity of any codebase.
Available on MacOS, Linux, and WindowsCMDLET-Reference | GitHub | PSGallery | Chocolatey
📚Table of Contents
- Generates and returns
sha256hash for each file within the specified folder contained within a VERIFICATION.txt file. - Reads the verification file and returns a
PSCustomObjectarray containg the file, path, size and 256 hash. - Unitilizes
New-Checksum&Read-CheckSumto generate and read the verification file. - Read and save checksums to
VERIFICATION.txtfile withNew-VerificationFile.
New-VerificationFile generates the verification file. recersivlly compiles a list of all files present. For each file, it computes the SHA256 hash and records the file, path, size and its hash in the verification file(VERIFICATION.txt).
Default output .\tools\VERIFICATION.txt
cd /path/to/folder
New-VerificationFile ⚪ VERIFICATION.txt output example:
VERIFICATION Verification is intended to assist the moderators and community in verifying that this package's contents are trustworthy. To Verify the files in this package, please download/Install module csverify from chocalatey.org or from the powershell gallery. Get-CheckSum -Path $Path e -[checksum hash]- ___________________ 1.23KB | 37511B972FBE38C353B680D55EC5CFE51C04C79CA3304922301C5AB44BAC94F9 | .\README.md 1.05KB | D3FF5A1DB41D78399BD676A16C9321F127BB52B7E7EBF56B14EC5ABC21971213 | .\LICENSE 0.34KB | 813818335A37527755ABDCF200322962E340E2278BBF3E515B21D4D232D9A92A | .\csverify.psm1 4.44KB | 394B7998E79D6DDE3B6FF1318550ED21BC9671F2C8F1AA2354861A120738B422 | .\csverify.psd1
Test-Verification is used to verify the integrity of the codebase base it compares the SHA256 values from VERIFICATION.txt file and Returns file report
⚪ Verification output
Running Verification: Hashed Checksums └─ Verified o--(5 / 5 Files » Found 1 that could not be verified) Status hash Path Size ------ ---- ---- ---- Verified 0DC558C6B5C5B34D9B77D177AEE6130AEAF75C10A0948C635AEC98F5C445790E .\README.md 0.95KB Verified D3FF5A1DB41D78399BD676A16C9321F127BB52B7E7EBF56B14EC5ABC21971213 .\LICENSE 1.05KB Verified F5CEFD9EE2498D5A6BB80F3F26A6B07FD405F3AB3AB63917426CB31EBF5719B9 .\csverify.psm1 0.35KB Verified EB749553314E1280C22EB6CD2E7CF3687EBF0A8D6C259A59C33AA4DFB215D85D .\csverify.psd1 4.44KB 1.14KB
Phellams modules are available from PowerShell Gallery and Chocolatey. you can access the raw assets via Gitlab Generic Assets or nuget repository via Gitlab Packages.
| ▓▓▓▓▒▒▒▒░░░ | ▓▓▓▓▒▒▒▒░░░ | ▓▓▓▓▒▒▒▒░░░ |
|---|---|---|
| 📦 PSGallery | |
|
| 📦 Chocolatey |
| ▓▓▓▓▒▒▒▒░░░ | ▓▓▓▓▒▒▒▒░░░ | ▓▓▓▓▒▒▒▒░░░ |
|---|---|---|
| 💼 Releases/Tags | |
|
Using nuget: See the packages page for installation instructions.
For instructions on adding
nugetsources packages from GitLab see Releases artifacts or via the Packages page.
The latest release artifacts can be downloaded from the Generic Assets Artifacts page.
# Clone the repository
git clone https://gitlab.com/phellams/csverify.git
cd csverify
import-module .\Phellams modules are built using either the phellams-automator Docker image paired with the Automator-Devops scripts to build and publish modules to:
If you prefer not to use the Docker image, you can run the automator-devops scripts locally using PowerShell 7.x.
Dependencies must be installed manually, either from the PowerShell Gallery or by cloning the module directly from the GitHub/GitLab source repository (see below).
All build metadata is stored in the ./build_config.json file. See Build Config for additional information.
local-builder [-Automator (switch)]
[-build_dotnet_lib (switch)]
[-PhWriter (switch)]
[-Pester (switch)]
[-Build (switch)]
[-PsGal (switch)]
[-Nuget (switch)]
[-ChocoNuSpec (switch)]
[-ChocoPackage (switch)]
[-ChocoPackageWindows (switch)]
[-Cleanup (switch)]
| Parameter | Description |
|---|---|
-Automator |
Builds using the phellams-automator Docker image. If not specified, the script will use the local PowerShell installation. All dependencies must be installed locally (see below). |
-build_dotnet_lib |
Calls build-dotnet-library.ps1, which runs dotnet build and dotnet pack to build and package .NET libraries (.nupkg). (WIP – functional but requires refinement.) |
-PhWriter |
Generates the phwriter-metadata.ps1 file using the phwriter module. |
-Pester |
Calls test-pester-before-build.ps1, which runs Invoke-Pester from the Pester module. |
-Sa |
Calls test-sa-before-build.ps1, which runs Invoke-ScriptAnalyzer from the PSScriptAnalyzer module. |
-Build |
Calls build-module.ps1 from the psmpacker module. Copies the built module to the dist folder and generates the VERIFICATION.txt file. |
-Nuget |
Calls build-package-generic-nuget.ps1, which runs New-NuspecPackageFile and New-NupkgPackage from the nupsforge module. |
-PsGal |
Calls build-package-psgallery.ps1, which runs New-NuspecPackageFile from the nupsforge module for PowerShell Gallery publishing. |
-ChocoNuSpec |
Calls build-nuspec-choco.ps1, which runs New-ChocoNuspecFile from the nupsforge module. |
-ChocoPackage (Docker only) |
Calls build-package-choco.sh (Linux only). Runs choco pack and choco push using the choco/choco:latest Docker image. |
-ChocoPackageWindows (Windows only) |
Calls build-package-choco-windows.ps1, which runs New-ChocoNuspecFile and New-ChocoPackage from the nupsforge module. Requires Chocolatey to be installed. |
Build the module locally using the phellams-automator Docker image.
Note: Chocolatey build and publish requires the choco Docker image to be built and published.
pwsh -c ./automator-devops/localbuilder.ps1 -Automator -Build -Nuget -ChocoNuSpec -ChocoPackage -PsGal -CleanupNote (Windows): Chocolatey can be installed easily via https://chocolatey.org/install. Note (Non-Windows): Chocolatey build and publish requires the choco Docker image if not running on Windows.
pwsh -c ./automator-devops/localbuilder.ps1 -Build -Nuget -ChocoNuSpec -ChocoPackage -PsGal -CleanupList of available cmdlets provided by the module.
New-CheckSum generates and returns sha256 hash for each within the specified folder. New-Verification unitilizes New-Checksum & Read-CheckSum.
Syntax:
New-CheckSum -Path (String) [-FromString (string)] [(CommonParameters)]
Parameters:
| Name | Type | Description | Required |
|---|---|---|---|
| Path | String | The path to generate the checksum file for | Yes |
| FromString | String | The string to generate the checksum file for | No |
New-CheckSum -Path ./Example:
Read-CheckSum reads the verification file and returns a PSCustomObject array containg the file, path, size and hash.
Syntax:
Read-CheckSum -Path (String) [(CommonParameters)]
Parameters:
| Name | Type | Description | Required |
|---|---|---|---|
| Path | String | The path to generate the checksum file for | Yes |
Example:
Read-CheckSum -RootPath ./New-VerificationFile generates the verification file. recersivlly compiles a list of all files present. For each file, i t computes the SHA256 hash and records the file, path, size and its hash in the verification file(VERIFICATION.txt).
Syntax:
New-VerificationFile -RootPath (String) -OutPutPath (String) [(CommonParameters)]
Parameters:
| Name | Type | Description | Required |
|---|---|---|---|
| RootPath | String | The path to the folder to generat | Yes |
| OutputPath | String | The output path to generate the verification file to | Yes |
Example:
New-VerificationFile ./ ./dist/chocoTest-Verification is used to verify the integrity of the codebase base it compares the SHA256 values from VERIFICATION.txt file and Returns file report.
Syntax:
Test-Verification -Path (String) [(CommonParameters)]
Parameters:
| Name | Type | Description | Required |
|---|---|---|---|
| Path | String | The path to the verification file | Yes |
Example:
Test-VerificationFeel free to contribute! Fork the repo and submit a merge request with your improvements. Or, open an issue with the enhancement tag to discuss ideas.
-
Fork the Project and clone it:
git clone https://gitlab.com/YOUR_USERNAME/pwsl.git -
Switch to dev and create your branch:
git checkout develop; git checkout -b feature/AmazingFeature -
Commit your changes:
git commit -m 'Add some AmazingFeature' -
Push to the branch:
git push origin feature/AmazingFeature -
Open a Merge Request:
This project is licensed under the MIT Licence, see the LICENSE file for details