fix: validate version argument with semver regex to prevent URL injection (closes #75)#152
Merged
Conversation
added 3 commits
July 4, 2026 00:07
…tion (closes #75) - Add preg_match validation in bin/zvec-install for CLI entry point - Add preg_match validation in Installer::install() for programmatic path - Reject path traversal, incomplete semver, empty strings, and URL-unsafe characters - Accept standard semver with optional pre-release suffixes (e.g. v0.5.0-alpha1) - Add tests/test_installer_version_validation.phpt with 12 test cases
- Fix regex to reject trailing dots/hyphens (require word char at end) - Remove redundant ?? operator in bin/zvec-install - Add test cases for trailing dot, hyphen, double hyphen
s2x
force-pushed
the
fix/issue-75-version-validation
branch
from
July 3, 2026 22:13
cf51e52 to
e79a1b4
Compare
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.
Description
Closes #75
The CLI installer (
bin/zvec-install) andInstaller::install()accepted arbitrary version strings without validation. A crafted argument like../../other/repo/v1.0.0could manipulate the download URL structure.Changes
preg_matchvalidation with semver regex in bothbin/zvec-install(CLI entry point) andInstaller::install()(programmatic path)RuntimeExceptionwith descriptive messagev0.5.0-alpha1,v0.4.0-rc.2)+), trailing dots/hyphensTesting
tests/test_installer_version_validation.phpt- 15 test casesv0.4.0,v1.2.3,v0.5.0-alpha1,v0.4.0-rc.2Code Review
Files Changed
bin/zvec-install- version validation beforeInstaller::install()callsrc/Installer.php- version validation ininstall()before URL constructiontests/test_installer_version_validation.phpt- new test fileCHANGELOG.md- entry under Security section