Skip to content

Commit a4e5e53

Browse files
Merge pull request #13282 from jim-minter/secret-injector-improvements
Automatic merge from submit-queue (batch tested with PRs 16269, 13282, 16386) Improvements to secret injector Disallow @ character in host component of URL patterns, so that people don't mistakenly try to add URL patterns of the form user@host. Extend admission controller to reject invalid URL patterns on secrets to provide early feedback to end users when their patterns are wrong.
2 parents 0a33b4c + ae22665 commit a4e5e53

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pkg/util/urlpattern/urlpattern.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var InvalidPatternError = errors.New("invalid pattern")
1212

1313
var urlPatternRegex = regexp.MustCompile(`^` +
1414
`(?:(\*|git|http|https|ssh)://)` +
15-
`(\*|(?:\*\.)?[^/*]+)` +
15+
`(\*|(?:\*\.)?[^@/*]+)` +
1616
`(/.*)` +
1717
`$`)
1818

pkg/util/urlpattern/urlpattern_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestMatchPattern(t *testing.T) {
4444
expectedScheme: `^(git|http|https|ssh)$`,
4545
expectedHost: `^.*$`,
4646
expectedPath: `^/.*$`,
47-
expectedMatch: []string{`https://github.com/`},
47+
expectedMatch: []string{`https://github.com/`, `https://user:[email protected]/`, `ssh://[email protected]/`},
4848
expectedNotMatch: []string{`ftp://github.com/`},
4949
},
5050
{
@@ -80,15 +80,15 @@ func TestMatchPattern(t *testing.T) {
8080
expectedScheme: `^https$`,
8181
expectedHost: `^github\.com$`,
8282
expectedPath: `^/.*$`,
83-
expectedMatch: []string{`https://github.com/`},
83+
expectedMatch: []string{`https://github.com/`, `https://user:[email protected]/`},
8484
expectedNotMatch: []string{`https://test.github.com/`},
8585
},
8686
{
8787
pattern: `https://*.github.com/*`,
8888
expectedScheme: `^https$`,
8989
expectedHost: `^(?:.*\.)?github\.com$`,
9090
expectedPath: `^/.*$`,
91-
expectedMatch: []string{`https://github.com/`, `https://test.github.com/`},
91+
expectedMatch: []string{`https://github.com/`, `https://user:[email protected]/`, `https://test.github.com/`},
9292
},
9393
{
9494
pattern: `https://\.+?()|[]{}^$/*`,
@@ -108,6 +108,10 @@ func TestMatchPattern(t *testing.T) {
108108
pattern: `https://git*hub.com/*`,
109109
expectedErr: true,
110110
},
111+
{
112+
pattern: `*://[email protected]/*`,
113+
expectedErr: true,
114+
},
111115
{
112116
pattern: `https://github.com/`,
113117
expectedScheme: `^https$`,

0 commit comments

Comments
 (0)