ValidatePackage validates that the package referenced in the server configuration is: 1. allowed on the official registry (based on registry base url); and 2. owned by the publisher, by checking for a matching server name in the package metadata
(ctx context.Context, pkg model.Package, serverName string)
| 12 | // 1. allowed on the official registry (based on registry base url); and |
| 13 | // 2. owned by the publisher, by checking for a matching server name in the package metadata |
| 14 | func ValidatePackage(ctx context.Context, pkg model.Package, serverName string) error { |
| 15 | switch pkg.RegistryType { |
| 16 | case model.RegistryTypeNPM: |
| 17 | return registries.ValidateNPM(ctx, pkg, serverName) |
| 18 | case model.RegistryTypePyPI: |
| 19 | return registries.ValidatePyPI(ctx, pkg, serverName) |
| 20 | case model.RegistryTypeNuGet: |
| 21 | return registries.ValidateNuGet(ctx, pkg, serverName) |
| 22 | case model.RegistryTypeOCI: |
| 23 | return registries.ValidateOCI(ctx, pkg, serverName) |
| 24 | case model.RegistryTypeMCPB: |
| 25 | return registries.ValidateMCPB(ctx, pkg, serverName) |
| 26 | default: |
| 27 | return fmt.Errorf("unsupported registry type: %s", pkg.RegistryType) |
| 28 | } |
| 29 | } |
no test coverage detected
searching dependent graphs…