Skip to content

Restrict characters in URLs of packages and platforms #6962 #7730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

luigimagdamit
Copy link

Added parser functionality to throw an error if disallowed URL characters appear to mitigate security issues through platforms and package url's

Comment on lines +93 to 106
if let Some((index, ch)) = url
.chars()
.any(|ch| MISLEADING_CHARACTERS_IN_URL.contains(&ch))
.enumerate()
.find(|(_, ch)| (!ch.is_alphanumeric() && !ALLOWED_URL_CHARACTERS.contains(ch)) || MISLEADING_CHARACTERS_IN_URL.contains(ch))
{
return Err(UrlProblem::MisleadingCharacter);
// Check if there is an intentionally misleading url character
// Otherwise check if there is a possibly insecure character in the url
if MISLEADING_CHARACTERS_IN_URL.contains(&ch) {
return Err(UrlProblem::MisleadingCharacter);
} else {
return Err(UrlProblem::InsecureCharacter((ch.to_string(), index)));
}

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this'd be a bit easier to read/understand if rather than making this a single if, you split it out into two: one that's exactly like what was there before, and a second one after that to check this new condition.

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.

2 participants