[ENG-2586] Harden version comparison with stricter normalization and expanded tests#1
Merged
Merged
Conversation
Contributor
devlob
commented
Apr 15, 2026
- Extract normalizeVersion() to safely strip v-prefix without corrupting versions containing 'v' in body (e.g., 6.3-revision-0, 5.0.37.preview)
- Use strict === comparisons and explicit empty checks instead of loose ==
- Fix range detection regex to avoid misinterpreting dashed versions as ranges
- Replace strpos/stripos with str_contains/str_starts_with (PHP 8.1+)
- Add edge case tests: scientific notation coercion, whitespace-only input, malformed operators, compound dashes, decimal strategy coverage
…expanded tests - Extract normalizeVersion() to safely strip v-prefix without corrupting versions containing 'v' in body (e.g., 6.3-revision-0, 5.0.37.preview) - Use strict === comparisons and explicit empty checks instead of loose == - Fix range detection regex to avoid misinterpreting dashed versions as ranges - Replace strpos/stripos with str_contains/str_starts_with (PHP 8.1+) - Add edge case tests: scientific notation coercion, whitespace-only input, malformed operators, compound dashes, decimal strategy coverage
Contributor
Author
|
/review |
Pest v3 requires PHP 8.2+. The default template had PHP 8.1 in the matrix which caused composer install to fail. Also adds Composer dependency caching and PHP 8.4 to the matrix.
Pest v3 requires a phpunit.xml config in CI environments. Without it, the --cache-directory flag is misinterpreted as an XML config path.
composer.lock is gitignored so CI resolves fresh — PHP 8.1 gets Pest v2, PHP 8.2+ gets Pest v3. Tests the full declared range.
Pest v2.36.1+ and v3 both require PHP 8.2. PHP 8.1 reached EOL Nov 2024. Update composer.json and CI matrix accordingly.
Package will be used in Hub (Laravel 12, PHP 8.4). No need to support older versions.
ejntaylor
approved these changes
Apr 15, 2026
mariojgt
reviewed
Apr 15, 2026
| $affectedIn = trim($affectedIn); | ||
| $currentVersion = trim($currentVersion); | ||
|
|
||
| if (empty($affectedIn) || empty($currentVersion)) { |
There was a problem hiding this comment.
I don't have a lot of background here, but what happens if the currentVersion or affectedIn come through as null? Right now, it looks like they get treated as empty strings, and we return false, which basically means “not vulnerable”.
Contributor
Author
There was a problem hiding this comment.
Because of declare(strict_types=1); that won't happen.
mariojgt
approved these changes
Apr 15, 2026
ae10a99 to
4b5296f
Compare
Hub and saas run PHP 8.2, so this package must support it. No 8.4-specific features are used in the source code.
4b5296f to
1912876
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.