Skip to content

Commit 12266f6

Browse files
Disable RBAC risk due to performance instability (#1609)
Co-authored-by: Viswajith Venugopal <viswajithiii@gmail.com>
1 parent f07d787 commit 12266f6

5 files changed

Lines changed: 33 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ Please avoid adding duplicate information across this changelog and JIRA/doc inp
4141
- For questions about this change, please contact the Red Hat support team at support@redhat.com.
4242
- ROX-10018: The policy `OpenShift: Kubeadmin Secret Accessed` will no longer trigger if the request was from the default OpenShift `oauth-apiserver-sa` service account, because this is an expected access pattern for the OpenShift apiserver.
4343
- Violation tags and process tags are deprecated, and will be removed in version 3.72.0.
44-
44+
- Users who do not want to include the RBAC factor in risk calculation can set
45+
the "ROX_INCLUDE_RBAC_IN_RISK" environment variable to "false" in the Central deployment spec.
4546

4647
## [69.1]
4748

‎central/risk/scorer/deployment/scorer.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/stackrox/rox/central/risk/multipliers/image"
1313
saStore "github.com/stackrox/rox/central/serviceaccount/datastore"
1414
"github.com/stackrox/rox/generated/storage"
15+
"github.com/stackrox/rox/pkg/env"
1516
"github.com/stackrox/rox/pkg/logging"
1617
)
1718

@@ -40,9 +41,13 @@ func NewDeploymentScorer(alertGetter getters.AlertGetter, roles roleStore.DataSt
4041
deployment.NewImageMultiplier(image.RiskyComponentCountHeading),
4142
deployment.NewImageMultiplier(image.ComponentCountHeading),
4243
deployment.NewImageMultiplier(image.ImageAgeHeading),
43-
deployment.NewSAPermissionsMultiplier(roles, bindings, serviceAccounts),
4444
},
4545
}
46+
if env.IncludeRBACInRisk.BooleanSetting() {
47+
scoreImpl.ConfiguredMultipliers = append(scoreImpl.ConfiguredMultipliers,
48+
deployment.NewSAPermissionsMultiplier(roles, bindings, serviceAccounts),
49+
)
50+
}
4651

4752
return scoreImpl
4853
}

‎pkg/env/rbac_risk.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package env
2+
3+
var (
4+
// IncludeRBACInRisk toggles whether RBAC is included in the risk calculation.
5+
IncludeRBACInRisk = RegisterBooleanSetting("ROX_INCLUDE_RBAC_IN_RISK", true)
6+
)

‎pkg/env/setting.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func RegisterSetting(envVar string, opts ...SettingOption) Setting {
6666
return s
6767
}
6868

69+
func unregisterSetting(envVar string) {
70+
delete(Settings, envVar)
71+
}
72+
6973
func (s *setting) EnvVar() string {
7074
return s.envVar
7175
}

‎pkg/env/setting_test.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package env
33
import (
44
"fmt"
55
"os"
6+
"strings"
67
"testing"
78
"time"
89

@@ -18,6 +19,7 @@ func TestWithoutDefault(t *testing.T) {
1819

1920
name := newRandomName()
2021
s := RegisterSetting(name)
22+
defer unregisterSetting(name)
2123

2224
a.Equal(name, s.EnvVar())
2325
a.Empty(s.Setting())
@@ -31,6 +33,7 @@ func TestWithDefault(t *testing.T) {
3133

3234
name := newRandomName()
3335
s := RegisterSetting(name, WithDefault("baz"))
36+
defer unregisterSetting(name)
3437

3538
a.Equal("baz", s.Setting())
3639

@@ -46,6 +49,7 @@ func TestWithDefaultAndAllowEmpty(t *testing.T) {
4649

4750
name := newRandomName()
4851
s := RegisterSetting(name, WithDefault("baz"), AllowEmpty())
52+
defer unregisterSetting(name)
4953

5054
a.Equal("baz", s.Setting())
5155

@@ -61,6 +65,7 @@ func TestDurationSetting(t *testing.T) {
6165

6266
name := newRandomName()
6367
s := registerDurationSetting(name, time.Minute)
68+
defer unregisterSetting(name)
6469

6570
a.Equal(time.Minute, s.DurationSetting())
6671
a.Equal("1m0s", s.Setting())
@@ -69,3 +74,13 @@ func TestDurationSetting(t *testing.T) {
6974
a.Equal(time.Hour, s.DurationSetting())
7075
a.Equal("1h0m0s", s.Setting())
7176
}
77+
78+
func TestSettingEnvVarsStartWithRox(t *testing.T) {
79+
for k := range Settings {
80+
// This one slipped by, too late to change it, so ignore in the test.
81+
if k == NotifyEveryRuntimeEvent.EnvVar() {
82+
continue
83+
}
84+
assert.True(t, strings.HasPrefix(k, "ROX_"), "Env var %s doesn't start with ROX_", k)
85+
}
86+
}

0 commit comments

Comments
 (0)