MCPcopy Create free account
hub / github.com/KingOfBugbounty/enumrust / validate_package

Function validate_package

src/package_scanner.rs:418–438  ·  view source on GitHub ↗

Validate package dependency against public registry

(
    package: &mut PackageDependency,
    client: &Client,
)

Source from the content-addressed store, hash-verified

416
417/// Validate package dependency against public registry
418pub 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)]

Callers 1

Calls 3

validate_npm_packageFunction · 0.85
validate_pip_packageFunction · 0.85
validate_go_packageFunction · 0.85

Tested by

no test coverage detected