Skip to content

Commit 96e610a

Browse files
committed
ClusterTrustBundle: Enforce max size during validation
1 parent 1ebe577 commit 96e610a

File tree

3 files changed

+212
-183
lines changed

3 files changed

+212
-183
lines changed

pkg/apis/certificates/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,6 @@ type ClusterTrustBundleList struct {
277277
// Items is a collection of ClusterTrustBundle objects
278278
Items []ClusterTrustBundle
279279
}
280+
281+
// MaxTrustBundleSize is the maximimum size of a single trust bundle field.
282+
const MaxTrustBundleSize = 1 * 1024 * 1024

pkg/apis/certificates/validation/validation.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,11 @@ func ValidateClusterTrustBundleUpdate(newBundle, oldBundle *certificates.Cluster
508508
func validateTrustBundle(path *field.Path, in string) field.ErrorList {
509509
var allErrors field.ErrorList
510510

511+
if len(in) > certificates.MaxTrustBundleSize {
512+
allErrors = append(allErrors, field.TooLong(path, fmt.Sprintf("<value omitted, len %d>", len(in)), certificates.MaxTrustBundleSize))
513+
return allErrors
514+
}
515+
511516
blockDedupe := map[string][]int{}
512517

513518
rest := []byte(in)

0 commit comments

Comments
 (0)