Validate package dependency against public registry
(
package: &mut PackageDependency,
client: &Client,
)
| 416 | |
| 417 | /// Validate package dependency against public registry |
| 418 | pub async fn validate_package( |
| 419 | package: &mut PackageDependency, |
| 420 | client: &Client, |
| 421 | ) -> Result<(), String> { |
| 422 | sleep(Duration::from_millis(100)).await; // Rate limiting |
| 423 | |
| 424 | let (exists, registry_url, error) = match package.package_type { |
| 425 | PackageType::NPM => validate_npm_package(&package.package_name, client).await, |
| 426 | PackageType::PIP => validate_pip_package(&package.package_name, client).await, |
| 427 | PackageType::GO => validate_go_package(&package.package_name, client).await, |
| 428 | }; |
| 429 | |
| 430 | package.exists_in_public_registry = exists; |
| 431 | package.registry_url = registry_url; |
| 432 | package.validation_error = error; |
| 433 | |
| 434 | // Mark as potential dependency confusion if package doesn't exist publicly |
| 435 | package.potential_confusion = !exists && package.validation_error.is_none(); |
| 436 | |
| 437 | Ok(()) |
| 438 | } |
| 439 | |
| 440 | /// Information about a JS file and where it was referenced |
| 441 | #[derive(Debug, Clone)] |
no test coverage detected