mirror of
https://github.com/distribution/distribution.git
synced 2025-09-24 04:27:01 +00:00
Merge pull request from GHSA-hqxw-f8mx-cpmw
[release/2.8] Fix runaway allocation on /v2/_catalog
This commit is contained in:
@@ -193,7 +193,8 @@ type Configuration struct {
|
||||
} `yaml:"pool,omitempty"`
|
||||
} `yaml:"redis,omitempty"`
|
||||
|
||||
Health Health `yaml:"health,omitempty"`
|
||||
Health Health `yaml:"health,omitempty"`
|
||||
Catalog Catalog `yaml:"catalog,omitempty"`
|
||||
|
||||
Proxy Proxy `yaml:"proxy,omitempty"`
|
||||
|
||||
@@ -244,6 +245,16 @@ type Configuration struct {
|
||||
} `yaml:"policy,omitempty"`
|
||||
}
|
||||
|
||||
// Catalog is composed of MaxEntries.
|
||||
// Catalog endpoint (/v2/_catalog) configuration, it provides the configuration
|
||||
// options to control the maximum number of entries returned by the catalog endpoint.
|
||||
type Catalog struct {
|
||||
// Max number of entries returned by the catalog endpoint. Requesting n entries
|
||||
// to the catalog endpoint will return at most MaxEntries entries.
|
||||
// An empty or a negative value will set a default of 1000 maximum entries by default.
|
||||
MaxEntries int `yaml:"maxentries,omitempty"`
|
||||
}
|
||||
|
||||
// LogHook is composed of hook Level and Type.
|
||||
// After hooks configuration, it can execute the next handling automatically,
|
||||
// when defined levels of log message emitted.
|
||||
@@ -670,6 +681,11 @@ func Parse(rd io.Reader) (*Configuration, error) {
|
||||
if v0_1.Loglevel != Loglevel("") {
|
||||
v0_1.Loglevel = Loglevel("")
|
||||
}
|
||||
|
||||
if v0_1.Catalog.MaxEntries <= 0 {
|
||||
v0_1.Catalog.MaxEntries = 1000
|
||||
}
|
||||
|
||||
if v0_1.Storage.Type() == "" {
|
||||
return nil, errors.New("no storage configuration provided")
|
||||
}
|
||||
|
@@ -71,6 +71,9 @@ var configStruct = Configuration{
|
||||
},
|
||||
},
|
||||
},
|
||||
Catalog: Catalog{
|
||||
MaxEntries: 1000,
|
||||
},
|
||||
HTTP: struct {
|
||||
Addr string `yaml:"addr,omitempty"`
|
||||
Net string `yaml:"net,omitempty"`
|
||||
@@ -524,6 +527,7 @@ func copyConfig(config Configuration) *Configuration {
|
||||
configCopy.Version = MajorMinorVersion(config.Version.Major(), config.Version.Minor())
|
||||
configCopy.Loglevel = config.Loglevel
|
||||
configCopy.Log = config.Log
|
||||
configCopy.Catalog = config.Catalog
|
||||
configCopy.Log.Fields = make(map[string]interface{}, len(config.Log.Fields))
|
||||
for k, v := range config.Log.Fields {
|
||||
configCopy.Log.Fields[k] = v
|
||||
|
Reference in New Issue
Block a user