(sandbox_id: &str)
| 3225 | |
| 3226 | #[allow(clippy::result_large_err)] |
| 3227 | fn validate_sandbox_id(sandbox_id: &str) -> Result<(), Status> { |
| 3228 | if sandbox_id.is_empty() { |
| 3229 | return Err(Status::invalid_argument("sandbox id is required")); |
| 3230 | } |
| 3231 | if sandbox_id.len() > 128 { |
| 3232 | return Err(Status::invalid_argument( |
| 3233 | "sandbox id exceeds maximum length (128 bytes)", |
| 3234 | )); |
| 3235 | } |
| 3236 | if matches!(sandbox_id, "." | "..") { |
| 3237 | return Err(Status::invalid_argument( |
| 3238 | "sandbox id must match [A-Za-z0-9._-]{1,128}", |
| 3239 | )); |
| 3240 | } |
| 3241 | if !sandbox_id |
| 3242 | .bytes() |
| 3243 | .all(|b| b.is_ascii_alphanumeric() || matches!(b, b'.' | b'_' | b'-')) |
| 3244 | { |
| 3245 | return Err(Status::invalid_argument( |
| 3246 | "sandbox id must match [A-Za-z0-9._-]{1,128}", |
| 3247 | )); |
| 3248 | } |
| 3249 | Ok(()) |
| 3250 | } |
| 3251 | |
| 3252 | #[allow(clippy::result_large_err)] |
| 3253 | fn parse_registry_reference(image_ref: &str) -> Result<Reference, Status> { |
no test coverage detected