Skip to content

Commit dde346c

Browse files
committed
Add validation to reject fileSha256 in non-MCPB packages
Signed-off-by: Radoslav Dimitrov <[email protected]>
1 parent dbaea55 commit dde346c

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

internal/validators/registries/npm.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ func ValidateNPM(ctx context.Context, pkg model.Package, serverName string) erro
4141
return ErrMissingVersionForNPM
4242
}
4343

44+
// Validate that MCPB-specific fields are not present
45+
if pkg.FileSHA256 != "" {
46+
return fmt.Errorf("NPM packages must not have 'fileSha256' field - this is only for MCPB packages")
47+
}
48+
4449
// Validate that the registry base URL matches NPM exactly
4550
if pkg.RegistryBaseURL != model.RegistryURLNPM {
4651
return fmt.Errorf("registry type and base URL do not match: '%s' is not valid for registry type '%s'. Expected: %s",

internal/validators/registries/nuget.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ func ValidateNuGet(ctx context.Context, pkg model.Package, serverName string) er
2828
return ErrMissingIdentifierForNuget
2929
}
3030

31+
// Validate that MCPB-specific fields are not present
32+
if pkg.FileSHA256 != "" {
33+
return fmt.Errorf("NuGet packages must not have 'fileSha256' field - this is only for MCPB packages")
34+
}
35+
3136
// Validate that the registry base URL matches NuGet exactly
3237
if pkg.RegistryBaseURL != model.RegistryURLNuGet {
3338
return fmt.Errorf("registry type and base URL do not match: '%s' is not valid for registry type '%s'. Expected: %s",

internal/validators/registries/oci.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ func ValidateOCI(ctx context.Context, pkg model.Package, serverName string) erro
9696
if pkg.Version != "" {
9797
return fmt.Errorf("OCI packages must not have 'version' field - include version in 'identifier' instead (e.g., 'docker.io/owner/image:1.0.0')")
9898
}
99+
if pkg.FileSHA256 != "" {
100+
return fmt.Errorf("OCI packages must not have 'fileSha256' field - this is only for MCPB packages")
101+
}
99102

100103
// Parse the canonical OCI reference from the identifier
101104
ociRef, err := ParseOCIReference(pkg.Identifier)

internal/validators/registries/pypi.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ func ValidatePyPI(ctx context.Context, pkg model.Package, serverName string) err
3939
return ErrMissingVersionForPyPi
4040
}
4141

42+
// Validate that MCPB-specific fields are not present
43+
if pkg.FileSHA256 != "" {
44+
return fmt.Errorf("PyPI packages must not have 'fileSha256' field - this is only for MCPB packages")
45+
}
46+
4247
// Validate that the registry base URL matches PyPI exactly
4348
if pkg.RegistryBaseURL != model.RegistryURLPyPI {
4449
return fmt.Errorf("registry type and base URL do not match: '%s' is not valid for registry type '%s'. Expected: %s",

0 commit comments

Comments
 (0)