fix: validate package names are lowercase

This commit is contained in:
daimond113 2024-10-30 17:07:17 +01:00
parent b4c447a129
commit b6f35b6209
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
3 changed files with 12 additions and 4 deletions

View file

@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Listen for device flow completion without requiring pressing enter by @daimond113
- Sync scripts repo in background by @daimond113
- Don't make CAS files read-only on Windows (file removal is disallowed if the file is read-only) by @daimond113
- Validate package names are lowercase by @daimond113
### Performance
- Clone dependency repos shallowly by @daimond113

View file

@ -122,7 +122,8 @@ impl StorageImpl for S3Storage {
let object_url = PutObject::new(
&self.s3_bucket,
Some(&self.s3_credentials),
&format!("doc/{}.gz", doc_hash),
// capitalize Doc to prevent conflicts with scope names
&format!("Doc/{}.gz", doc_hash),
)
.sign(S3_SIGN_DURATION);
@ -142,7 +143,7 @@ impl StorageImpl for S3Storage {
let object_url = GetObject::new(
&self.s3_bucket,
Some(&self.s3_credentials),
&format!("doc/{}.gz", doc_hash),
&format!("Doc/{}.gz", doc_hash),
)
.sign(S3_SIGN_DURATION);

View file

@ -47,7 +47,10 @@ impl FromStr for PackageName {
return Err(Self::Err::PrePostfixUnderscore(reason, part.to_string()));
}
if !part.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
if !part
.chars()
.all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')
{
return Err(Self::Err::InvalidCharacters(reason, part.to_string()));
}
}
@ -172,7 +175,10 @@ pub mod wally {
return Err(Self::Err::InvalidLength(reason, part.to_string()));
}
if !part.chars().all(|c| c.is_ascii_alphanumeric() || c == '-') {
if !part
.chars()
.all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '-')
{
return Err(Self::Err::InvalidCharacters(reason, part.to_string()));
}
}