feat(domain): Use String for Package Versions to Support Non-SemVer Formats#27
Merged
tembleking merged 1 commit intomasterfrom Oct 29, 2025
Merged
Conversation
The 'semver' crate cannot handle a wide variety of package versions
found in the wild, such as Debian versions ('1.1.35-1.2+deb13u2') or
other formats like '31.0-api'.
This change replaces 'semver::Version' with 'String' to store package
versions, and uses the 'version-compare' crate to compare them when
suggesting a fix.
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the strict semver::Version type with String for package versions to support non-standard version formats like Debian packages and Android versions that cannot be parsed by the semver crate. It introduces the version-compare crate for more flexible version comparison logic.
- Removes dependency on
semvercrate throughout the codebase - Adds
version-comparecrate for handling diverse version formats - Expands test coverage with various real-world version formats including Debian, Android, and Jenkins versions
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/domain/scanresult/package.rs | Updates Package struct to use String for version field and implements custom version comparison logic |
| src/domain/scanresult/vulnerability.rs | Changes fix_version field from Option to Option |
| src/domain/scanresult/scan_result.rs | Updates method signatures to accept String instead of Version for package and vulnerability creation |
| src/infra/sysdig_image_scanner_json_scan_result_v1.rs | Removes semver parsing that could cause panics and uses raw version strings |
| tests/general.rs | Updates test fixtures to use string literals instead of semver parsing |
| Cargo.toml | Adds version-compare dependency and bumps package version |
| Justfile | Adds cargo machete --fix command |
| .pre-commit-config.yaml | Sets always_run: true for cargo-check hook |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
alecron
approved these changes
Oct 29, 2025
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.
The
semvercrate is strict and cannot parse many package versions found in the wild, such as those from Debian (e.g.,1.1.35-1.2+deb13u2) or other non-standard formats (e.g.,31.0-api,32.0.0-android). This caused panics when the application encountered these versions.This PR resolves the issue by:
semver::Versiontype with a simpleStringfor storing package versions.version-comparecrate, which is more flexible and capable of comparing different versioning schemes.