feat(osinstaller): verify SHA-256 checksum of downloaded CLI binary#204
Open
wterpstra wants to merge 2 commits intoCheckmarx:mainfrom
Open
feat(osinstaller): verify SHA-256 checksum of downloaded CLI binary#204wterpstra wants to merge 2 commits intoCheckmarx:mainfrom
wterpstra wants to merge 2 commits intoCheckmarx:mainfrom
Conversation
…LI binaries
- readASTCLIVersion() now returns {version, checksum} and caches both; falls back to
cliDefaultVersion and cliDefaultChecksums when the version file is absent or empty,
otherwise pairs the version file with checkmarx-ast-cli.checksums
- getDownloadURL() returns {url, checksum}, passing null when CX_CLI_LOCATION is set
- downloadIfNotInstalledCLI() verifies the downloaded archive when a checksum is available
- Add checkmarx-ast-cli.checksums shipped with the package for custom version pinning
- Add checksum verification test cases covering match, mismatch, null, CX_CLI_LOCATION bypass, and custom version scenarios
dc34e80 to
9776d87
Compare
…or custom versions When a version file is present but the checksums file is missing or lacks an entry for the current platform, log a warning to make the unverified download visible rather than silently skipping verification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The installer currently downloads the CLI binary without verifying its integrity. This PR adds SHA-256 checksum verification to protect against corrupted or tampered downloads.
What changed
CxInstaller.tsreadASTCLIVersion()now returns{ version, checksum }instead of just the version string. The checksum is resolved for the current platform/architecture and cached alongside the version.checkmarx-ast-cli.versionfile is absent or empty, falls back to the hardcodedcliDefaultVersionand its bundledcliDefaultChecksums(compile-time guarantee for the default release).checkmarx-ast-cli.checksumsfile to look up the expected checksum — allowing consumers who pin a custom version to also ship verified checksums.getDownloadURL()now returns{ url, checksum }. Checksum isnullwhenCX_CLI_LOCATIONis set, skipping verification for custom binary sources.downloadIfNotInstalledCLI()verifies the downloaded archive against the expected SHA-256 before extracting. A mismatch throws aCxErrorand exits with code 1.checkmarx-ast-cli.checksums(new file, shipped with the package)2.3.48binaries, keyed byplatform_architecture.checkmarx-ast-cli.versioncan ship a matchingcheckmarx-ast-cli.checksumsalongside it to keep verification active.CxInstallerTest.test.ts{ url }and{ version }from the updated return types.CxInstaller checksum verification casescovering: checksum match (linux + darwin), mismatch, null/missing checksum,CX_CLI_LOCATIONbypass, and custom version scenarios.Testing
Manually verified end-to-end on Linux:
2.3.48binary and passes checksum verification ✓2.3.47(mismatched checksums) correctly triggersprocess.exit(1)✓