Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
5539a672
Commit
5539a672
authored
May 24, 2017
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent illegal verb/name combinations in default policy rules
parent
6f7eac63
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
1 deletion
+33
-1
helpers.go
pkg/apis/rbac/helpers.go
+16
-0
Godeps.json
staging/src/k8s.io/client-go/Godeps/Godeps.json
+1
-1
helpers.go
staging/src/k8s.io/client-go/pkg/apis/rbac/helpers.go
+16
-0
No files found.
pkg/apis/rbac/helpers.go
View file @
5539a672
...
@@ -190,6 +190,22 @@ func (r *PolicyRuleBuilder) Rule() (PolicyRule, error) {
...
@@ -190,6 +190,22 @@ func (r *PolicyRuleBuilder) Rule() (PolicyRule, error) {
// this a common bug
// this a common bug
return
PolicyRule
{},
fmt
.
Errorf
(
"resource rule must have apiGroups: %#v"
,
r
.
PolicyRule
)
return
PolicyRule
{},
fmt
.
Errorf
(
"resource rule must have apiGroups: %#v"
,
r
.
PolicyRule
)
}
}
// if resource names are set, then the verb must not be list, watch, create, or deletecollection
// since verbs are largely opaque, we don't want to accidentally prevent things like "impersonate", so
// we will backlist common mistakes, not whitelist acceptable options.
if
len
(
r
.
PolicyRule
.
ResourceNames
)
!=
0
{
illegalVerbs
:=
[]
string
{}
for
_
,
verb
:=
range
r
.
PolicyRule
.
Verbs
{
switch
verb
{
case
"list"
,
"watch"
,
"create"
,
"deletecollection"
:
illegalVerbs
=
append
(
illegalVerbs
,
verb
)
}
}
if
len
(
illegalVerbs
)
>
0
{
return
PolicyRule
{},
fmt
.
Errorf
(
"verbs %v do not have names available: %#v"
,
illegalVerbs
,
r
.
PolicyRule
)
}
}
default
:
default
:
return
PolicyRule
{},
fmt
.
Errorf
(
"a rule must have either nonResourceURLs or resources: %#v"
,
r
.
PolicyRule
)
return
PolicyRule
{},
fmt
.
Errorf
(
"a rule must have either nonResourceURLs or resources: %#v"
,
r
.
PolicyRule
)
}
}
...
...
staging/src/k8s.io/client-go/Godeps/Godeps.json
View file @
5539a672
{
{
"ImportPath"
:
"k8s.io/client-go"
,
"ImportPath"
:
"k8s.io/client-go"
,
"GoVersion"
:
"go1.
7
"
,
"GoVersion"
:
"go1.
8
"
,
"GodepVersion"
:
"v79"
,
"GodepVersion"
:
"v79"
,
"Packages"
:
[
"Packages"
:
[
"./..."
"./..."
...
...
staging/src/k8s.io/client-go/pkg/apis/rbac/helpers.go
View file @
5539a672
...
@@ -189,6 +189,22 @@ func (r *PolicyRuleBuilder) Rule() (PolicyRule, error) {
...
@@ -189,6 +189,22 @@ func (r *PolicyRuleBuilder) Rule() (PolicyRule, error) {
// this a common bug
// this a common bug
return
PolicyRule
{},
fmt
.
Errorf
(
"resource rule must have apiGroups: %#v"
,
r
.
PolicyRule
)
return
PolicyRule
{},
fmt
.
Errorf
(
"resource rule must have apiGroups: %#v"
,
r
.
PolicyRule
)
}
}
// if resource names are set, then the verb must not be list, watch, create, or deletecollection
// since verbs are largely opaque, we don't want to accidentally prevent things like "impersonate", so
// we will backlist common mistakes, not whitelist acceptable options.
if
len
(
r
.
PolicyRule
.
ResourceNames
)
!=
0
{
illegalVerbs
:=
[]
string
{}
for
_
,
verb
:=
range
r
.
PolicyRule
.
Verbs
{
switch
verb
{
case
"list"
,
"watch"
,
"create"
,
"deletecollection"
:
illegalVerbs
=
append
(
illegalVerbs
,
verb
)
}
}
if
len
(
illegalVerbs
)
>
0
{
return
PolicyRule
{},
fmt
.
Errorf
(
"verbs %v do not have names available: %#v"
,
illegalVerbs
,
r
.
PolicyRule
)
}
}
default
:
default
:
return
PolicyRule
{},
fmt
.
Errorf
(
"a rule must have either nonResourceURLs or resources: %#v"
,
r
.
PolicyRule
)
return
PolicyRule
{},
fmt
.
Errorf
(
"a rule must have either nonResourceURLs or resources: %#v"
,
r
.
PolicyRule
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment