fix(virtual_packages): handle invalid chars in LibC family#2209
Open
ayushman1210 wants to merge 3 commits intoconda:mainfrom
Open
fix(virtual_packages): handle invalid chars in LibC family#2209ayushman1210 wants to merge 3 commits intoconda:mainfrom
ayushman1210 wants to merge 3 commits intoconda:mainfrom
Conversation
Contributor
Author
|
hey @baszalmstra please review this pr when you have some free time and if any changes needed please let me know |
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
From<LibC> for GenericVirtualPackagecan panic on invalid characters during package name conversion, as there was an unhandledunwrap()on string parsing.This PR fixes the panic by removing non-alphanumeric characters, replacing them with
_.Because
libc.familyis arbitrary text pulled from the OS, if it contains characters that are invalid for conda package names (like spaces or parentheses), the string parsing would fail and.unwrap()would panic, completely crashing the application.This correctly implements the
TODOcomment that noted the family string should be sanitized (e.g., replacing invalid characters) before converting it into a package name to prevent this panic.Fixes #2208
How Has This Been Tested?
Added 1 unit test in crates/rattler_virtual_packages/src/lib.rs to verify that
libc.familystrings with parentheses and spaces are properly sanitized into package names.cargo test -p rattler_virtual_packagesAI Disclosure
Tools: Google Gemini
Checklist: