Skip to content

Commit

Permalink
Merge pull request #2035 from runcom/fix-foreign-urls-check
Browse files Browse the repository at this point in the history
registry/handles/app: always append default urls regexps
  • Loading branch information
dmcgowan committed Dec 6, 2016
2 parents 314144a + 0fb25dd commit 67095fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 4 additions & 1 deletion configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,11 @@ type Configuration struct {

// Validation configures validation options for the registry.
Validation struct {
// Enabled enables the other options in this section.
// Enabled enables the other options in this section. This field is
// deprecated in favor of Disabled.
Enabled bool `yaml:"enabled,omitempty"`
// Disabled disables the other options in this section.
Disabled bool `yaml:"disabled,omitempty"`
// Manifests configures manifest validation.
Manifests struct {
// URLs configures validation for URLs in pushed manifests.
Expand Down
16 changes: 8 additions & 8 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ information about each option that appears later in this page.
schema1:
signingkeyfile: /etc/registry/key.json
validation:
enabled: true
manifests:
urls:
allow:
Expand Down Expand Up @@ -1871,24 +1870,25 @@ defines such a feature with configurable behavior.
## Validation

validation:
enabled: true
manifests:
urls:
allow:
- ^https?://([^/]+\.)*example\.com/
deny:
- ^https?://www\.example\.com/

### Enabled
### disabled

Use the `enabled` flag to enable the other options in the `validation`
section. They are disabled by default.
Use the `disabled` flag to disable the other options in the `validation`
section. They are enabled by default.
This option deprecates the `enabled` flag.

### Manifests
### manifests

Use the `manifest` subsection to configure manifest validation.
Use the `manifests` subsection to configure manifests validation. If `disabled` is
`false` the validation allows nothing.

#### URLs
#### urls

The `allow` and `deny` options are both lists of
[regular expressions](https://godoc.org/regexp/syntax) that restrict the URLs in
Expand Down
4 changes: 4 additions & 0 deletions registry/handlers/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ func NewApp(ctx context.Context, config *configuration.Configuration) *App {
options = append(options, storage.EnableRedirect)
}

if !config.Validation.Enabled {
config.Validation.Enabled = !config.Validation.Disabled
}

// configure validation
if config.Validation.Enabled {
if len(config.Validation.Manifests.URLs.Allow) == 0 && len(config.Validation.Manifests.URLs.Deny) == 0 {
Expand Down

0 comments on commit 67095fb

Please sign in to comment.