Skip to content

Commit

Permalink
refactored privilege pss logic (#181)
Browse files Browse the repository at this point in the history
* refactored privilege pss logic

Signed-off-by: Ved Ratan <[email protected]>
  • Loading branch information
VedRatan authored Jun 14, 2024
1 parent 545b49c commit 4aec2fc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
5 changes: 1 addition & 4 deletions pkg/adapter/nimbus-kyverno/processor/kcpbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ func clusterEscapeToHost(cnp *v1alpha1.ClusterNimbusPolicy, rule v1alpha1.Rule)
case "restricted":
psa_level = api.LevelRestricted

case "privileged":
psa_level = api.LevelPrivileged

default:
psa_level = api.LevelBaseline
}
Expand Down Expand Up @@ -131,7 +128,7 @@ func clusterEscapeToHost(cnp *v1alpha1.ClusterNimbusPolicy, rule v1alpha1.Rule)
Background: &background,
Rules: []kyvernov1.Rule{
{
Name: "restricted",
Name: "pod-security-standard",
MatchResources: kyvernov1.MatchResources{
Any: matchFilters,
},
Expand Down
7 changes: 2 additions & 5 deletions pkg/adapter/nimbus-kyverno/processor/kpbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ func escapeToHost(np *v1alpha1.NimbusPolicy, rule v1alpha1.Rule) kyvernov1.Polic
switch rule.Params["psa_level"][0] {
case "restricted":
psa_level = api.LevelRestricted

case "privileged":
psa_level = api.LevelPrivileged


default:
psa_level = api.LevelBaseline
}
Expand All @@ -76,7 +73,7 @@ func escapeToHost(np *v1alpha1.NimbusPolicy, rule v1alpha1.Rule) kyvernov1.Polic
Background: &background,
Rules: []kyvernov1.Rule{
{
Name: "restricted",
Name: "pod-security-standard",
MatchResources: kyvernov1.MatchResources{
Any: kyvernov1.ResourceFilters{
kyvernov1.ResourceFilter{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
app: nginx
resources: {}
mutate: {}
name: restricted
name: pod-security-standard
skipBackgroundRequests: true
validate:
podSecurity:
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/escape-to-host/kyverno-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
app: nginx
resources: {}
mutate: {}
name: restricted
name: pod-security-standard
skipBackgroundRequests: true
validate:
podSecurity:
Expand Down

0 comments on commit 4aec2fc

Please sign in to comment.