Skip to content

Conversation

@tembleking
Copy link
Member

The semver crate 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:

  1. Replacing the semver::Version type with a simple String for storing package versions.
  2. Introducing the version-compare crate, which is more flexible and capable of comparing different versioning schemes.
  3. Expanding the test suite to validate the correct behavior for a wide range of version formats, ensuring the suggested fix logic is robust.

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.
@tembleking tembleking enabled auto-merge (squash) October 29, 2025 10:04
@tembleking tembleking requested a review from Copilot October 29, 2025 10:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 semver crate throughout the codebase
  • Adds version-compare crate 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.

@tembleking tembleking merged commit 79c8155 into master Oct 29, 2025
5 checks passed
@tembleking tembleking deleted the feat/non-semantic-versions branch October 29, 2025 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants